projects
/
darcs-mirror-metainit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c91e63a
)
Fixed Parse.pm and create-sysvinit-file.pl.
author
urs
<urs@nerd2nerd.org>
Tue, 12 Jun 2007 18:33:05 +0000
(18:33 +0000)
committer
urs
<urs@nerd2nerd.org>
Tue, 12 Jun 2007 18:33:05 +0000
(18:33 +0000)
Parse.pm
patch
|
blob
|
history
create-sysvinit-file.pl
patch
|
blob
|
history
diff --git
a/Parse.pm
b/Parse.pm
index
e278f04
..
6889e67
100644
(file)
--- a/
Parse.pm
+++ b/
Parse.pm
@@
-1,11
+1,14
@@
-package Parse
+package Parse
;
sub parse {
sub parse {
- my $fh = shift;
+ my $filename = shift;
+ open(FILE, "<$filename") || die "$!";
my %parsed;
my $lastkey;
my %parsed;
my $lastkey;
- while (<$fh>) {
+ while (<FILE>) {
+ # Ignore empty lines and comments
+ next if /^$/ or /^#/;
#last if /^$/;
if (my ($key, $value) = m/^([^ ].*): (.*)/) {
$parsed{$key} = $value;
#last if /^$/;
if (my ($key, $value) = m/^([^ ].*): (.*)/) {
$parsed{$key} = $value;
@@
-29,3
+32,6
@@
sub parse {
return %parsed;
}
return %parsed;
}
+
+# Return a true value
+1;
diff --git
a/create-sysvinit-file.pl
b/create-sysvinit-file.pl
index
ba87700
..
d8bfde8
100644
(file)
--- a/
create-sysvinit-file.pl
+++ b/
create-sysvinit-file.pl
@@
-4,16
+4,17
@@
use Parse;
use Parse;
+$filename = shift || die "Filename expected!\n";
# Parse the metainit in
# Parse the metainit in
-%initparams =
parse($ARGV[0]
);
+%initparams =
Parse::parse($filename
);
# Print the "dynamic" part of the initskript
# Print the "dynamic" part of the initskript
-print <<
EOF
+print <<
"EOF"
#! /bin/sh
### BEGIN INIT INFO
#! /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
# 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"
# 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
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.
# ... and the rest of the initscript, that is identical for all
# metainit-created scripts.