Permalink
Browse files

Log::LSB::InitMsg lives here for the moment

  • Loading branch information...
1 parent 0792ea0 commit c7385fc295cd2e568d9ab64d57eba1e4e86e7ace Andrew Rodland committed Jul 15, 2009
Showing with 43 additions and 0 deletions.
  1. +43 −0 Log/LSB/InitMsg.pm
View
@@ -0,0 +1,43 @@
+package Log::LSB::InitMsg;
+
+use strict;
+use warnings;
+
+use Sub::Name;
+
+# Call a function from /lib/lsb/init-functions in a shell
+sub run_with_lsb {
+ my ($class, $funcname, @args) = @_;
+ my $ret = system('/bin/sh', '-c',
+ '. /lib/lsb/init-functions ; cmd=$1 ; shift ; $cmd "$@"',
+ $funcname, # sh process name
+ $funcname, @args);
+
+ if (!defined $ret) {
+ return;
+ }
+
+ return !$ret;
+}
+
+BEGIN {
+ my @cmds = qw(
+ log_success_msg
+ log_failure_msg
+ log_warning_msg
+ log_begin_msg
+ log_end_msg
+ log_daemon_msg
+ log_progress_msg
+ );
+
+ for my $cmdname (@cmds) {
+ no strict;
+ *{$cmdname} = subname $cmdname => sub {
+ my $class = shift;
+ return $class->run_with_lsb($cmdname, @_);
+ };
+ }
+}
+
+1;

0 comments on commit c7385fc

Please sign in to comment.