[Pkg-sysvinit-devel] [PATCH 1/4] update-rc.d: add -d <path> option
Kel Modderman
kel at otaku42.de
Thu Sep 18 08:49:34 UTC 2008
Add a -d <path> command line option so that runlevel links can be manipulated
in a test suite.
---
--- a/debian/sysv-rc/sbin/update-rc.d
+++ b/debian/sysv-rc/sbin/update-rc.d
@@ -6,8 +6,9 @@
use strict;
use warnings;
-my $initd = "/etc/init.d";
-my $etcd = "/etc/rc";
+my $dir = "";
+my $initd = "etc/init.d";
+my $etcd = "etc/rc";
my $notreally = 0;
# Print usage message and die.
@@ -15,11 +16,12 @@
sub usage {
print STDERR "update-rc.d: error: @_\n" if ($#_ >= 0);
print STDERR <<EOF;
-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] [...] .
+usage: update-rc.d [-d <path>] [-n] [-f] <basename> remove
+ update-rc.d [-d <path>] [-n] <basename> defaults [NN | SS KK]
+ update-rc.d [-d <path>] [-n] <basename> start|stop NN runlvl [runlvl] [...] .
-n: not really
-f: force
+ -d: path to alternate /
EOF
exit (1);
}
@@ -31,6 +33,7 @@
shift @ARGV;
if (/^-n$/) { $notreally++; next }
if (/^-f$/) { $force++; next }
+ if (/^-d$/) { $dir = shift @ARGV; next }
if (/^-h|--help$/) { &usage; }
&usage("unknown option");
}
@@ -38,6 +41,15 @@
# Action.
&usage() if ($#ARGV < 1);
+
+$initd = join('/', $dir, $initd);
+$etcd = join('/', $dir, $etcd);
+
+if (not -d $initd) {
+ print STDERR "update-rc.d: directory does not exist '$initd'\n";
+ exit (1)
+}
+
my $bn = shift @ARGV;
unless ($bn =~ m/[a-zA-Z0-9+.-]+/) {
--- a/debian/sysv-rc/man8/update-rc.d.8
+++ b/debian/sysv-rc/man8/update-rc.d.8
@@ -5,16 +5,19 @@
update\-rc.d \- install and remove System-V style init script links
.SH SYNOPSIS
.B update\-rc.d
+.RI [ -d " path " ]
.RI [ -n ]
.RI [ -f ]
.IB name " remove"
.HP
.B update-rc.d
+.RI [ -d " path " ]
.RI [ -n ]
.IB name " defaults"
.RI [ NN " | " SS " " KK ]
.HP
.B update-rc.d
+.RI [ -d " path " ]
.RI [ -n ]
.I name
.BR start | stop
@@ -200,6 +203,11 @@
.SH OPTIONS
.TP
+.I -d path
+Path to alternative /, actions are performed on initscripts and
+runlevel directories relative to
+.BI <path> "."
+.TP
.I -n
Don't do anything, just show what we would do.
.TP
---
More information about the Pkg-sysvinit-devel
mailing list