From 3f2c685834bddd655afad55ce95b8d3f274fe2a0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 10 Mar 2014 11:46:14 +0000 Subject: [PATCH] Add `__check_services_sysvinit` for SysV init systems. Drop bashism and use `__check_services_sysvinit` instead. --- bootstrap-salt.sh | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 83f5e8d..75dcd6d 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1313,6 +1313,32 @@ __check_services_upstart() { } # ---------- end of function __check_services_upstart ---------- +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: __check_services_sysvinit +# DESCRIPTION: Return 0 or 1 in case the service is enabled or not +# PARAMETERS: servicename +#---------------------------------------------------------------------------------------------------------------------- +__check_services_sysvinit() { + if [ $# -eq 0 ]; then + echoerror "You need to pass a service name to check!" + exit 1 + elif [ $# -ne 1 ]; then + echoerror "You need to pass a service name to check as the single argument to the function" + fi + + servicename=$1 + echodebug "Checking if service ${servicename} is enabled" + + if [ "$(chkconfig --list | grep salt-$fname | grep '[2-5]:on')" != "" ]; then + echodebug "Service ${servicename} is enabled" + return 0 + else + echodebug "Service ${servicename} is NOT enabled" + return 1 + fi +} # ---------- end of function __check_services_sysvinit ---------- + + ####################################################################################################################### # # Distribution install functions @@ -2294,20 +2320,16 @@ install_centos_testing_post() { } install_centos_check_services() { - if [ ! -f /sbin/initctl ]; then - return 0 - fi - for fname in minion master syndic; do # Skip if not meant to be installed [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue - if [ -f /sbin/initctl -a -f /etc/init/salt-$fname ]; then - __check_services_upstart salt-$fname || return 1 + if [ -f /sbin/initctl ] && [ -f /etc/init/salt-$fname ]; then + __check_services_upstart salt-$fname || return 1 elif [ -f /etc/init.d/salt-$fname ]; then - chkconfig --list | grep salt-$fname | grep -q '[2345]:on' || return 1 - fi + __check_services_sysvinit salt-$fname || return 1 + fi done return 0 }