diff options
| author | Paul Buetow <paul@buetow.org> | 2022-04-21 23:45:23 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2022-04-21 22:59:05 +0100 |
| commit | ce255ff5a1257db57424603caac2b4bfca3c7694 (patch) | |
| tree | 9f5c3a9222555270ae7d3ebccd2d4da27e3f1e87 /bin | |
| parent | db2bf4b9dbe3388e074a1144ac3f0e9b04d43b96 (diff) | |
release v1.3develop
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/perldaemon | 101 |
1 files changed, 50 insertions, 51 deletions
diff --git a/bin/perldaemon b/bin/perldaemon index 11c1a7e..6fb2b2c 100755 --- a/bin/perldaemon +++ b/bin/perldaemon @@ -1,74 +1,73 @@ -#!/usr/bin/env bash -# PerlDaemon (c) 2010, 2011, Dipl.-Inform. (FH) Paul Buetow (http://perldaemon.buetow.org) +#!/usr/bin/env sh -declare -r ARG=$1 -declare -a LIBPATHS=(./lib ../lib /lib /usr/lib /usr/local/lib /opt/lib) +export ARG=$1 +export LIBPATHS="./lib ../lib /lib /usr/lib /usr/local/lib /opt/lib" -for path in ${LIBPATHS[@]}; do - if [ -f $path/PerlDaemon/PerlDaemon.pl ]; then - LIBDIR=$path - break - fi +for libpath in $LIBPATHS; do + if [ -f $libpath/PerlDaemon/PerlDaemon.pl ]; then + LIBDIR=$libpath + break + fi done if [ -z "$LIBDIR" ]; then - echo No PerlDaemon module path found - exit 1 + echo No PerlDaemon module path found + exit 1 fi -start () { - echo Starting daemon now... - perl -I$LIBDIR $LIBDIR/PerlDaemon/PerlDaemon.pl config=./conf/perldaemon.conf $@ +function start_it { + echo Starting daemon now... + perl -I$LIBDIR $LIBDIR/PerlDaemon/PerlDaemon.pl config=./conf/perldaemon.conf $@ } -stop () { - if [ -f ./run/perldaemon.pid ]; then - echo Stopping daemon now... - kill $(cat ./run/perldaemon.pid); - else - echo "No pidfile found (not running?) " - fi +function stop_it { + if [ -f ./run/perldaemon.pid ]; then + echo "Stopping daemon now..." + kill `cat ./run/perldaemon.pid`; + else + echo "No pidfile found (not running?) " + fi } -logrotate () { - echo Triggering a logrotate - kill -HUP $(cat ./run/perldaemon.pid) +function logrotate_it { + echo Triggering a logrotate + kill -HUP $(cat ./run/perldaemon.pid) } -keys () { - perl -I$LIBDIR $LIBDIR/PerlDaemon/PerlDaemon.pl config=./conf/perldaemon.conf keys=1 $@ +function keys { + perl -I$LIBDIR $LIBDIR/PerlDaemon/PerlDaemon.pl config=./conf/perldaemon.conf keys=1 $@ } case $ARG in - start) - shift - start $@ - ;; + start) + shift + start_it $@ + ;; - stop) - stop - ;; + stop) + stop_it + ;; - restart) - shift - stop - start $@ - ;; + restart) + shift + stop_it + start_it $@ + ;; - logrotate) - logrotate - ;; + logrotate) + logrotate_it + ;; - foreground) - start daemon.daemonize=no $@ - ;; + foreground) + start_it daemon.daemonize=no $@ + ;; - keys) - keys $@ - ;; + keys) + keys $@ + ;; - *) - echo "Usage: $0 <start|stop|restart|logrotate|foreground|keys> [key1=val1 [[key2=val2] ...]]" - exit 1 - ;; + *) + echo "Usage: $0 <start|stop|restart|logrotate|foreground|keys> [key1=val1 [[key2=val2] ...]]" + exit 1 + ;; esac |
