|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +################################################# |
| 4 | +# # |
| 5 | +# A shell script to install Salt Minion # |
| 6 | +# on CentOS or Debian # |
| 7 | +# # |
| 8 | +################################################# |
| 9 | + |
| 10 | +# check if the current user is root |
| 11 | +if [[ $(/usr/bin/id -u) != "0" ]]; then |
| 12 | + echo -e "This looks like a 'non-root' user.\nPlease switch to 'root' and run the script again." |
| 13 | + exit |
| 14 | +fi |
| 15 | + |
| 16 | +os_type=$(gawk -F= '/^ID=/{print 2ドル}' /etc/os-release) |
| 17 | + |
| 18 | +prerequisites_centos(){ |
| 19 | + |
| 20 | + cat > /etc/yum.repos.d/saltstack.repo << saltrepo |
| 21 | +[saltstack-repo] |
| 22 | +name=SaltStack repo for Red Hat Enterprise Linux \$releasever |
| 23 | +baseurl=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/latest |
| 24 | +enabled=1 |
| 25 | +gpgcheck=1 |
| 26 | +gpgkey=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/latest/SALTSTACK-GPG-KEY.pub |
| 27 | + https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/latest/base/RPM-GPG-KEY-CentOS-7 |
| 28 | +saltrepo |
| 29 | + |
| 30 | + yum update -y |
| 31 | + yum install systemd systemd-python -y |
| 32 | +} |
| 33 | + |
| 34 | +prerequisites_debian() { |
| 35 | + wget -O - https://repo.saltstack.com/apt/debian/8/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - |
| 36 | + echo "deb http://repo.saltstack.com/apt/debian/8/amd64/latest jessie main" > /etc/apt/sources.list.d/saltstack.list |
| 37 | + |
| 38 | + apt-get upgrade -y |
| 39 | + apt-get update -y |
| 40 | + apt-get install systemd python-systemd -y |
| 41 | +} |
| 42 | + |
| 43 | +install_saltminion_centos() { |
| 44 | + yum install salt-common salt-minion salt-ssh -y |
| 45 | +} |
| 46 | + |
| 47 | +install_saltminion_debian() { |
| 48 | + apt-get install salt-common salt-minion salt-ssh -y |
| 49 | +} |
| 50 | + |
| 51 | +if [[ $os_type == "\"centos\"" || $os_type == "\"rhel\"" ]]; then |
| 52 | + prerequisites_centos |
| 53 | + install_saltminion_centos |
| 54 | +elif [[ $os_type == "debian" || $os_type == "ubuntu" ]]; then |
| 55 | + prerequisites_debian |
| 56 | + install_saltminion_debian |
| 57 | +fi |
0 commit comments