Re: daemon stop and start during upgrade
* Christoph Biedl [Tue, 11 Sep 2007 15:34:49 +0200]:
> Hello,
> Currently I am packaging a daemon. I used dh-make (0.43, Debian
> lenny) and did some small adjustments afterwards. Now came across two
> problems where I am not sure how they should solved properly, in other
> words: What is best practise?
> Given the following situation: The daemon was stopped manually. Now I
> want to install a new build, using "dpkg -i". This invokes (among
> other) /var/lib/dpkg/info/<daemon>.prerm which contains only a few lines
> "Automatically added by dh_installinit". They include a call of
> "invoke-rc.d <daemon> stop || exit $?",
> this is basically a wrapper for "/etc/init.d/<daemon> stop" which
> calls start-stop-daemon. This program returns non-zero since the
> daemon is not running, that value is passed back through the chain and
> finally causes a dpkg error. dpkg tries the script from the new
> package instead which fails for the same reason.
> To deal with that mess I could modify /etc/init.d/<daemon> and add the
> --oknodo to start-stop-daemon, or "|| true". If this is the best way
> to do, why does not dh-make create the init script in such a way by
> default?
> An alternative approach was to ship my own version of prerm thus
> overriding dh_installinit. Not a good idea IMHO.
> Is there a better solution?
Your init.d script should *not* exit with status non-zero if the daemon
was already stopped. You can do that either by passing --oknodo to
start-stop-daemon, or by checking by hand if the return status is 1.
*Not*, in any case, by appending "|| true", since that would hide the
case when a real errors occurs and the daemon can't be stopped.
If you wrote your init.d script from some template that advocates
returning directly the exit status of start-stop-daemon without
--oknodo, that template needs fixing.
HTH,
--
Adeodato Simó dato at net.com.org.es
Debian Developer adeodato at debian.org
Listening to: Hooverphonic - Heartbeat (Remix)
Reply to: