From: urs Date: Tue, 12 Jun 2007 18:33:05 +0000 (+0000) Subject: Fixed Parse.pm and create-sysvinit-file.pl. X-Git-Tag: DEBIAN_metainit_0_0_1~90 X-Git-Url: http://git.nomeata.de/?p=darcs-mirror-metainit.git;a=commitdiff_plain;h=5d08bc38064289963b4df314c2a1c15d21a82759;hp=c91e63a2c8e93e5cd13bf7095f854f8ed8b01661 Fixed Parse.pm and create-sysvinit-file.pl. --- diff --git a/Parse.pm b/Parse.pm index e278f04..6889e67 100644 --- a/Parse.pm +++ b/Parse.pm @@ -1,11 +1,14 @@ -package Parse +package Parse; sub parse { - my $fh = shift; + my $filename = shift; + open(FILE, "<$filename") || die "$!"; my %parsed; my $lastkey; - while (<$fh>) { + while () { + # Ignore empty lines and comments + next if /^$/ or /^#/; #last if /^$/; if (my ($key, $value) = m/^([^ ].*): (.*)/) { $parsed{$key} = $value; @@ -29,3 +32,6 @@ sub parse { return %parsed; } + +# Return a true value +1; diff --git a/create-sysvinit-file.pl b/create-sysvinit-file.pl index ba87700..d8bfde8 100644 --- a/create-sysvinit-file.pl +++ b/create-sysvinit-file.pl @@ -4,16 +4,17 @@ use Parse; +$filename = shift || die "Filename expected!\n"; # Parse the metainit in -%initparams = parse($ARGV[0]); +%initparams = Parse::parse($filename); # Print the "dynamic" part of the initskript -print << EOF +print << "EOF" #! /bin/sh ### BEGIN INIT INFO -# Provides: $initparams{Name} -# Required-Start: $initparams{Required-Start} -# Required-Stop: $initparams{Required-Stop} +# Provides: $initparams{"Name"} +# Required-Start: $initparams{"Required-Start"} +# Required-Stop: $initparams{"Required-Stop"} # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO @@ -26,12 +27,13 @@ print << EOF # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Description of the service" -NAME=$parsed{Name} -DAEMON=$parsed{Path} -DAEMON_ARGS=$parsed{Args} +NAME=$initparams{"Name"} +DAEMON=$initparams{"Path"} +DAEMON_ARGS=$initparams{"Args"} PIDFILE=/var/run/\$NAME.pid SCRIPTNAME=/etc/init.d/\$NAME EOF +; # ... and the rest of the initscript, that is identical for all # metainit-created scripts.