From 6788c02dcfb91f5294d88c2e9ad671e5967427e0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 10 Mar 2014 12:11:20 +0000 Subject: [PATCH] Add debian based distro specific SysV init check --- bootstrap-salt.sh | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index e2e1671..e1f320f 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1339,6 +1339,32 @@ __check_services_sysvinit() { } # ---------- end of function __check_services_sysvinit ---------- +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: __check_services_debian +# DESCRIPTION: Return 0 or 1 in case the service is enabled or not +# PARAMETERS: servicename +#---------------------------------------------------------------------------------------------------------------------- +__check_services_debian() { + 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 [ "$(service --status-all 2>1 | grep ${servicename} | grep '\[ + \]')" != "" ]; then + echodebug "Service ${servicename} is enabled" + return 0 + else + echodebug "Service ${servicename} is NOT enabled" + return 1 + fi +} # ---------- end of function __check_services_debian ---------- + + ####################################################################################################################### # # Distribution install functions @@ -1636,7 +1662,7 @@ install_ubuntu_check_services() { 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 - __check_services_sysvinit salt-$fname || return 1 + __check_services_debian salt-$fname || return 1 fi done return 0 @@ -1999,6 +2025,17 @@ install_debian_restart_daemons() { /etc/init.d/salt-$fname start done } + +install_debian_check_services() { + 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 + __check_services_debian salt-$fname || return 1 + done + return 0 +} # # Ended Debian Install Functions #