new version of rc.darkice

This commit is contained in:
rafael@riseup.net 2010-12-21 13:32:59 +00:00
parent 84760a8f0c
commit 704124e400
1 changed files with 90 additions and 89 deletions

View File

@ -1,12 +1,13 @@
#!/bin/sh
# generic init file for darkice
#
# Author:
# Niels Dettenbach - nd@syndicat.com - 2009-11-05
# Last Change: 2010-12-21
#
# License:
# GPLv3 (2009)
#
# thanks to:
# - Roland Whitehead
# GPL (2009)
# 0.7
## settings ##
# check your paths!
@ -24,8 +25,8 @@ verbose="5"
RETVAL=0
if [ ! -f $configfile ]
then
echo "$progname: config file not found"
exit
echo "$progname: config file not found"
exit
fi
if [ ! -f $program ]
@ -36,94 +37,94 @@ fi
case $1 in
'start')
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 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
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 $pidfile
echo " stopped"
else
echo "$progname not running"
fi
RETVAL=$?
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