From 704124e40046c70e1f95d292f26b17b43861c457 Mon Sep 17 00:00:00 2001 From: "rafael@riseup.net" Date: Tue, 21 Dec 2010 13:32:59 +0000 Subject: [PATCH] new version of rc.darkice --- darkice/trunk/rc.darkice | 179 ++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 89 deletions(-) diff --git a/darkice/trunk/rc.darkice b/darkice/trunk/rc.darkice index 16180c1..0c5047c 100644 --- a/darkice/trunk/rc.darkice +++ b/darkice/trunk/rc.darkice @@ -1,129 +1,130 @@ -#!/bin/sh +#!/bin/sh # generic init file for darkice -# -# Author: -# Niels Dettenbach - nd@syndicat.com - 2009-11-05 # -# License: -# GPLv3 (2009) -# +# Niels Dettenbach - nd@syndicat.com - 2009-11-05 +# Last Change: 2010-12-21 +# +# thanks to: +# - Roland Whitehead +# GPL (2009) +# 0.7 ## settings ## # check your paths! program=/usr/bin/darkice pidfile=/var/run/darkice.pid -configfile=/etc/darkice.cfg +configfile=/etc/darkice.cfg logfile=/var/log/darkice.log -progname="darkice" -restart_delay=2 -verbose="5" +progname="darkice" +restart_delay=2 +verbose="5" ## end of settings ## RETVAL=0 if [ ! -f $configfile ] -then - echo "$progname: config file not found" - exit -fi +then + echo "$progname: config file not found" + exit +fi if [ ! -f $program ] -then +then echo "$progname: programm file $program not found" - exit -fi + exit +fi case $1 in -'start') - if [ -f $pidfile ]; then +'start') + if [ -f $pidfile ]; then PID=`cat $pidfile` running=`ps --no-headers -o "%c" -p $PID` if ( [ "$progname" == "$running" ] ); then - echo "$progname is still running" - else - echo "$progname seems crashed - PID does not match the deamon" - echo "removing stale PID File $pidfile" - rm $pidfile - $0 start - exit $? - fi - exit 0 - else - echo -n $"Starting $progname " - RETVAL=1 - $program -v $verbose -c $configfile 2>%1 >> $logfile & - echo - RETVAL=$? - if [ $RETVAL -eq 0 ]; then - echo $! > $pidfile - echo " started" - else - echo " not started" - echo $RETVAL - exit 0 - fi - RETVAL=$? - fi -;; -'stop') - if [ -f $pidfile ]; then - echo -n $"Stop $progname " - PID=`cat $pidfile` - kill -s TERM $PID 2> /dev/null - echo - sleep $restart_delay - rm $pidfile - echo " stopped" - else - echo "$progname not running" - fi - RETVAL=$? + echo "$progname is still running" + else + echo "$progname seems crashed - PID ($PID) does not match the deamon" + echo "removing stale PID File $pidfile" + rm -f $pidfile + $0 start + exit $? + fi + exit 0 + else + echo -n $"Starting $progname " + RETVAL=1 + $program -v $verbose -c $configfile 2>%1 >> $logfile & + echo + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + echo $! > $pidfile + echo " started" + else + echo " not started" + echo $RETVAL + exit 0 + fi + RETVAL=$? + fi +;; +'stop') + if [ -f $pidfile ]; then + echo -n $"Stop $progname " + PID=`cat $pidfile` + kill -s TERM $PID 2> /dev/null + echo + sleep $restart_delay + rm -f $pidfile + echo " stopped" + else + echo "$progname not running" + fi + RETVAL=$? ;; 'status') - if [ -f $pidfile ]; then - PID=`cat $pidfile` - running=`ps --no-headers -o "%c" -p $PID` - if ( [ "$progname" == "$running" ] ); then - echo "$progname IS running with PID `cat $pidfile`." - else - echo "$progname process is dead or stale PID File $pidfile" - exit 0 - fi - else - echo "$progname is not running" - exit 0 - fi + if [ -f $pidfile ]; then + PID=`cat $pidfile` + running=`ps --no-headers -o "%c" -p $PID` + if ( [ "$progname" == "$running" ] ); then + echo "$progname IS running with PID `cat $pidfile`." + else + echo "$progname process is dead or stale PID File $pidfile" + exit 0 + fi + else + echo "$progname is not running" + exit 0 + fi ;; 'restart') - $0 stop - $0 start - RETVAL=$? + $0 stop + $0 start + RETVAL=$? ;; 'restartifdown') - if [ -f $pidfile ]; then + if [ -f $pidfile ]; then PID=`cat $pidfile` running=`ps --no-headers -o "%c" -p $PID` if ( [ "$progname" == "$running" ] ); then echo "$progname IS running with PID `cat $pidfile` - no restart." else - echo "$progname PID $PID seems dead - restart" - $0 stop - $0 start - RETVAL=$? - fi - else - echo "PID file $pidfile found - restart" - $0 stop - $0 start - RETVAL=$? - fi + echo "$progname PID $PID seems dead - restart" + $0 stop + $0 start + RETVAL=$? + fi + else + echo "PID file $pidfile found - restart" + $0 stop + $0 start + RETVAL=$? + fi ;; *) - echo "Usage: $0 {start|stop|restart|status|restartifdown} " - exit 1; + echo "Usage: $0 {start|stop|restart|status|restartifdown} " + exit 1; ;; esac