From 6b3a4110cc0ff21631ad601d994f4c72fb5219c2 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Tue, 15 Jan 2013 12:14:05 -0600 Subject: 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 --- sh/runscript.sh.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in index 21ff39a..237186a 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 \ -- cgit v1.2.3