1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
my ( $file, $ilib );
# Let's make it so people can test in t/ or in the dist directory.
if ( -f 't/bin/01_lsb_02.pl' ) { # Dist Directory.
$file = "t/bin/01_lsb_02.pl";
$ilib = "lib";
} elsif ( -f 'bin/01_lsb_02.pl' ) {
$file = "bin/01_lsb_02.pl";
$ilib = "../lib";
} else {
die "Tests should be run in the dist directory or t/";
}
open my $lf, "-|", "perl", "-I$ilib", $file, "get_init_file"
or die "Failed to open pipe to $file: $!";
my $content = do { local $/; <$lf> };
close $lf;
my $content_expected = do { local $/; <DATA> };
is $content, $content_expected, "LSB File Generation Works.";
done_testing;
__DATA__
#!/bin/sh
### BEGIN INIT INFO
# Provides: My Daemon
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: My Daemon Short
# Description: My Daemon controls the My Daemon daemon.
### END INIT INFO`
[ -r /etc/default/my_program ] && . /etc/default/my_program
if [ -x /usr/sbin/mydaemon/init.pl ];
then
/usr/sbin/mydaemon/init.pl $1
else
echo "Required program /usr/sbin/mydaemon/init.pl not found!"
exit 1;
fi
|