Re: init.d scripts: LSB and Debian policy
Tobias Burnus wrote:
> [DP] "force-reload -- cause the configuration to be reloaded if the
> service supports this, otherwise restart the service."
> [LSB 1.9-pre snapshot]
> "force-reload -- cause the configuration to be reloaded if the
> service supports this, otherwise restart the service
> if it is running"
> This solves the reload/restart ambiguity if the service is not running.
FYI: There is a wish (#203239) for policy to endorse a name for the
action of restarting a service iff it is running. Names proposed
have been "restart-if-running" and "restart" with second argument
"running".
It is interesting that DP and LSB differ in what they require of
force-reload. The LSB requirement makes more sense whereas the DP
requirement is easier to implement in a distro whose initscripts
fail to implement restart-if-running. In present Debian initscripts
force-reload is either synonymous with reload or synonymous with
restart. If an initscript already has restart-if-running then
implementing LSB-style force-reload is easy: in each case it is
either synonymous with reload or synonymous with restart-if-running.
> The exit status codes in the DP are a bit unclear. Especially regarding
> . running "start" on a service already running
> . running "stop" on a service already stopped or not running
The initscript should do nothing and exit with status 0 in these
cases.
> . running "reload" on a service already stopped or not running
> The LSB says that these are successful while the DP says nothing about
> this.
You misquote the LSB (1.3). It says that running "restart" on a service
already stopped or not running should be counted as a success.
> Some use Debian init.d scripts use start-stop-daemon with --nodook,
"--oknodo"
> others (a bit more) without.
> Adding to the DP that they should/shall return a "0" might make sense.
Trying to reload a service that is not running should result in
a nonzero status, I believe.
> (The [DP] test -f program-executed-later-in-script || exit 0
> [LSB] test -f program-executed-later-in-file || exit 5
> difference it also unfortunate (0=success, 5=program is not installed))
Becoming LSB compliant on this point wouldn't be trivially easy.
A lot of scripts run with "set -e" would have to be changed from
doing
/etc/init.d/foo action
which would fail on the nonzero exit status, to doing
if /etc/init.d/foo action ; then
case $? in
...
esac
fi
Making this change would take a long time to accomplish. Sounds
like something that should happen post-sarge.
--
Thomas Hood
Reply to: