[Pkg-systemd-maintainers] Bug#705254: Provide "is-enabled" command for update-rc.d

Michael Biebl biebl at debian.org
Fri Apr 12 21:27:18 BST 2013


A rough idea how this check could look like:
1/ grep for Default-Start and Default-Stop in the LSB header
2/ To check if a service is enabled:
   for i in Default-Start: check if /etc/rc$i.d/S??$service
   for i in Default-Stop: check if /etc/rc$i.d/K??$service
if all of those checks are true, is-enabled returns true
3/ To check if a service is disabled:
   for i in Default-Start: check if exists /etc/rc$i.d/K??$service
   for i in Default-Stop: check if  /etc/rc$i.d/K??$service
if all of those checks are true, is-enabled returns false

otherwise return unknown. I'm not quite sure yet how to map that to
return codes, i.e. if we treat unknown as enabled or disabled. Probably
the latter.

Roger, do you know of a better idea to implement this check? Does that
check work correctly for rcS services?

A few examples:

a/ typical multi-user service: rsyslog
root at pluto:~# grep -E "Default-Start|Default-Stop" /etc/init.d/rsyslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6

root at pluto:~# ls /etc/rc?.d/???rsyslog
/etc/rc0.d/K04rsyslog  /etc/rc1.d/K04rsyslog  /etc/rc2.d/S01rsyslog
/etc/rc3.d/S01rsyslog  /etc/rc4.d/S01rsyslog  /etc/rc5.d/S01rsyslog
/etc/rc6.d/K04rsyslog

root at pluto:~# update-rc.d rsyslog disable
update-rc.d: using dependency based boot sequencing
insserv: warning: current start runlevel(s) (empty) of script `rsyslog'
overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script
`rsyslog' overrides LSB defaults (0 1 6).

root at pluto:~# ls /etc/rc?.d/???rsyslog
/etc/rc0.d/K04rsyslog  /etc/rc1.d/K04rsyslog  /etc/rc2.d/K04rsyslog
/etc/rc3.d/K04rsyslog  /etc/rc4.d/K04rsyslog  /etc/rc5.d/K04rsyslog
/etc/rc6.d/K04rsyslog

b/ rcS-type service: hdparm
root at pluto:~# grep -E "Default-Start|Default-Stop" /etc/init.d/hdparm
# Default-Start:     S
# Default-Stop:

root at pluto:~# ls /etc/rc?.d/???hdparm
/etc/rcS.d/S05hdparm

root at pluto:~# update-rc.d hdparm disable
update-rc.d: using dependency based boot sequencing
insserv: warning: current start runlevel(s) (empty) of script `hdparm'
overrides LSB defaults (S).
insserv: warning: current stop runlevel(s) (S) of script `hdparm'
overrides LSB defaults (empty).

root at pluto:~# ls /etc/rc?.d/???hdparm
/etc/rcS.d/K05hdparm



Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20130412/0cd5c972/attachment-0001.sig>


More information about the Pkg-systemd-maintainers mailing list