From f94102ce117195cf7dd7db93d9a10985eebabb1e Mon Sep 17 00:00:00 2001 From: Albrecht Gebhardt Date: Tue, 27 Nov 2018 13:09:29 +0100 Subject: [PATCH] improve init script --- rc.frewe-client | 90 ++++++------------------------------------------- 1 file changed, 10 insertions(+), 80 deletions(-) diff --git a/rc.frewe-client b/rc.frewe-client index a7f5efa..10fe625 100644 --- a/rc.frewe-client +++ b/rc.frewe-client @@ -1,31 +1,21 @@ #!/bin/sh -# Install/uninstall, start/stop/restart, testrun frewe-client -if [ -x /usr/bin/dirname ] && [ -x /usr/bin/readlink ] -then - - if [ -L $0 ] - then - DIR=$(dirname $(readlink -f $0)) ; - else - DIR=$(dirname $0) ; - fi -else - DIR="/var/spool/frewe" -fi - -if [ "$DIR" == "." ] -then - DIR="`pwd`" -fi +### BEGIN INIT INFO +# Provides: frewe-client +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Frewe upload client +DIR="/var/spool/frewe" PRONAME="frewe-client" BINFILE="/usr/local/bin/$PRONAME" CFGFILE="/etc/$PRONAME.cfg" LOGFILE="/dev/null" # Uncomment to enable local data logging -#LOGFILE="$DIR/$PRONAME.csv" +#LOGFILE="/tmp/$PRONAME.csv" if [ ! -f "$BINFILE" ] then @@ -48,43 +38,6 @@ $BINFILE -H case "$1" in -install) - -if [ -e /var/flash/debug.cfg ] && [ "`cat /var/flash/debug.cfg | grep $PRONAME`" != "" ] -then - echo "$PRONAME is already installed. Here is the content of debug.cfg:" - cat /var/flash/debug.cfg - echo "Nothing to install" - exit 1 -fi - -echo "(max=12; i=0; while [ \$i -lt \$max ]; do if [ -x "$BINFILE" ]; then $BINFILE -c $CFGFILE >> $LOGFILE & break; fi; let i=\$i+1; echo Waiting for $PRONAME... \$i; sleep 5; done) &" > /var/tmp/debug.cfg - -if [ -e /var/flash/debug.cfg ] -then - cat /var/flash/debug.cfg >> /var/tmp/debug.cfg -fi - -cat /var/tmp/debug.cfg > /var/flash/debug.cfg -echo "$PRONAME installed. Here is the content of the new debug.cfg:" -cat /var/flash/debug.cfg - -;; - -uninstall) - -if [ -e /var/flash/debug.cfg ] -then - cat /var/flash/debug.cfg | grep -v $PRONAME > /var/tmp/debug.cfg - cat /var/tmp/debug.cfg > /var/flash/debug.cfg - echo "$PRONAME uninstalled. Here is the content of the new debug.cfg:" - cat /var/flash/debug.cfg -else - echo "debug.cfg not found, nothing was installed..." -fi - -;; - start) if [ "`pidof $PRONAME`" != "" ] @@ -131,16 +84,6 @@ echo "$PRONAME started with PID `pidof $PRONAME`" stat) -if [ "`cat /var/flash/debug.cfg | grep $PRONAME`" != "" ] -then - echo "$PRONAME is installed. Here is content of debug.cfg:" - cat /var/flash/debug.cfg -else - echo "$PRONAME is not installed" -fi - -echo - if [ "`pidof $PRONAME`" != "" ] then echo "$PRONAME is running with PID `pidof $PRONAME`" @@ -151,22 +94,9 @@ fi ;; - -testrun) - -$BINFILE -v - -;; - -testruncfg) - -$BINFILE -v -c $CFGFILE -r 0 - -;; - *) -echo "Usage: $0 {install|uninstall|start|stop|restart|stat|testrun|testruncfg}" +echo "Usage: $0 {start|stop|restart|stat}" exit 1 ;; -- GitLab