aboutsummaryrefslogtreecommitdiffstats
path: root/service
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2015-09-11 10:35:20 +0200
committerLukas Nykryn <lnykryn@redhat.com>2015-09-11 10:48:34 +0200
commita018641159b7d0a2938cc56baadc163e2775601e (patch)
treec9252219eeb2324de5da307780c9585c10aae8ae /service
parent6a4433a99fb086f48f66c6c07e61df9a0538085c (diff)
downloadinitscripts-a018641159b7d0a2938cc56baadc163e2775601e.tar
initscripts-a018641159b7d0a2938cc56baadc163e2775601e.tar.gz
initscripts-a018641159b7d0a2938cc56baadc163e2775601e.tar.bz2
initscripts-a018641159b7d0a2938cc56baadc163e2775601e.tar.xz
initscripts-a018641159b7d0a2938cc56baadc163e2775601e.zip
service: improve status and stop function for daemon with intscripts
When daemon abnormally dies systemd leaves it in active state. This is due to support of initscripts like network. We can guess if it is a daemon or not.
Diffstat (limited to 'service')
-rwxr-xr-xservice7
1 files changed, 7 insertions, 0 deletions
diff --git a/service b/service
index c8bf0a2b..79792fc5 100755
--- a/service
+++ b/service
@@ -71,6 +71,13 @@ while [ $# -gt 0 ]; do
done
if [ -f "${SERVICEDIR}/${SERVICE}" ]; then
+ # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes
+ # lets reap them before next start
+ if [ "${ACTION}" = "start" ] && \
+ systemctl show -p ActiveState ${SERVICE}.service | grep -q '=active$' && \
+ systemctl show -p SubState ${SERVICE}.service | grep -q '=exited$' ; then
+ /bin/systemctl stop ${SERVICE}.service
+ fi
env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS}
elif [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" -a -n "${ACTION}" ]; then
env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS}