diff --git a/impermanence.pl b/impermanence.pl index b4e7caa..6c7fd6f 100755 --- a/impermanence.pl +++ b/impermanence.pl @@ -9,13 +9,14 @@ use Getopt::Std;; use Data::Dumper; use File::HomeDir; use File::Path qw(make_path); +use Sys::Syslog qw(:standard :macros); use 5.010; my $verbose = 0; # display usage and quit sub usage { - say "usage: $0 [-v] -d directory -u user (start|stop|restart)"; + say "usage: $0 [-v] -d directory -u user (start|stop|restart|status)"; say " $0 -t conf"; exit 1; } @@ -24,12 +25,14 @@ sub usage { sub saydebug { my $msg = shift; say STDERR "DEBUG: $msg" if $verbose; + syslog(LOG_INFO, "$msg"); } # display a message before exiting with status 2 sub trap_error { my $msg = shift; say STDERR "FATAL: $msg"; + syslog(LOG_ERR, "$msg"); exit 2; } @@ -228,6 +231,8 @@ sub main { $start = 1; }elsif( $ARGV[0] eq "stop" ) { $stop = 1; + }elsif( $ARGV[0] eq "status" ) { + exit ! is_mounted($impermanence_home); }else{ usage(); } @@ -246,4 +251,6 @@ sub main { } -main() +openlog("impermanence", 'ndelay', LOG_DAEMON); +main(); +closelog(); diff --git a/openbsd/impermanence.rc b/openbsd/impermanence.rc new file mode 100755 index 0000000..7ac5104 --- /dev/null +++ b/openbsd/impermanence.rc @@ -0,0 +1,22 @@ +#!/bin/ksh +# + +daemon="/usr/local/bin/impermanence" + +. /etc/rc.d/rc.subr + +rc_reload=NO + +rc_start() { + $daemon ${daemon_flags} start +} + +rc_stop() { + $daemon ${daemon_flags} stop +} + +rc_check() { + $daemon ${daemon_flags} status +} + +rc_cmd $1 diff --git a/tests/errored.yml b/tests/errored.yml new file mode 100644 index 0000000..92bcaf9 --- /dev/null +++ b/tests/errored.yml @@ -0,0 +1,2 @@ +key: +value