[Initscripts-ng-commits] r137 - /trunk/src/insserv/debian/update-rc.d-insserv

pere at users.alioth.debian.org pere at users.alioth.debian.org
Thu Sep 7 12:52:38 UTC 2006


Author: pere
Date: Thu Sep  7 12:52:38 2006
New Revision: 137

URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=137
Log:
Get update-rc.d working.

Modified:
    trunk/src/insserv/debian/update-rc.d-insserv

Modified: trunk/src/insserv/debian/update-rc.d-insserv
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/update-rc.d-insserv?rev=137&op=diff
==============================================================================
--- trunk/src/insserv/debian/update-rc.d-insserv (original)
+++ trunk/src/insserv/debian/update-rc.d-insserv Thu Sep  7 12:52:38 2006
@@ -1,14 +1,40 @@
-#!/bin/sh
+#!/usr/bin/perl
 
-flagfile=/etc/update-rc.d-insserv
+use strict;
+use warnings;
 
-if [ -f $flagfile ] ; then
-    # XXX not implemented
-    insserv $scriptname
-else
-    echo error: Inconsistent update-rc.d configuration.  The flag file
-    echo error: $flagfile is missing,
-    echo error: but the update-rc.d divert is still in place.  Calling
-    echo error: the version from sysv-rc directly.
-    exec /usr/sbin/update-rc.d.distrib $@
-fi
+my $flagfile = "/etc/update-rc.d-insserv";
+
+if ( ! -f $flagfile ) {
+    print STDERR <<EOF;
+error: Inconsistent update-rc.d configuration.  The flag file
+error: $flagfile is missing,
+error: but the update-rc.d divert is still in place.  Calling
+error: the version from sysv-rc directly.
+EOF
+    exec "/usr/sbin/update-rc.d.distrib", at ARGV;
+} else {
+    my @opts;
+    while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) {
+	shift @ARGV;
+	if (/^-n$/) { push(@opts, "-n"); next }
+	if (/^-f$/) { push(@opts, "-f"); next }
+	if (/^-h|--help$/) { &usage; }
+	&usage("unknown option");
+    }
+    my $scriptname = $ARGV[0];
+
+    exec "insserv", @opts, "/etc/init.d/$scriptname";
+}
+
+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 | sNN kNN]
+       update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .
+		-n: not really
+		-f: force
+EOF
+	exit (1);
+}




More information about the Initscripts-ng-commits mailing list