From 5238ad5a0c4a9e1c8cd036f5de4055e39bd71297 Mon Sep 17 00:00:00 2001 From: Manuel Traut Date: Fri, 29 Apr 2011 09:09:27 +0200 Subject: added debootstrap stuff Signed-off-by: Manuel Traut --- beagle/debian-rfs/usr/share/sysv-rc/saveconfig | 94 ++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 beagle/debian-rfs/usr/share/sysv-rc/saveconfig (limited to 'beagle/debian-rfs/usr/share/sysv-rc/saveconfig') diff --git a/beagle/debian-rfs/usr/share/sysv-rc/saveconfig b/beagle/debian-rfs/usr/share/sysv-rc/saveconfig new file mode 100755 index 0000000..f939935 --- /dev/null +++ b/beagle/debian-rfs/usr/share/sysv-rc/saveconfig @@ -0,0 +1,94 @@ +#! /usr/bin/perl +# +# saveconfig +# +# Print out the configuration of the current /etc/rc?.d +# symlink setup, in a format compatible to the +# "update-rc.d" command line. +# +# Author: Miquel van Smoorenburg +# Adjusted by Petter Reinholdtsen +# + +sub usage { + print STDERR "error: ", @_, "\n" if @_; + print STDERR <] + -s save each scripts setting in directory + -h show usage inforation +EOF +} + +my $archivedir = ""; + +while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) { + shift @ARGV; + if (/^-s$/) { $archivedir = shift; usage("Missing -s argument"), exit 1 unless $archivedir; next } + if (/^-h|--help$/) { &usage; } + &usage("unknown option"); +} + +chdir "/etc/init.d"; + +sub scan { + my $dir = shift; + local *DD; + my $f; + opendir DD, $dir; + foreach $f (readdir DD) { + next if ($f =~ m/^\./); + push @{$dir{$dir}}, $f; + } + closedir DD; +} + +foreach my $d (qw(S 0 1 2 3 4 5 6 7 8 9)) { + scan("/etc/rc$d.d"); +} +scan("/etc/init.d"); + +foreach my $s (@{$dir{"/etc/init.d"}}) { + my %start; + my %stop; + my $start = 0; + my $stop = 0; + foreach my $l (qw(S 0 1 2 3 4 5 6)) { + #print "L: $l\n"; + foreach my $f (@{$dir{"/etc/rc$l.d"}}) { + #print "F: $f\n"; + if ($f =~ m#^S(\d+)$s$#) { + $start{$1} .= "$l "; + $start = 1; + } + if ($f =~ m#^K(\d+)$s$#) { + $stop{$1} .= "$l "; + $stop = 1; + } + } + } + my $entry; + if ($start || $stop) { + $entry = "update-rc.d $s "; + if ($start > 0) { + foreach my $x (sort keys %start) { + $entry .= "start $x " . $start{$x} . ". "; + } + } + if ($stop > 0) { + foreach my $x (sort keys %stop) { + $entry .= "stop $x " . $stop{$x} . ". "; + } + } + $entry .= "\n"; + if ($archivedir) { + my $file = "$archivedir/$s"; + open(FILE, ">", "${file}.new") || + die "Unable to write to $file"; + print FILE $entry; + close(FILE); + rename "${file}.new", "$file"; + } else { + print $entry; + } + } +} -- cgit v1.2.3