[Pkg-sysvinit-commits] r1318 - in sysvinit/trunk/debian: . sysv-rc/man8 sysv-rc/sbin
kelmo-guest at alioth.debian.org
kelmo-guest at alioth.debian.org
Mon Feb 2 14:11:16 UTC 2009
Author: kelmo-guest
Date: 2009-02-02 14:11:15 +0000 (Mon, 02 Feb 2009)
New Revision: 1318
Modified:
sysvinit/trunk/debian/changelog
sysvinit/trunk/debian/sysv-rc/man8/update-rc.d.8
sysvinit/trunk/debian/sysv-rc/sbin/update-rc.d
Log:
Add interface for disabling system init script start links with
update-rc.d, and enabling them again. Closes: #67095
Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog 2009-02-02 13:53:18 UTC (rev 1317)
+++ sysvinit/trunk/debian/changelog 2009-02-02 14:11:15 UTC (rev 1318)
@@ -29,8 +29,10 @@
* Modify debian/sysv-rc/sbin/update-rc.d so defaults and startstop
functions accept local arguments instead of using (and modifying)
the global script argument array.
+ * Add interface for disabling system init script start links with
+ update-rc.d, and enabling them again. Closes: #67095
- -- Kel Modderman <kel at otaku42.de> Mon, 02 Feb 2009 23:52:52 +1000
+ -- Kel Modderman <kel at otaku42.de> Tue, 03 Feb 2009 00:09:28 +1000
sysvinit (2.86.ds1-61) unstable; urgency=low
Modified: sysvinit/trunk/debian/sysv-rc/man8/update-rc.d.8
===================================================================
--- sysvinit/trunk/debian/sysv-rc/man8/update-rc.d.8 2009-02-02 13:53:18 UTC (rev 1317)
+++ sysvinit/trunk/debian/sysv-rc/man8/update-rc.d.8 2009-02-02 14:11:15 UTC (rev 1318)
@@ -23,6 +23,12 @@
.BR start | stop
.IR "NN runlevel" " [" runlevel "]..."
.BR . " ..."
+.HP
+.B update-rc.d
+.RI [ -d " path " ]
+.RI [ -n ]
+.IB name " disable|enable "
+.RI [ " S|2|3|4|5 " ]
.SH DESCRIPTION
.B update-rc.d
updates the System V style init script links
@@ -48,19 +54,7 @@
.BR init (8)
and the
.IR "Debian Policy Manual" .
-.P
-Please note that this program was designed for use
-in package maintainer scripts and, accordingly,
-has only the very limited functionality required by such scripts.
-System administrators are not encouraged to use
-.BR update-rc.d
-to manage runlevels.
-They should edit the links directly or
-use runlevel editors such as
-.B sysv-rc-conf
-and
-.B bum
-instead.
+
.SH INSTALLING INIT SCRIPT LINKS
When run with either the
.BR defaults ", " start ", or " stop
@@ -197,6 +191,30 @@
directories that are not symbolic links to the script
.BI /etc/init.d/ name
will be left untouched.
+.SH DISABLING INIT SCRIPT START LINKS
+When run with the
+.BR disable " [ " S|2|3|4|5 " ] "
+options,
+.B update-rc.d
+modifies existing runlevel links for the script
+.BR /etc/init.d/ \fIname\fR
+by renaming start links to stop links with a sequence number equal
+to the difference of 100 minus the original sequence number.
+.P
+When run with the
+.BR enable " [ " S|2|3|4|5 " ] "
+options,
+.B update-rc.d
+modifies existing runlevel links for the script
+.BR /etc/init.d/ \fIname\fR
+by renaming stop links to start links with a sequence number equal
+to the positive difference of current sequence number minus 100, thus
+returning to the original sequence number that the script had been
+installed with before disabling it.
+.P
+Both of these options only operate on start runlevel links of S, 2,
+3, 4 or 5. If no start runlevel is specified after the disable or enable
+keywords, the script will attempt to modify links in all start runlevels.
.SH OPTIONS
.TP
Modified: sysvinit/trunk/debian/sysv-rc/sbin/update-rc.d
===================================================================
--- sysvinit/trunk/debian/sysv-rc/sbin/update-rc.d 2009-02-02 13:53:18 UTC (rev 1317)
+++ sysvinit/trunk/debian/sysv-rc/sbin/update-rc.d 2009-02-02 14:11:15 UTC (rev 1318)
@@ -18,6 +18,7 @@
usage: update-rc.d [-n] [-f] <basename> remove
update-rc.d [-n] <basename> defaults [NN | SS KK]
update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .
+ update-rc.d [-n] <basename> disable|enable [S|2|3|4|5]
-n: not really
-f: force
EOF
@@ -65,6 +66,7 @@
if (/^remove$/) { &checklinks ("remove"); }
elsif (/^defaults$/) { &defaults (@ARGV); &makelinks; }
elsif (/^(start|stop)$/) { &startstop (@ARGV); &makelinks; }
+elsif (/^(dis|en)able$/) { &toggle (@ARGV); &makelinks; }
else { &usage; }
exit (0);
@@ -156,6 +158,70 @@
}
+# Process the arguments after the "enable" or "disable" keyword.
+
+sub toggle {
+ my @argv = @_;
+ my ($action, %lvls, @start, @stop, @xstartlinks);
+
+ if (!&checklinks) {
+ print " System startup links for $initd/$bn do not exist.\n";
+ exit (0);
+ }
+
+ $action = $argv[0];
+ if ($#argv > 1) {
+ while ($#argv > 0 && shift @argv) {
+ if ($argv[0] =~ /^[S2-5]$/) {
+ $lvls{$argv[0]}++;
+ } else {
+ &usage ("expected 'S' '2' '3' '4' or '5'");
+ }
+ }
+ } else {
+ $lvls{$_}++ for ('S', '2', '3', '4', '5');
+ }
+
+ push(@start, glob($etcd . '[2-5S].d/[KS][0-9][0-9]' . $bn));
+
+ foreach (@start) {
+ my $islink = &is_link (undef, $_, $bn);
+ next if !$islink;
+
+ next unless my ($lvl, $sk, $seq) = m/^$etcd([2-5S])\.d\/([SK])([0-9]{2})$bn$/;
+ $startlinks[$lvl] = $sk . $seq;
+
+ if ($action eq 'disable' and $sk eq 'S' and $lvls{$lvl}) {
+ $xstartlinks[$lvl] = 'K' . sprintf "%02d", (100 - $seq);
+ } elsif ($action eq 'enable' and $sk eq 'K' and $lvls{$lvl}) {
+ $xstartlinks[$lvl] = 'S' . sprintf "%02d", -($seq - 100);
+ } else {
+ $xstartlinks[$lvl] = $sk . $seq;
+ }
+ }
+
+ push(@stop, glob($etcd . '[016].d/[KS][0-9][0-9]' . $bn));
+
+ foreach (@stop) {
+ my $islink = &is_link (undef, $_, $bn);
+ next if !$islink;
+
+ next unless my ($lvl, $sk, $seq) = m/^$etcd([016])\.d\/([SK])([0-9]{2})$bn$/;
+ $stoplinks[$lvl] = $sk . $seq;
+ }
+
+ if ($action eq 'disable') {
+ print " Disabling system startup links for $initd/$bn ...\n";
+ } elsif ($action eq 'enable') {
+ print " Enabling system startup links for $initd/$bn ...\n";
+ }
+
+ &checklinks ("remove");
+ @startlinks = @xstartlinks;
+
+ 1;
+}
+
# Process the arguments after the "defaults" keyword.
sub defaults {
More information about the Pkg-sysvinit-commits
mailing list