Add __check_services_sysvinit for SysV init systems.

Drop bashism and use `__check_services_sysvinit` instead.
This commit is contained in:
Pedro Algarvio 2014-03-10 11:46:14 +00:00
parent d89671dd77
commit 3f2c685834

View file

@ -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
}