check_service.sh: remove unusually code.
This commit is contained in:
parent
5badd41cb2
commit
b9f2e3edbb
@ -91,27 +91,15 @@ else
|
||||
LOGGING=false
|
||||
fi
|
||||
|
||||
|
||||
# Is service name given?
|
||||
#
|
||||
if [[ -n "$1" ]] ; then
|
||||
service_name=$1
|
||||
else
|
||||
fatal "$(basename $0): No Service given"
|
||||
fi
|
||||
|
||||
# - Is Service installed ?
|
||||
# -
|
||||
_check_binary="$(which ${service_name,,}d)"
|
||||
if [[ -z "$_check_binary" ]] ; then
|
||||
_check_binary="$(which ${service_name,,})"
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "$_check_binary" ]]; then
|
||||
fatal "$(basename $0): $service_name Service seems NOT to be installed"
|
||||
else
|
||||
check_binary="$_check_binary"
|
||||
check_string_ps="$check_binary"
|
||||
fi
|
||||
|
||||
|
||||
# - Systemd supported ?
|
||||
# -
|
||||
@ -152,6 +140,23 @@ if [[ -z "$SYSTEMD_SERVICE" ]] && [[ -z "$SYSV_INIT_SCRIPT" ]] ; then
|
||||
fatal "Neither an init-script nor a service file for $service_name found!"
|
||||
fi
|
||||
|
||||
# - Determin check_string_ps ..
|
||||
# -
|
||||
if [[ -n "$SYSTEMD_SERVICE" ]] ; then
|
||||
_systemd_service_file=""
|
||||
if [[ -f "/etc/systemd/system/$SYSTEMD_SERVICE" ]] ; then
|
||||
_systemd_service_file="/etc/systemd/system/$SYSTEMD_SERVICE"
|
||||
elif [[ -f "/lib/systemd/system/$SYSTEMD_SERVICE" ]] ; then
|
||||
_systemd_service_file="/etc/systemd/system/$SYSTEMD_SERVICE"
|
||||
fi
|
||||
if [[ -n "$_systemd_service_file" ]]; then
|
||||
check_string_ps="$(trim $(cat "$_systemd_service_file" | grep ExecStart | grep -o -E "ExecStart\s*=\s*[^[:space:]]+" | cut -d "=" -f2))"
|
||||
fi
|
||||
else
|
||||
check_string_ps="$(trim $(cat "$SYSV_INIT_SCRIPT" | grep DAEMON | grep -o -E "DAEMON\s*=\s*[^[:space:]]+" | cut -d "=" -f2))"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#---------------------------------------
|
||||
#-----------------------------
|
||||
@ -161,7 +166,7 @@ fi
|
||||
|
||||
if $LOGGING ; then
|
||||
echo -e "\n Check if $service_name service is running.."
|
||||
echo -e " ================================="
|
||||
echo -e " ====================================="
|
||||
fi
|
||||
if ! ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}" | grep -v grep > /dev/null ; then
|
||||
error "$service_name service seems to be down! Trying to restart service now.."
|
||||
|
Loading…
Reference in New Issue
Block a user