[Initscripts-ng-commits] r967 - in /trunk/src/insserv/debian: dirs update-rc.d-insserv

pere at users.alioth.debian.org pere at users.alioth.debian.org
Thu Aug 27 20:53:05 UTC 2009


Author: pere
Date: Thu Aug 27 20:53:05 2009
New Revision: 967

URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=967
Log:
Update update-rc.d-insserv based on the new one in sysvinit svn.

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

Modified: trunk/src/insserv/debian/dirs
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/dirs?rev=967&op=diff
==============================================================================
--- trunk/src/insserv/debian/dirs (original)
+++ trunk/src/insserv/debian/dirs Thu Aug 27 20:53:05 2009
@@ -3,3 +3,4 @@
 etc/insserv/overrides
 usr/sbin
 usr/share/insserv/overrides
+var/lib/update-rc.d

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=967&op=diff
==============================================================================
--- trunk/src/insserv/debian/update-rc.d-insserv (original)
+++ trunk/src/insserv/debian/update-rc.d-insserv Thu Aug 27 20:53:05 2009
@@ -27,17 +27,20 @@
 	exit (1);
 }
 
-# Dependency based boot sequencing is active.  The flag file should
-# probably be considered obsolete and dropped in Squeeze+1 or +2, and
-# the default behaviour be changed to assume the flag exist on all
-# systems.
-if ( -f "/var/lib/insserv/using-insserv" ) {
+# Dependency based boot sequencing is the default, but upgraded
+# systems might keep the legacy ordering until the sysadm choose to
+# migrate to the new ordering method.  sysv-rc version 2.87dsf-2 will
+# remove /var/lib/insserv/using-insserv and this divert, thus transfering
+the responsibility for dependency based update-rc.d to sysv-rc.
+if ( -f "/var/lib/insserv/using-insserv" && ! -f "/etc/init.d/.legacy-bootordering" ) {
     info("using dependency based boot sequencing");
     exit insserv_updatercd(@ARGV);
 }
 
 # Check out options.
 my $force;
+
+my @orig_argv = @ARGV;
 
 while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) {
 	shift @ARGV;
@@ -47,6 +50,15 @@
 	&usage("unknown option");
 }
 
+sub save_last_action {
+    my ($script, @arguments) = @_;
+    my $archive = "/var/lib/update-rc.d";
+    open(FILE, ">", "$archive/${script}.new") || die;
+    print FILE join(" ","update-rc.d", at arguments), "\n";
+    close(FILE);
+    rename "$archive/${script}.new", "$archive/${script}";
+}
+
 # Action.
 
 &usage() if ($#ARGV < 1);
@@ -74,10 +86,10 @@
 my @stoplinks;
 
 $_ = $ARGV[0];
-if    (/^remove$/)       { &checklinks ("remove"); }
-elsif (/^defaults$/)     { &defaults (@ARGV); &makelinks; }
-elsif (/^(start|stop)$/) { &startstop (@ARGV); &makelinks; }
-elsif (/^(dis|en)able$/) { &toggle (@ARGV); &makelinks; }
+if    (/^remove$/)       { &checklinks ("remove"); save_last_action($bn, @orig_argv); }
+elsif (/^defaults$/)     { &defaults (@ARGV); &makelinks; save_last_action($bn, @orig_argv); }
+elsif (/^(start|stop)$/) { &startstop (@ARGV); &makelinks; save_last_action($bn, @orig_argv); }
+elsif (/^(dis|en)able$/) { &toggle (@ARGV); &makelinks; save_last_action($bn, @orig_argv); }
 else                     { &usage; }
 
 exit (0);
@@ -160,8 +172,8 @@
     open(INIT, "<$initdscript") || die "error: unable to read $initdscript";
     while (<INIT>) {
         chomp;
-        $lsbinfo{'found'} = 1 if (m/^\#\#\# BEGIN INIT INFO$/);
-        last if (m/\#\#\# END INIT INFO$/);
+        $lsbinfo{'found'} = 1 if (m/^\#\#\# BEGIN INIT INFO\s*$/);
+        last if (m/\#\#\# END INIT INFO\s*$/);
         if (m/^\# ($lsbheaders):\s*(\S?.*)$/i) {
     	$lsbinfo{lc($1)} = $2;
         }
@@ -317,7 +329,7 @@
 
     if (&checklinks) {
 	print " System start/stop links for $initd/$bn already exist.\n";
-	exit (0);
+	return 0;
     }
     print " Adding system startup for $initd/$bn ...\n";
 
@@ -347,6 +359,8 @@
     my $action;
     my $notreally = 0;
 
+    my @orig_argv = @args;
+
     while($#args >= 0 && ($_ = $args[0]) =~ /^-/) {
         shift @args;
         if (/^-n$/) { push(@opts, $_); $notreally++; next }
@@ -361,11 +375,19 @@
     $action = shift @args;
     if ("remove" eq $action) {
         if ( -f "/etc/init.d/$scriptname" ) {
-            exec "insserv", @opts, "-r", $scriptname;
+            my $rc = system "insserv", @opts, "-r", $scriptname;
+            if (0 == $rc && !$notreally) {
+                save_last_action($scriptname, @orig_argv);
+            }
+            exit $rc;
         } else {
             # insserv removes all dangling symlinks, no need to tell it
             # what to look for.
-            exec "insserv", @opts;
+            my $rc = system "insserv", @opts;
+            if (0 == $rc && !$notreally) {
+                save_last_action($scriptname, @orig_argv);
+            }
+            exit $rc;
         }
     } elsif ("defaults" eq $action || "start" eq $action ||
              "stop" eq $action) {
@@ -378,14 +400,22 @@
             info("\`$action @args' overridden by LSB info of $scriptname");
         }
         if ( -f "/etc/init.d/$scriptname" ) {
-            exec "insserv", @opts, $scriptname;
+            my $rc = system "insserv", @opts, $scriptname;
+            if (0 == $rc && !$notreally) {
+                save_last_action($scriptname, @orig_argv);
+            }
+            exit $rc;
         } else {
             error("initscript does not exist: /etc/init.d/$scriptname");
         }
     } elsif ("disable" eq $action || "enable" eq $action) {
         insserv_toggle($action, $scriptname, @args);
         # Call insserv to resequence modified links
-        exec "insserv", @opts, $scriptname;
+        my $rc = system "insserv", @opts, $scriptname;
+        if (0 == $rc && !$notreally) {
+            save_last_action($scriptname, @orig_argv);
+        }
+        exit $rc;
     } else {
         usage();
     }




More information about the Initscripts-ng-commits mailing list