1 #!/bin/sh 2 3 NAME="minidlna" 4 DAEMON=/usr/sbin/minidlnad 5 SCRIPTNAME=/etc/init.d/$NAME 6 PIDFILE=/var/run/$NAME.pid 7 CONF=/etc/$NAME.conf 8 ARGS="-f $CONF" 9 10 # Exit if the package is not installed 11 [ -x "$DAEMON" ] || exit 0 12 13 start_function() { 14 15 export PATH=$PWD:$PATH 16 17 if [ -f ${PIDFILE} ]; then 18 echo "$SCRIPTNAME already running with PID #`cat $PIDFILE` ( according to ${PIDFILE} )"; 19 exit 0 20 fi 21 22 $DAEMON $ARGS 23 24 pid=$! 25 26 if [ "$pid" != "" ]; then 27 echo -n "$pid" > ${PIDFILE} 28 fi 29 } 30 stop_function()31stop_function() { 32 33 export PATH=$PWD:$PATH 34 35 if [ ! -e "${PIDFILE}" ]; then 36 echo "${SCRIPTNAME} not running ( according to ${PIDFILE} )"; 37 exit 1; 38 fi 39 PID=`cat ${PIDFILE}` 40 kill -INT ${PID} 41 rm -f ${PIDFILE} 42 } 43 44 case $1 in 45 "start") 46 start_function 47 ;; 48 "stop") 49 stop_function 50 ;; 51 *) 52 echo "Usage: $0 {start | stop}" 53 54 esac 55