diff --git a/Changes b/Changes index 95270a1..14fb0d6 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ + * include the date and module version in the generated init file + (Karen Etheridge) + 0.0.9 2012-19-04 SymKat * Stole Moo's MANIFEST.SKIP diff --git a/lib/Daemon/Control.pm b/lib/Daemon/Control.pm index 94d5fab..26a51d9 100644 --- a/lib/Daemon/Control.pm +++ b/lib/Daemon/Control.pm @@ -375,6 +375,8 @@ sub dump_init_script { $self->data( $self->run_template( $self->data, { + HEADER => 'Generated at ' . scalar(localtime) + . ' with Daemon::Control ' . ($self->VERSION || 'DEV'), NAME => $self->name ? $self->name : "", REQUIRED_START => $self->lsb_start ? $self->lsb_start : "", REQUIRED_STOP => $self->lsb_stop ? $self->lsb_stop : "", @@ -428,6 +430,8 @@ sub run { __DATA__ #!/bin/sh +# [% HEADER %] + ### BEGIN INIT INFO # Provides: [% NAME %] # Required-Start: [% REQUIRED_START %] diff --git a/t/01_lsb_file.t b/t/01_lsb_file.t index 70b39d6..41a642d 100644 --- a/t/01_lsb_file.t +++ b/t/01_lsb_file.t @@ -24,17 +24,19 @@ close $lf; my $content_expected = do { local $/; }; -is $content, $content_expected, "LSB File Generation Works."; +like $content, qr/$content_expected/, "LSB File Generation Works."; done_testing; __DATA__ #!/bin/sh +# Generated at [\w: ]+ with Daemon::Control (?:DEV|[\d.]+) + ### BEGIN INIT INFO # Provides: My Daemon -# Required-Start: $syslog $remote_fs -# Required-Stop: $syslog +# Required-Start: \$syslog \$remote_fs +# Required-Stop: \$syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: My Daemon Short @@ -43,9 +45,9 @@ __DATA__ -if [ -x /usr/sbin/mydaemon/init.pl ]; +if \[ -x /usr/sbin/mydaemon/init.pl \]; then - /usr/sbin/mydaemon/init.pl $1 + /usr/sbin/mydaemon/init.pl \$1 else echo "Required program /usr/sbin/mydaemon/init.pl not found!" exit 1; diff --git a/t/01_lsb_file_with_init_config.t b/t/01_lsb_file_with_init_config.t index d3f8cb6..65975a7 100644 --- a/t/01_lsb_file_with_init_config.t +++ b/t/01_lsb_file_with_init_config.t @@ -24,28 +24,30 @@ close $lf; my $content_expected = do { local $/; }; -is $content, $content_expected, "LSB File Generation Works."; +like $content, qr/$content_expected/, "LSB File Generation Works."; done_testing; __DATA__ #!/bin/sh +# Generated at [\w: ]+ with Daemon::Control (?:DEV|[\d.]+) + ### BEGIN INIT INFO # Provides: My Daemon -# Required-Start: $syslog $remote_fs -# Required-Stop: $syslog +# 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 +\[ -r /etc/default/my_program \] && . /etc/default/my_program -if [ -x /usr/sbin/mydaemon/init.pl ]; +if \[ -x /usr/sbin/mydaemon/init.pl \]; then - /usr/sbin/mydaemon/init.pl $1 + /usr/sbin/mydaemon/init.pl \$1 else echo "Required program /usr/sbin/mydaemon/init.pl not found!" exit 1;