From f31025464cb64782fd0e34832e6797ad0bfe7f1a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 22 Oct 2012 02:01:01 +0100 Subject: [PATCH 1/4] One more copy/paste bug. --- bootstrap-salt-minion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-salt-minion.sh b/bootstrap-salt-minion.sh index ad63efb..66607fe 100755 --- a/bootstrap-salt-minion.sh +++ b/bootstrap-salt-minion.sh @@ -605,7 +605,7 @@ POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}_post" POST_INSTALL_FUNC="null" for FUNC_NAME in $POST_FUNC_NAMES; do if __function_defined $FUNC_NAME; then - DEPS_INSTALL_FUNC=$FUNC_NAME + POST_INSTALL_FUNC=$FUNC_NAME break fi done From 24d35432487f68bcb16ab4b31a826258f85ba968 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 22 Oct 2012 03:39:33 +0100 Subject: [PATCH 2/4] Add CentOS git install support. --- bootstrap-salt-minion.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/bootstrap-salt-minion.sh b/bootstrap-salt-minion.sh index 66607fe..b6dacf7 100755 --- a/bootstrap-salt-minion.sh +++ b/bootstrap-salt-minion.sh @@ -449,7 +449,6 @@ install_fedora_stable() { # # CentOS Install Functions # - install_centos_63_stable_deps() { if [ $CPU_ARCH_L = "i686" ]; then local ARCH="i386" @@ -466,8 +465,34 @@ install_centos_63_stable() { install_centos_63_stable_post() { /sbin/chkconfig salt-minion on + #/etc/init.d/salt-minion start & salt-minion start & } + +install_centos_63_git_deps() { + install_centos_63_stable_deps + yum -y install git PyYAML m2crypto python-crypto python-msgpack python-zmq python-jinja2 --enablerepo=epel-testing +} + +install_centos_63_git() { + rm -rf /usr/lib/python*/site-packages/salt + rm -rf /usr/bin/salt* + cd /tmp + git clone git://github.com/saltstack/salt.git + cd salt + git checkout $GIT_REV + python2 setup.py install + mkdir -p /etc/salt/ + +} + +install_centos_63_git_post() { + cp pkg/rpm/salt-{master,minion} /etc/init.d/ + chmod +x /etc/init.d/salt-{master,minion} + /sbin/chkconfig salt-minion on + /etc/init.d/salt-minion start & + sleep 1 +} # # Ended CentOS Install Functions # @@ -638,3 +663,4 @@ fi # Done! echo " * Salt installed!" +exit 0 From cffc725e086a31b859892e6c40cd7877a76fa96f Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 23 Oct 2012 04:16:03 +0100 Subject: [PATCH 3/4] Properly kill any sub-shells started while running the script. Fixes hanging in CentOS bootstrap. --- bootstrap-salt-minion.sh | 42 ++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/bootstrap-salt-minion.sh b/bootstrap-salt-minion.sh index b6dacf7..c67a167 100755 --- a/bootstrap-salt-minion.sh +++ b/bootstrap-salt-minion.sh @@ -102,14 +102,10 @@ if [ $(whoami) != "root" ] ; then exit 1 fi - # Define our logging file and pipe paths LOGFILE="/tmp/$(basename $0 | sed s/.sh/.log/g )" LOGPIPE="/tmp/$(basename $0 | sed s/.sh/.logpipe/g )" -# Remove the logging pipe when the script exits -trap "rm -f $LOGPIPE" EXIT - # Create our logging pipe mknod $LOGPIPE p @@ -123,6 +119,38 @@ exec 1>$LOGPIPE exec 2>&- exec 2>$LOGPIPE +#--- FUNCTION ---------------------------------------------------------------- +# NAME: __exit_cleanup +# DESCRIPTION: Cleanup any leftovers after script has ended +#------------------------------------------------------------------------------- +__exit_cleanup() { + EXIT_CODE=$? + + # Remove the logging pipe when the script exits + echo " * Removing the logging pipe $LOGPIPE" + rm -f $LOGPIPE + + # Kill tee when exiting, CentOS, at least requires this + TEE_PID=$(ps ax | grep tee | grep $LOGFILE | awk '{print $1}') + echo " * Killing logging pipe tee's with pid(s): $TEE_PID" + + # We need to trap errors since killing tee will cause a 127 errno + # We also do this as late as possible so we don't "mis-catch" other errors + __trap_errors() { + echo "Errors Trapped: $EXIT_CODE" + # Exit with the "original" exit code, not the trapped code + exit $EXIT_CODE + } + trap "__trap_errors" ERR + + # Now we're "good" to kill tee + kill -TERM $TEE_PID + + # In case the 127 errno is not triggered, exit with the "original" exit code + exit $EXIT_CODE +} +trap "__exit_cleanup" EXIT + #--- FUNCTION ---------------------------------------------------------------- # NAME: __gather_hardware_info @@ -465,8 +493,7 @@ install_centos_63_stable() { install_centos_63_stable_post() { /sbin/chkconfig salt-minion on - #/etc/init.d/salt-minion start & - salt-minion start & + /etc/init.d/salt-minion start } install_centos_63_git_deps() { @@ -490,8 +517,7 @@ install_centos_63_git_post() { cp pkg/rpm/salt-{master,minion} /etc/init.d/ chmod +x /etc/init.d/salt-{master,minion} /sbin/chkconfig salt-minion on - /etc/init.d/salt-minion start & - sleep 1 + /etc/init.d/salt-minion start } # # Ended CentOS Install Functions From 5d37d059e221889b3d0aa81ffe0df95d5aa21fda Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 23 Oct 2012 08:09:12 +0100 Subject: [PATCH 4/4] Don't ignore the CPU for FreeBSD installs, and the functions are for FreeBSD 9. FreeBSD installs are still untested. --- bootstrap-salt-minion.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/bootstrap-salt-minion.sh b/bootstrap-salt-minion.sh index c67a167..0618c6b 100755 --- a/bootstrap-salt-minion.sh +++ b/bootstrap-salt-minion.sh @@ -571,25 +571,45 @@ install_arch_post() { # # FreeBSD Install Functions # -install_freebsd_stable_deps() { +install_freebsd_9_stable_deps() { + if [ $CPU_VENDOR_ID_L = "AuthenticAMD" -a $CPU_ARCH_L = "x86_64" ]; then + local ARCH="amd64" + elif [ $CPU_VENDOR_ID_L = "GenuineIntel" -a $CPU_ARCH_L = "x86_64" ]; then + local ARCH="x86:64" + elif [ $CPU_VENDOR_ID_L = "GenuineIntel" -a $CPU_ARCH_L = "i386" ]; then + local ARCH="i386" + elif [ $CPU_VENDOR_ID_L = "GenuineIntel" -a $CPU_ARCH_L = "i686" ]; then + local ARCH="x86:32" + fi + portsnap fetch extract update cd /usr/ports/ports-mgmt/pkg make install clean cd /usr/local/sbin/pkg2ng - echo 'PACKAGESITE: http://pkgbeta.freebsd.org/freebsd-9-amd64/latest' > /usr/local/etc/pkg.conf + echo 'PACKAGESITE: http://pkgbeta.freebsd.org/freebsd-9-${ARCH}/latest' > /usr/local/etc/pkg.conf } install_freebsd_git_deps() { + if [ $CPU_VENDOR_ID_L = "AuthenticAMD" -a $CPU_ARCH_L = "x86_64" ]; then + local ARCH="amd64" + elif [ $CPU_VENDOR_ID_L = "GenuineIntel" -a $CPU_ARCH_L = "x86_64" ]; then + local ARCH="x86:64" + elif [ $CPU_VENDOR_ID_L = "GenuineIntel" -a $CPU_ARCH_L = "i386" ]; then + local ARCH="i386" + elif [ $CPU_VENDOR_ID_L = "GenuineIntel" -a $CPU_ARCH_L = "i686" ]; then + local ARCH="x86:32" + fi + portsnap fetch extract update cd /usr/ports/ports-mgmt/pkg make install clean cd /usr/local/sbin/pkg2ng - echo 'PACKAGESITE: http://pkgbeta.freebsd.org/freebsd-9-amd64/latest' > /usr/local/etc/pkg.conf + echo 'PACKAGESITE: http://pkgbeta.freebsd.org/freebsd-9-${ARCH}/latest' > /usr/local/etc/pkg.conf } -install_freebsd_stable() { +install_freebsd_9_stable() { pkg install -y salt } @@ -604,7 +624,7 @@ install_freebsd_git() { /usr/local/bin/python setup.py install } -install_freebsd_stable_post() { +install_freebsd_9_stable_post() { salt-minion -d } @@ -616,6 +636,7 @@ install_freebsd_git_post() { # ############################################################################## + #============================================================================= # LET'S PROCEED WITH OUR INSTALLATION #=============================================================================