[Initscripts-ng-commits] r217 - /trunk/www/soc2006-bootsystem/code/correct-init-order

dvictoria-guest at users.alioth.debian.org dvictoria-guest at users.alioth.debian.org
Wed Sep 20 16:30:53 UTC 2006


Author: dvictoria-guest
Date: Wed Sep 20 16:30:53 2006
New Revision: 217

URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=217
Log:
initial version of new script to correct boot order

Added:
    trunk/www/soc2006-bootsystem/code/correct-init-order   (with props)

Added: trunk/www/soc2006-bootsystem/code/correct-init-order
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/www/soc2006-bootsystem/code/correct-init-order?rev=217&op=file
==============================================================================
--- trunk/www/soc2006-bootsystem/code/correct-init-order (added)
+++ trunk/www/soc2006-bootsystem/code/correct-init-order Wed Sep 20 16:30:53 2006
@@ -1,0 +1,202 @@
+#!/usr/bin/perl
+# Copyright (C) 2006 Carlos Villegas and Petter Reinholdtsen
+# Full notice of GPL license can be found in the main 
+# project file: checkLSB.
+
+#
+# Author: Petter Reinholdtsen
+# Author: Carlos Villegas
+# Created:   2006-09-19
+# Last updated: 
+#
+# Correct init-order
+#
+# 1. Read /etc/rc?.d and the included scripts to get init-script order and
+# run-time dependency information.
+#
+# 
+# It will read the init scripts from the /etc/init.d directory by default.
+# 
+
+
+use strict;
+use warnings;
+# use Getopt::Std;
+use File::Basename;
+
+#my $initdir = "/etc/";
+my $initdir = "/home/carlos/Academia/debian";
+my $overridepath = "/home/carlos/Academia/debian/insserv/overrides";
+
+# my $debug = 0;
+# my $web = 0;
+# my %opts;
+
+# getopts('dh', \%opts);
+
+# $debug = $opts{'d'};
+# $web = $opts{'h'};
+
+my %scriptinfo; # Variable with run-time dependency information.
+
+my %rc =
+    (
+     'rcS.d' => 'S',
+     'rc2.d' => '2',
+     );
+
+readinfo();
+
+
+sub readinfo {
+	my $bootorder = 0;
+	my @dirs = ('rcS.d','rc2.d');
+	my $scriptname;
+	for my $rcdir (@dirs) {
+		chdir "$initdir/$rcdir";
+		print "$initdir/$rcdir";
+			for my $script (<*hwclock.sh>) {
+			$bootorder++;	
+			print STDOUT "\n-------------------------------------------\nLoading $initdir/$rcdir/$script\n";
+
+			if ($script =~ m/S(\d{2})(\S*)/) {
+				$scriptname = $2;
+				$scriptinfo{$scriptname}{'num_ist'}=$1;
+				print "name = $2\n";
+				print "number = $1\n";
+				}
+			print "real order = $bootorder\n";
+
+			$scriptinfo{$scriptname}{'runlevel_ist'}=$rc{$rcdir};
+			$scriptinfo{$scriptname}{'order_ist'}=$bootorder;
+			
+			my $lsbinforef = load_lsb_tags("$initdir/$rcdir/$script", 0);
+			unless (defined $lsbinforef) {
+			print STDERR "LSB header missing in $initdir/$rcdir/$script\n";
+			next;
+			    }
+			my %lsbinfo = %{$lsbinforef};
+
+			print "required-start = $lsbinfo{'required-start'}\n";
+			print "should-start = $lsbinfo{'should-start'}\n";
+			print "default-start = $lsbinfo{'default-start'}\n";
+			$scriptinfo{$scriptname}{'required'}=$lsbinfo{'required-start'};
+			$scriptinfo{$scriptname}{'should'}=$lsbinfo{'should-start'};
+			$scriptinfo{$scriptname}{'default_rl'}=$lsbinfo{'default-start'};
+			
+
+
+
+			
+				}
+			}
+		}
+		
+
+sub load_lsb_tags {
+    my ($initfile, $useoverrides) = @_;
+    print STDERR "Loading $initfile (load_lsb_tags)\n";
+    ### BEGIN INIT INFO
+    # Provides:          xdebconfigurator
+    # Required-Start:    $syslog
+    # Required-Stop:     $syslog
+    # Default-Start:     2 3 4 5
+    # Default-Stop:      1 6
+    # Short-Description: Genererate xfree86 configuration at boot time
+    # Description:       Preseed X configuration and use dexconf to
+    #                    genereate a new configuration file.
+    ### END INIT INFO
+    unless (open(FILE, "<$initfile")) {
+        warn "error: Unable to read $initfile";
+	return;
+    }
+    
+    my $found = 0;
+    my ($provides, $requiredstart, $requiredstop, $shouldstart, $shouldstop, $defaultstart, $defaultstop, $shortdescription, $description);
+    while (<FILE>) {
+	chomp;
+	$found = 1 if (m/\#\#\# BEGIN INIT INFO/);
+	next unless $found;
+	last if (m/\#\#\# END INIT INFO/);
+
+	if (m/^\# provides:/i){
+		$provides=$1 if (m/^\# provides:\s+(\S*.*\S+)\s*$/i);
+		$provides="" unless ($provides);
+		}
+
+	if (m/^\# required-start:/i){
+		$requiredstart=$1 if (m/^\# required-start:\s+(\S*.*\S+)\s*$/i);
+		$requiredstart="" unless ($requiredstart);
+		}
+
+	if (m/^\# required-stop:/i){
+		$requiredstop=$1 if (m/^\# required-stop:\s+(\S*.*\S+)\s*$/i);
+		$requiredstop="" unless ($requiredstop);
+		}
+
+	if (m/^\# should-start:/i){
+		$shouldstart=$1 if (m/^\# should-start:\s+(\S*.*\S+)\s*$/i);
+		$shouldstart="" unless ($shouldstart);
+		}
+
+	if (m/^\# should-stop:/i){
+		$shouldstop=$1 if (m/^\# should-stop:\s+(\S*.*\S+)\s*$/i);
+		$shouldstop="" unless ($shouldstop);
+		}
+
+	if (m/^\# default-start:/i){
+		$defaultstart=$1 if (m/^\# default-start:\s+(\S*.*\S+)\s*$/i);
+		$defaultstart="" unless (defined $defaultstart);
+		}
+
+	if (m/^\# default-stop:/i){
+		$defaultstop=$1 if (m/^\# default-stop:\s+(\S*.*\S+)+\s*$/i);
+		$defaultstop="" unless (defined $defaultstop);
+		}
+		
+	if (m/^\# short-description:/i){
+		$shortdescription=$1 if (m/^\# short-description:\s+(\S*.*\S+)\s*$/i);
+		$shortdescription="" unless ($shortdescription);
+		}
+
+	if (m/^\# description:/i){
+		$description=$1 if (m/^\# description:\s+(\S*.*\S+)\s*$/i);
+		$description="" unless ($description);
+		}
+
+
+#	$provides = $1      if (m/^\# provides:\s+(\S*.*\S+)\s*$/i);
+#	$requiredstart = $1 if (m/^\# required-start:\s+(\S*.*\S+)\s*$/i);
+#	$requiredstop = $1  if (m/^\# required-stop:\s+(\S*.*\S+)\s*$/i);
+#	$shouldstart = $1   if (m/^\# should-start:\s+(\S*.*\S+)\s*$/i);
+#	$shouldstop = $1    if (m/^\# should-stop:\s+(\S*.*\S+)\s*$/i);
+#	$defaultstart=$1    if (m/^\# default-start:\s+(\S*.*\S+)\s*$/i);
+
+    }
+    close(FILE);
+	# Try override file
+    $initfile = readlink($initfile) if (-l $initfile);
+    $initfile = $1 if $initfile =~ m/S\d{2}(.*)$/;
+    my $basename = basename($initfile);
+
+    if (!$found) {
+	if (-f "$overridepath/$basename") {
+	    print STDERR "Override $overridepath/$basename\n";
+	    return load_lsb_tags("$overridepath/$basename", $useoverrides);
+	}
+    }
+    return undef unless ($found);
+    return undef unless ($found);
+
+	print "provides $provides (inside load_lsb_tags)\n";
+    return {
+	    'provides'       => $provides,
+	    'required-start' => $requiredstart,
+	    'required-stop'  => $requiredstop,
+	    'should-start'   => $shouldstart,
+	    'should-stop'    => $shouldstop,
+	    'default-start'  => $defaultstart,
+	    'file'           => $initfile,
+
+	};
+}		

Propchange: trunk/www/soc2006-bootsystem/code/correct-init-order
------------------------------------------------------------------------------
    svn:executable = *




More information about the Initscripts-ng-commits mailing list