#481348 Init.d script does not stop daemon

Package:
hpsockd
Source:
hpsockd
Description:
HP SOCKS server
Submitter:
Andriy Lesyuk
Date:
2015-01-10 09:21:05 UTC
Severity:
important
#481348#5
Date:
2008-05-15 12:42:51 UTC
From:
To:
The init.d script starts the daemon successfully but no pid file
(/var/run/hpsockd.pid) is created. Therefore the script is unable to
stop the daemon...

I solved this problem for myself by replacing "start-stop-daemon
--stop..." with "/usr/sbin/sdc stop". However, I guess, this is not good 
solution for everyone.

Thanks,
Andriy

#481348#10
Date:
2015-01-10 08:19:31 UTC
From:
To:
Dear Maintainer,

hpsockd enter daemon status by itself therefor start-stop-daemon can not create
the proper pid file, which causes the script fail to stop daemon.

Invoke start-stop-daemon with --name instead of --pidfile fix the problem.
--- debian/init.d | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/debian/init.d b/debian/init.d index 72f7e90..f0417a5 100755 --- a/debian/init.d +++ b/debian/init.d @@ -13,14 +13,24 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/hpsockd NAME=hpsockd +WORKDIR=/var/cache/$NAME DESC="HP SOCKS daemon" test -f $DAEMON || exit 0 set -e +check_hpsockd_dir() +{ + if [ ! -d $WORKDIR ]; then + mkdir -m 755 $WORKDIR + chown nobody:root $WORKDIR + fi +} + case "$1" in start) + check_hpsockd_dir if [ -f /etc/hpsockd.conf ]; then echo -n "Starting $DESC: " start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ @@ -32,8 +42,7 @@ case "$1" in ;; stop) echo -n "Stopping $DESC: " - start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ - --exec $DAEMON + start-stop-daemon --stop --quiet --name $NAME echo "$NAME." ;; reload|force-reload) @@ -42,8 +51,7 @@ case "$1" in ;; restart) echo -n "Restarting $DESC: " - start-stop-daemon --stop --quiet --pidfile \ - /var/run/$NAME.pid --exec $DAEMON + start-stop-daemon --stop --quiet --name $NAME sleep 1 start-stop-daemon --start --quiet --pidfile \ /var/run/$NAME.pid --exec $DAEMON -- 1.7.10.4