new version of rc.darkice
This commit is contained in:
parent
84760a8f0c
commit
704124e400
|
@ -1,129 +1,130 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# generic init file for darkice
|
# generic init file for darkice
|
||||||
#
|
|
||||||
# Author:
|
|
||||||
# Niels Dettenbach - nd@syndicat.com - 2009-11-05
|
|
||||||
#
|
#
|
||||||
# License:
|
# Niels Dettenbach - nd@syndicat.com - 2009-11-05
|
||||||
# GPLv3 (2009)
|
# Last Change: 2010-12-21
|
||||||
#
|
#
|
||||||
|
# thanks to:
|
||||||
|
# - Roland Whitehead
|
||||||
|
# GPL (2009)
|
||||||
|
# 0.7
|
||||||
|
|
||||||
## settings ##
|
## settings ##
|
||||||
# check your paths!
|
# check your paths!
|
||||||
|
|
||||||
program=/usr/bin/darkice
|
program=/usr/bin/darkice
|
||||||
pidfile=/var/run/darkice.pid
|
pidfile=/var/run/darkice.pid
|
||||||
configfile=/etc/darkice.cfg
|
configfile=/etc/darkice.cfg
|
||||||
logfile=/var/log/darkice.log
|
logfile=/var/log/darkice.log
|
||||||
progname="darkice"
|
progname="darkice"
|
||||||
restart_delay=2
|
restart_delay=2
|
||||||
verbose="5"
|
verbose="5"
|
||||||
|
|
||||||
## end of settings ##
|
## end of settings ##
|
||||||
|
|
||||||
RETVAL=0
|
RETVAL=0
|
||||||
if [ ! -f $configfile ]
|
if [ ! -f $configfile ]
|
||||||
then
|
then
|
||||||
echo "$progname: config file not found"
|
echo "$progname: config file not found"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f $program ]
|
if [ ! -f $program ]
|
||||||
then
|
then
|
||||||
echo "$progname: programm file $program not found"
|
echo "$progname: programm file $program not found"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
'start')
|
'start')
|
||||||
if [ -f $pidfile ]; then
|
if [ -f $pidfile ]; then
|
||||||
PID=`cat $pidfile`
|
PID=`cat $pidfile`
|
||||||
running=`ps --no-headers -o "%c" -p $PID`
|
running=`ps --no-headers -o "%c" -p $PID`
|
||||||
if ( [ "$progname" == "$running" ] ); then
|
if ( [ "$progname" == "$running" ] ); then
|
||||||
echo "$progname is still running"
|
echo "$progname is still running"
|
||||||
else
|
else
|
||||||
echo "$progname seems crashed - PID does not match the deamon"
|
echo "$progname seems crashed - PID ($PID) does not match the deamon"
|
||||||
echo "removing stale PID File $pidfile"
|
echo "removing stale PID File $pidfile"
|
||||||
rm $pidfile
|
rm -f $pidfile
|
||||||
$0 start
|
$0 start
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo -n $"Starting $progname "
|
echo -n $"Starting $progname "
|
||||||
RETVAL=1
|
RETVAL=1
|
||||||
$program -v $verbose -c $configfile 2>%1 >> $logfile &
|
$program -v $verbose -c $configfile 2>%1 >> $logfile &
|
||||||
echo
|
echo
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL -eq 0 ]; then
|
if [ $RETVAL -eq 0 ]; then
|
||||||
echo $! > $pidfile
|
echo $! > $pidfile
|
||||||
echo " started"
|
echo " started"
|
||||||
else
|
else
|
||||||
echo " not started"
|
echo " not started"
|
||||||
echo $RETVAL
|
echo $RETVAL
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
'stop')
|
'stop')
|
||||||
if [ -f $pidfile ]; then
|
if [ -f $pidfile ]; then
|
||||||
echo -n $"Stop $progname "
|
echo -n $"Stop $progname "
|
||||||
PID=`cat $pidfile`
|
PID=`cat $pidfile`
|
||||||
kill -s TERM $PID 2> /dev/null
|
kill -s TERM $PID 2> /dev/null
|
||||||
echo
|
echo
|
||||||
sleep $restart_delay
|
sleep $restart_delay
|
||||||
rm $pidfile
|
rm -f $pidfile
|
||||||
echo " stopped"
|
echo " stopped"
|
||||||
else
|
else
|
||||||
echo "$progname not running"
|
echo "$progname not running"
|
||||||
fi
|
fi
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
;;
|
;;
|
||||||
'status')
|
'status')
|
||||||
if [ -f $pidfile ]; then
|
if [ -f $pidfile ]; then
|
||||||
PID=`cat $pidfile`
|
PID=`cat $pidfile`
|
||||||
running=`ps --no-headers -o "%c" -p $PID`
|
running=`ps --no-headers -o "%c" -p $PID`
|
||||||
if ( [ "$progname" == "$running" ] ); then
|
if ( [ "$progname" == "$running" ] ); then
|
||||||
echo "$progname IS running with PID `cat $pidfile`."
|
echo "$progname IS running with PID `cat $pidfile`."
|
||||||
else
|
else
|
||||||
echo "$progname process is dead or stale PID File $pidfile"
|
echo "$progname process is dead or stale PID File $pidfile"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$progname is not running"
|
echo "$progname is not running"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
'restart')
|
'restart')
|
||||||
$0 stop
|
$0 stop
|
||||||
$0 start
|
$0 start
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
;;
|
;;
|
||||||
|
|
||||||
'restartifdown')
|
'restartifdown')
|
||||||
if [ -f $pidfile ]; then
|
if [ -f $pidfile ]; then
|
||||||
PID=`cat $pidfile`
|
PID=`cat $pidfile`
|
||||||
running=`ps --no-headers -o "%c" -p $PID`
|
running=`ps --no-headers -o "%c" -p $PID`
|
||||||
if ( [ "$progname" == "$running" ] ); then
|
if ( [ "$progname" == "$running" ] ); then
|
||||||
echo "$progname IS running with PID `cat $pidfile` - no restart."
|
echo "$progname IS running with PID `cat $pidfile` - no restart."
|
||||||
else
|
else
|
||||||
echo "$progname PID $PID seems dead - restart"
|
echo "$progname PID $PID seems dead - restart"
|
||||||
$0 stop
|
$0 stop
|
||||||
$0 start
|
$0 start
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "PID file $pidfile found - restart"
|
echo "PID file $pidfile found - restart"
|
||||||
$0 stop
|
$0 stop
|
||||||
$0 start
|
$0 start
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop|restart|status|restartifdown} "
|
echo "Usage: $0 {start|stop|restart|status|restartifdown} "
|
||||||
exit 1;
|
exit 1;
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue