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
This commit is contained in:
William Hubbs 2013-01-15 12:14:05 -06:00
parent 3896b9d55c
commit 6b3a4110cc

View File

@ -145,7 +145,12 @@ start()
${pidfile:+--pidfile} $pidfile \ ${pidfile:+--pidfile} $pidfile \
$_background $start_stop_daemon_args \ $_background $start_stop_daemon_args \
-- $command_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 yesno "$start_inactive"; then
if ! $_inactive; then if ! $_inactive; then
mark_service_stopped mark_service_stopped
@ -156,6 +161,12 @@ start()
stop() 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 [ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0
ebegin "Stopping ${name:-$RC_SVCNAME}" ebegin "Stopping ${name:-$RC_SVCNAME}"
start-stop-daemon --stop \ start-stop-daemon --stop \