Skip to content

Instantly share code, notes, and snippets.

@arodland
Created July 15, 2009 09:29
Show Gist options
  • Save arodland/147606 to your computer and use it in GitHub Desktop.
Save arodland/147606 to your computer and use it in GitHub Desktop.
package Log::LSB::InitMsg;
use strict;
use warnings;
# 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} = sub {
my $class = shift;
return $class->run_with_lsb($cmdname, @_);
};
}
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment