[darkice] Re: darkice init and status (shell) script file (generic)

  • From: "Rafael Diniz" <rafael@xxxxxxxxxx>
  • To: darkice@xxxxxxxxxxxxx
  • Date: Mon, 9 Nov 2009 14:06:54 -0800 (PST)

also, lets try to use our new website to create tickets!
: )


> hi niels,
> can you make a svn diff against the trunk?
> otherwise, I can make it later.
>
> thanks,
> rafael diniz
>
>> Dear Rafael,
>> dear darkice users,
>>
>> many thanks for your good work with 0.20.
>>
>> regarding to the discussion on this list and the fact that there are
>> still
>> distributions without a init script for darkice (which should be run
>> generically under the different linux distributions) i post my
>> suggestion
>> for
>> such one here.
>>
>> However, may be this will help someone too.
>>
>> Additionally the script allows simple but helpful monitoring or
>> 'auto-repair' in a case the darkice process get crashed.
>>
>>  - 'start' starts darkice as a deamon
>>  - 'stop' stops a running darkice process
>>  - 'restart' stops and starts a darkice process safely
>>  - 'restartifdown' checks the darkice process and create a new one when
>> crashed - this could be used i.e. in a cron job to make shure darkice is
>> running all the time
>>  - 'status' checks the running darkice process
>>
>> Any contribution, correction or opinion is welcome here.
>>
>> btw: the script is available for download here too:
>>  -> ftp://ftp.syndicat.com/pub/darkice/darkice
>>  -> http://www.syndicat.com/pub/darkice/darkice
>>
>> --- snip ---
>> #!/bin/sh
>> # generic init file for darkice
>> #
>> # Niels Dettenbach - nd@xxxxxxxxxxxx - 2009-11-05
>> # GPL (2009)
>> # 0.4
>>
>> ## settings ##
>> # check your paths!
>>
>> program=/usr/bin/darkice
>> pidfile=/var/run/darkice.pid
>> configfile=/etc/darkice.cfg
>> logfile=/var/log/darkice.log
>> progname="darkice"
>> restart_delay=2
>> verbose="5"
>>
>> ## end of settings ##
>>
>> RETVAL=0
>> if [ ! -f $configfile ]
>> then
>>         echo "$progname: config file not found"
>>         exit
>> fi
>> if [ ! -f $program ]
>> then
>>         echo "$progname: programm file $program not found"
>>         exit
>> fi
>>
>> case $1 in
>> '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=$?
>> ;;
>> '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
>> ;;
>> 'restart')
>>         $0 stop
>>         $0 start
>>         RETVAL=$?
>> ;;
>>
>> 'restartifdown')
>>         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 "Usage: $0 {start|stop|restart|status|restartifdown} "
>>         exit 1;
>> ;;
>> esac
>>
>> exit $RETVAL
>>
>> --- snap ---
>>
>> May be there are still exit codes which are not correct in each
>> situation
>> - pls correct me here if you find something wrong.
>>
>>
>> cheers,
>>
>>
>> Niels.
>> --
>>
>> ---
>>
>>   Niels Dettenbach
>>   ---
>>   Syndicat IT&Internet
>>   http://www.syndicat.com
>>   T.-Muentzer.-Str. 2, 37308 Heilbad Heiligenstadt - DE
>>   ---
>>   Kryptoinfo:
>>   PGP public key ID 651CA20D
>>   Fingerprint: 55E0 4DCD B04C 4A49 1586  88AE 54DC 4465 651C A20D
>>   https://syndicat.com/pub_key.asc
>>   ---
>>
>
>
>
>



Other related posts: