[Home]

Summary:ASTERISK-13927: [patch] LSB header for init scripts
Reporter:Andrew Latham (lathama)Labels:
Date Opened:2009-04-08 15:47:05Date Closed:2010-01-11 17:53:35.000-0600
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Core/BuildSystem
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) lsb-init-info-debian.diff
Description:Add LSB headers to init scripts.

Suggestion

### BEGIN INIT INFO
# Provides:          asterisk
# Required-Start:    $network $local_fs $syslog
# Required-Stop:     $network $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Asterisk at boot time
# Description:       Asterisk a software PBX and VoIP glue.
### END INIT INFO

For all platforms.
http://wiki.debian.org/LSBInitScripts

eg.. asterisk/contrib/init.d/rc.debian.asterisk
Comments:By: Jason Parker (jparker) 2009-04-08 16:49:47

Just out of curiosity, do Red Hat-based systems support this the same way?  A lot of the init scripts I've seen for those have different syntax.  They use chkconfig, basically.

By: Andrew Latham (lathama) 2009-04-08 16:57:28

Debian Lenny is complaining about it so I am submitting it.  I want to assume it will work in other distros but I know that Debian supports this.

By: Andrew Latham (lathama) 2009-04-11 07:30:13

In DAHDI this appears to be set and work for all platforms.  See dahdi.init

I will look at the current Asterisk init scripts to see if I can submit one that covers all distros like DAHDI's.

By: Tzafrir Cohen (tzafrir) 2009-04-11 09:04:30

The standard is originally based on the comments convention from SUSE with adjustmets for RedHat.

Names of services tend to differ a bit between distributions.

It would also help if Asterisk starts after the Zaptel / DAHDI modules are loaded:

Should-Start: dahdi

By: pkempgen (pkempgen) 2009-07-25 18:30:22

There's more services to be added to Should-Start:
dahdi, zaptel, $named, $time, mysql, postgresql(?), odbc, misdn.
And since asterisk needs a mounted /usr (/usr/lib/asterisk/modules/)
it needs to depend on $remote_fs in Required-Start.

By: Digium Subversion (svnbot) 2009-11-07 11:08:20.000-0600

Repository: asterisk
Revision: 228766

U   trunk/contrib/init.d/rc.debian.asterisk

------------------------------------------------------------------------
r228766 | tzafrir | 2009-11-07 11:08:19 -0600 (Sat, 07 Nov 2009) | 4 lines

Add LSB headers to the Debian init.d script

See also issue ASTERISK-13927 .

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=228766

By: Leif Madsen (lmadsen) 2009-12-15 11:49:00.000-0600

pkempgen: since you seem to have a pretty good idea of what needs to be added here, think you'd be able to provide a patch or at least some thoughts on how to close this issue out?

By: pkempgen (pkempgen) 2009-12-19 07:12:32.000-0600

Patch (lsb-init-info-debian.diff, against trunk r.235773) attached.
Explanation:

I have moved the whole INIT INFO block further to the top since I
think that many implementations look for it in the first 25 lines or
something.

---cut---
# Provides:          asterisk
---cut---

"facilities provided by this init script." Pretty self-explanatory.

---cut---
# Required-Start:    $network $syslog $named $local_fs $remote_fs
# Required-Stop:     $network $syslog $named $local_fs $remote_fs
---cut---

"facilities which must be available during startup (resp. shutdown)
of this service"

These are standard LSB facility names.
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/facilname.html

I have added $remote_fs since Asterisk depends on files in the /usr
hierarchy and /usr might be a remote file system.
The Debian wiki says "Scripts depending on $remote_fs do not need
to depend on $local_fs." so we could remove the dependency on
$local_fs. However the LSB standard does not mention this exception
and it doesn't hurt to depend on $local_fs thus it stays.

$network means "basic networking support is available. Example: a
server program could listen on a socket."

$named means "IP name-to-address translation ... Example: if a DNS
query daemon normally provides this facility, then that daemon has
been started."

$syslog means "system logger is operational."

---cut---
# Should-Start:      dahdi misdn lcr wanrouter mysql postgresql
# Should-Stop:       dahdi misdn lcr wanrouter mysql postgresql
---cut---

"facilities which, if present, should be available during startup
(resp. shutdown) of this service. This allows for weak dependencies
which do not cause the service to fail if a facility is not
available."

