mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 09:40:21 +00:00
Add __check_services_sysvinit
for SysV init systems.
Drop bashism and use `__check_services_sysvinit` instead.
This commit is contained in:
parent
d89671dd77
commit
3f2c685834
1 changed files with 30 additions and 8 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue