2323# ======================================================================================================================
2424set -o nounset # Treat unset variables as an error
2525
26- __ScriptVersion=" 2019.05.20 "
26+ __ScriptVersion=" 2019.10.03 "
2727__ScriptName=" bootstrap-salt.sh"
2828
2929__ScriptFullName=" $0 "
@@ -601,7 +601,11 @@ elif [ "$ITYPE" = "stable" ]; then
601601 STABLE_REV=" $1 "
602602 shift
603603 elif [ " $( echo " $1 " | grep -E ' ^([0-9]*\.[0-9]*\.[0-9]*)$' ) " != " " ]; then
604- STABLE_REV=" archive/$1 "
604+ if [ " $( uname) " = " Darwin" ]; then
605+ STABLE_REV=" $1 "
606+ else
607+ STABLE_REV=" archive/$1 "
608+ fi
605609 shift
606610 else
607611 echo " Unknown stable version: $1 (valid: 1.6, 1.7, 2014.1, 2014.7, 2015.5, 2015.8, 2016.3, 2016.11, 2017.7, 2018.3, 2019.2, latest, \$ MAJOR.\$ MINOR.\$ PATCH)"
667671
668672# Check if we're installing via a different Python executable and set major version variables
669673if [ -n " $_PY_EXE " ]; then
670- _PY_PKG_VER=$( echo " $_PY_EXE " | sed -r " s/\\ .//g" )
674+ if [ " $( uname) " = " Darwin" ]; then
675+ _PY_PKG_VER=$( echo " $_PY_EXE " | sed " s/\\ .//g" )
676+ else
677+ _PY_PKG_VER=$( echo " $_PY_EXE " | sed -r " s/\\ .//g" )
678+ fi
671679
672680 _PY_MAJOR_VERSION=$( echo " $_PY_PKG_VER " | cut -c 7)
673681 if [ " $_PY_MAJOR_VERSION " != 3 ] && [ " $_PY_MAJOR_VERSION " != 2 ]; then
@@ -1001,7 +1009,7 @@ __gather_linux_system_info() {
10011009 elif [ " ${DISTRO_NAME} " = " OracleServer" ]; then
10021010 # This the Oracle Linux Server 6.5
10031011 DISTRO_NAME=" Oracle Linux"
1004- elif [ " ${DISTRO_NAME} " = " AmazonAMI" ]; then
1012+ elif [ " ${DISTRO_NAME} " = " AmazonAMI" ] || [ " ${DISTRO_NAME} " = " Amazon " ] ; then
10051013 DISTRO_NAME=" Amazon Linux AMI"
10061014 elif [ " ${DISTRO_NAME} " = " ManjaroLinux" ]; then
10071015 DISTRO_NAME=" Arch Linux"
@@ -1243,6 +1251,16 @@ __gather_bsd_system_info() {
12431251}
12441252
12451253
1254+ # --- FUNCTION -------------------------------------------------------------------------------------------------------
1255+ # NAME: __gather_osx_system_info
1256+ # DESCRIPTION: Discover MacOS X
1257+ # ----------------------------------------------------------------------------------------------------------------------
1258+ __gather_osx_system_info () {
1259+ DISTRO_NAME=" MacOSX"
1260+ DISTRO_VERSION=$( sw_vers -productVersion)
1261+ }
1262+
1263+
12461264# --- FUNCTION -------------------------------------------------------------------------------------------------------
12471265# NAME: __gather_system_info
12481266# DESCRIPTION: Discover which system and distribution we are running.
@@ -1258,6 +1276,9 @@ __gather_system_info() {
12581276 openbsd|freebsd|netbsd )
12591277 __gather_bsd_system_info
12601278 ;;
1279+ darwin )
1280+ __gather_osx_system_info
1281+ ;;
12611282 * )
12621283 echoerror " ${OS_NAME} not supported." ;
12631284 exit 1
@@ -1448,6 +1469,7 @@ __debian_derivatives_translation() {
14481469 linuxmint_1_debian_base=" 8.0"
14491470 raspbian_8_debian_base=" 8.0"
14501471 raspbian_9_debian_base=" 9.0"
1472+ raspbian_10_debian_base=" 10.0"
14511473 bunsenlabs_9_debian_base=" 9.0"
14521474 turnkey_9_debian_base=" 9.0"
14531475
@@ -2648,13 +2670,12 @@ __install_saltstack_ubuntu_repository() {
26482670 UBUNTU_CODENAME=${DISTRO_CODENAME}
26492671 fi
26502672
2651- __PACKAGES=' '
2652-
26532673 # Install downloader backend for GPG keys fetching
2654- if [ " $DISTRO_MAJOR_VERSION " -gt 16 ]; then
2655- __PACKAGES=" ${__PACKAGES} gnupg dirmngr"
2656- else
2657- __PACKAGES=" ${__PACKAGES} gnupg-curl"
2674+ __PACKAGES=' wget'
2675+
2676+ # Required as it is not installed by default on Ubuntu 18+
2677+ if [ " $DISTRO_MAJOR_VERSION " -ge 18 ]; then
2678+ __PACKAGES=" ${__PACKAGES} gnupg"
26582679 fi
26592680
26602681 # Make sure https transport is available
@@ -2698,6 +2719,12 @@ install_ubuntu_deps() {
26982719 __PACKAGES=" upstart"
26992720 fi
27002721
2722+ if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ]; then
2723+ PY_PKG_VER=3
2724+ else
2725+ PY_PKG_VER=" "
2726+ fi
2727+
27012728 if [ " $DISTRO_MAJOR_VERSION " -ge 16 ] && [ -z " $_PY_EXE " ]; then
27022729 __PACKAGES=" ${__PACKAGES} python2.7"
27032730 fi
@@ -2706,13 +2733,13 @@ install_ubuntu_deps() {
27062733 __PACKAGES=" ${__PACKAGES} python-virtualenv"
27072734 fi
27082735 # Need python-apt for managing packages via Salt
2709- __PACKAGES=" ${__PACKAGES} python-apt"
2736+ __PACKAGES=" ${__PACKAGES} python${PY_PKG_VER} -apt"
27102737
27112738 # requests is still used by many salt modules
2712- __PACKAGES=" ${__PACKAGES} python-requests"
2739+ __PACKAGES=" ${__PACKAGES} python${PY_PKG_VER} -requests"
27132740
27142741 # YAML module is used for generating custom master/minion configs
2715- __PACKAGES=" ${__PACKAGES} python-yaml"
2742+ __PACKAGES=" ${__PACKAGES} python${PY_PKG_VER} -yaml"
27162743
27172744 # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813
27182745 __PACKAGES=" ${__PACKAGES} procps pciutils"
@@ -3049,13 +3076,12 @@ __install_saltstack_debian_repository() {
30493076 __PY_VERSION_REPO=" py3"
30503077 fi
30513078
3052- __PACKAGES=' '
3053-
30543079 # Install downloader backend for GPG keys fetching
3080+ __PACKAGES=' wget'
3081+
3082+ # Required as it is not installed by default on Debian 9+
30553083 if [ " $DISTRO_MAJOR_VERSION " -ge 9 ]; then
3056- __PACKAGES=" ${__PACKAGES} gnupg2 dirmngr"
3057- else
3058- __PACKAGES=" ${__PACKAGES} gnupg-curl"
3084+ __PACKAGES=" ${__PACKAGES} gnupg2"
30593085 fi
30603086
30613087 # Make sure https transport is available
@@ -3375,14 +3401,8 @@ install_debian_git_post() {
33753401 # Install initscripts for Debian 7 "Wheezy"
33763402 elif [ ! -f " /etc/init.d/salt-$fname " ] || \
33773403 { [ -f " /etc/init.d/salt-$fname " ] && [ " $_FORCE_OVERWRITE " -eq $BS_TRUE ]; }; then
3378- if [ -f " ${_SALT_GIT_CHECKOUT_DIR} /pkg/salt-$fname .init" ]; then
3379- __copyfile " ${_SALT_GIT_CHECKOUT_DIR} /pkg/salt-${fname} .init" " /etc/init.d/salt-${fname} "
3380- __copyfile " ${_SALT_GIT_CHECKOUT_DIR} /pkg/salt-${fname} .environment" " /etc/default/salt-${fname} "
3381- else
3382- # Make sure wget is available
3383- __check_command_exists wget || __apt_get_install_noinput wget || return 1
3384- __fetch_url " /etc/init.d/salt-${fname} " " ${HTTP_VAL} ://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt-${fname} .init"
3385- fi
3404+ __copyfile " ${_SALT_GIT_CHECKOUT_DIR} /pkg/deb/salt-${fname} .init" " /etc/init.d/salt-${fname} "
3405+ __copyfile " ${_SALT_GIT_CHECKOUT_DIR} /pkg/deb/salt-${fname} .environment" " /etc/default/salt-${fname} "
33863406
33873407 if [ ! -f " /etc/init.d/salt-${fname} " ]; then
33883408 echowarn " The init script for salt-${fname} was not found, skipping it..."
@@ -6611,6 +6631,117 @@ daemons_running_voidlinux() {
66116631#
66126632# ######################################################################################################################
66136633
6634+ # ######################################################################################################################
6635+ #
6636+ # OS X / Darwin Install Functions
6637+ #
6638+
6639+ __macosx_get_packagesite () {
6640+ DARWIN_ARCH=" x86_64"
6641+
6642+ __PY_VERSION_REPO=" py2"
6643+ if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ]; then
6644+ __PY_VERSION_REPO=" py3"
6645+ fi
6646+
6647+ PKG=" salt-${STABLE_REV} -${__PY_VERSION_REPO} -${DARWIN_ARCH} .pkg"
6648+ SALTPKGCONFURL=" https://repo.saltstack.com/osx/${PKG} "
6649+ }
6650+
6651+ # Using a separate conf step to head for idempotent install...
6652+ __configure_macosx_pkg_details () {
6653+ __macosx_get_packagesite || return 1
6654+ return 0
6655+ }
6656+
6657+ install_macosx_stable_deps () {
6658+ __configure_macosx_pkg_details || return 1
6659+ return 0
6660+ }
6661+
6662+ install_macosx_git_deps () {
6663+ install_macosx_stable_deps || return 1
6664+
6665+ __fetch_url " /tmp/get-pip.py" " https://bootstrap.pypa.io/get-pip.py" || return 1
6666+
6667+ if [ -n " $_PY_EXE " ]; then
6668+ _PYEXE=${_PY_EXE}
6669+ else
6670+ _PYEXE=python2.7
6671+ fi
6672+
6673+ # Install PIP
6674+ $_PYEXE /tmp/get-pip.py || return 1
6675+
6676+ __git_clone_and_checkout || return 1
6677+
6678+ __PIP_REQUIREMENTS=" dev_python27.txt"
6679+ if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ]; then
6680+ __PIP_REQUIREMENTS=" dev_python34.txt"
6681+ fi
6682+
6683+ requirements_file=" ${_SALT_GIT_CHECKOUT_DIR} /requirements/${__PIP_REQUIREMENTS} "
6684+ pip install -U -r " ${requirements_file} " --install-option=" --prefix=/opt/salt" || return 1
6685+
6686+ return 0
6687+ }
6688+
6689+ install_macosx_stable () {
6690+ install_macosx_stable_deps || return 1
6691+
6692+ /usr/bin/curl " ${SALTPKGCONFURL} " > " /tmp/${PKG} " || return 1
6693+
6694+ /usr/sbin/installer -pkg " /tmp/${PKG} " -target / || return 1
6695+
6696+ return 0
6697+ }
6698+
6699+ install_macosx_git () {
6700+
6701+ if [ -n " $_PY_EXE " ]; then
6702+ _PYEXE=${_PY_EXE}
6703+ else
6704+ _PYEXE=python2.7
6705+ fi
6706+
6707+ if [ -f " ${_SALT_GIT_CHECKOUT_DIR} /salt/syspaths.py" ]; then
6708+ $_PYEXE setup.py --salt-config-dir=" $_SALT_ETC_DIR " --salt-cache-dir=" ${_SALT_CACHE_DIR} " ${SETUP_PY_INSTALL_ARGS} install --prefix=/opt/salt || return 1
6709+ else
6710+ $_PYEXE setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/opt/salt || return 1
6711+ fi
6712+
6713+ return 0
6714+ }
6715+
6716+ install_macosx_stable_post () {
6717+ if [ ! -f /etc/paths.d/salt ]; then
6718+ print " %s\n" " /opt/salt/bin" " /usr/local/sbin" > /etc/paths.d/salt
6719+ fi
6720+
6721+ # shellcheck disable=SC1091
6722+ . /etc/profile
6723+
6724+ return 0
6725+ }
6726+
6727+ install_macosx_git_post () {
6728+ install_macosx_stable_post || return 1
6729+ return 0
6730+ }
6731+
6732+ install_macosx_restart_daemons () {
6733+ [ $_START_DAEMONS -eq $BS_FALSE ] && return
6734+
6735+ /bin/launchctl unload -w /Library/LaunchDaemons/com.saltstack.salt.minion.plist || return 1
6736+ /bin/launchctl load -w /Library/LaunchDaemons/com.saltstack.salt.minion.plist || return 1
6737+
6738+ return 0
6739+ }
6740+ #
6741+ # Ended OS X / Darwin Install Functions
6742+ #
6743+ # ######################################################################################################################
6744+
66146745# ######################################################################################################################
66156746#
66166747# Default minion configuration function. Matches ANY distribution as long as
0 commit comments