diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2013-01-15 12:14:05 -0600 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2013-01-15 12:14:05 -0600 |
commit | 6b3a4110cc0ff21631ad601d994f4c72fb5219c2 (patch) | |
tree | 153d38a32c9602c48d81714a1493ec31f46ea59b /sh | |
parent | 3896b9d55ce76e41233eadb6d0ede2f8115736d3 (diff) |
runscript: fix stopping changed service issues
If an init script or service was upgraded while it was running and the
settings for the pid file, command and process name were changed, it
would not be possible to stop the old service.
Runscript now saves the values it used to start the service and re-uses
them to stop the service.
Reported-by: flameeyes@gentoo.org
X-Gentoo-Bug: 434032
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=434032
Diffstat (limited to 'sh')
-rw-r--r-- | sh/runscript.sh.in | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in index 21ff39a3..237186ae 100644 --- a/sh/runscript.sh.in +++ b/sh/runscript.sh.in @@ -145,7 +145,12 @@ start() ${pidfile:+--pidfile} $pidfile \ $_background $start_stop_daemon_args \ -- $command_args - eend $? "Failed to start $RC_SVCNAME" && return 0 + if eend $? "Failed to start $RC_SVCNAME"; then + service_set_value "command" "${command}" + [ -n "${pidfile}" ] && service_set_value "pidfile" "${pidfile}" + [ -n "${procname}" ] && service_set_value "procname" "${procname}" + return 0 + fi if yesno "$start_inactive"; then if ! $_inactive; then mark_service_stopped @@ -156,6 +161,12 @@ start() stop() { + local startcommand="$(rc_service_get "command")" + local startpidfile="$(rc_service_get "pidfile")" + local startprocname="$(rc_service_get "procname")" + command="${startcommand:-$command}" + pidfile="${startpidfile:-$pidfile}" + procname="${startprocname:-$procname}" [ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0 ebegin "Stopping ${name:-$RC_SVCNAME}" start-stop-daemon --stop \ |