Example: If (and only if) dahdi is present on the system then dahdi
should be started before asterisk. The same thing goes for other
ISDN/analog card drivers: misdn, lcr (Linux Call Router), wanpipe/
wanrouter.
I have added mysql and postgresql since asterisk might be configured
to read from or write to a database (Realtime, CDRs) and so the
database (if present) should already be running when asterisk is
started.

---cut---
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
---cut---

"which run levels should by default run the init script with a start
(stop) argument to start (stop) the services controlled by the init
script."

On Debian daemons usually start when switching to runlevels 2, 3, 4
or 5 (multiuser modes) and stop at 1 (single-user mode), 0 (halt),
6 (reboot).
http://wiki.debian.org/RunLevel
Other distributions might have slightly different conventions.
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/runlevels.html

References:
http://wiki.debian.org/LSBInitScripts
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/tocsysinit.html

Basically the same INIT INFO block could be used for all
contrib/init.d/rc.*.asterisk init scripts.
However different distros might have different conventions for
runlevels and as Tzafrir pointed out names of services (in
Should-Start/Should-Stop) differ a bit between distributions.
I guess though that starting at runlevel 2 3 4 5 and stopping at
0 1 6 should be sane and since we list only standard LSB facilities
in Required-Start/Required-Stop the same INIT INFO block should work
on all distros. Names of services listed in Should-Start/Should-Stop
might differ between distributions but since these are "weak
dependencies which do not cause the service to fail if a facility is
not available" they shouldn't do any harm.
I cannot comment on other distros though so my patch is for Debian
only.

By: Tzafrir Cohen (tzafrir) 2009-12-19 08:31:11.000-0600

Does Asterisk rely on syslog? $local_fs is needed if you want to e.g. rely on files from /usr .

Should-Start/Should-Stop lists optional dependencies, that is: if such a service exists, we'll start after it (or stop before it, respectively). So I don't see the real issue here. Most Asterisk systems don't have e.g. a PostgreSQL server, anyway. It is still listed there.

By: pkempgen (pkempgen) 2009-12-19 09:12:26.000-0600

> Does Asterisk rely on syslog?

Yes if logging to syslog is configured in logger.conf.
Well, you could argue that $syslog should be listed in Should-*
instead of Required-* but that seems to be unusal.

> $local_fs is needed if you want to e.g. rely on files from /usr .

$local_fs is needed for local file systems (e.g. /var/lib/asterisk/).
/usr might be a remote file system and since asterisk depends on
files in /usr (/usr/lib/asterisk/modules/) it needs to depend on
$remote_fs.

> Should-Start/Should-Stop lists optional dependencies, that is: if
> such a service exists, we'll start after it (or stop before it,
> respectively).

Exactly.

> So I don't see the real issue here. Most Asterisk systems don't
> have e.g. a PostgreSQL server, anyway. It is still listed there.

Yes. That's why postgresql is a weak dependency (Should-Start)
instead of a strong dependency (Required-Start).
If the system does not have postgresql, fine. ("This allows for weak
dependencies which do not cause the service to fail if a facility is
not available.")
If the system does have postgresql then postgresql should already be
running when asterisk is started because asterisk might need to load
configuration from the database (extconfig.conf).

Somehow I fail to see your point.

By: Tzafrir Cohen (tzafrir) 2009-12-19 09:23:46.000-0600

> Somehow I fail to see your point.

I fail to see where I fail to agree with you.

By: Leif Madsen (lmadsen) 2009-12-21 12:03:24.000-0600

Thanks for the contribution!

By: Digium Subversion (svnbot) 2010-01-11 17:53:33.000-0600

Repository: asterisk
Revision: 239270

U   trunk/contrib/init.d/rc.archlinux.asterisk
U   trunk/contrib/init.d/rc.debian.asterisk
U   trunk/contrib/init.d/rc.gentoo.asterisk
U   trunk/contrib/init.d/rc.mandriva.asterisk
U   trunk/contrib/init.d/rc.redhat.asterisk
U   trunk/contrib/init.d/rc.slackware.asterisk
U   trunk/contrib/init.d/rc.suse.asterisk

------------------------------------------------------------------------
r239270 | tilghman | 2010-01-11 17:53:33 -0600 (Mon, 11 Jan 2010) | 6 lines

Add LSB headers to init scripts.
(closes issue ASTERISK-13927)
Reported by: lathama
Patches:
      lsb-init-info-debian.diff uploaded by pkempgen (license 169)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=239270