scripts/runbot
changeset 27 4a2f7a1492ab
parent 26 767f79e69de1
child 31 bbcb8a3366b4
equal deleted inserted replaced
26:767f79e69de1 27:4a2f7a1492ab
     8 # Default-Stop:      0 1 6
     8 # Default-Stop:      0 1 6
     9 # Short-Description: IRC BOT mcbot 
     9 # Short-Description: IRC BOT mcbot 
    10 # Description:       IRC BOT mcbot
    10 # Description:       IRC BOT mcbot
    11 ### END INIT INFO
    11 ### END INIT INFO
    12 
    12 
       
    13 RUNAS="nobody"
    13 BINARY="mcbot"
    14 BINARY="mcbot"
    14 DIRECTORY="/usr/sbin/"
    15 DIRECTORY="/usr/sbin/"
    15 LANGUAGE="de_DE.UTF-8"
    16 LANGUAGE="de_DE.UTF-8"
       
    17 PARAMETER=""
       
    18 LOGFILE="/var/lib/nobody/mcbot-`date \"+%d-%m-%y\"`.log"
    16 
    19 
    17 [[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0
    20 [[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0
    18 
    21 
    19 start() {
    22 start() {
    20 	echo -n "Starting ${BINARY}"
    23 	echo -n " * Starting ${BINARY}"
    21 	su - nobody -c "LANG=$LANGUAGE ${DIRECTORY}/${BINARY} &>/var/lib/nobody/mcbot-`date "+%d-%m-%y"`.log &"
    24 	su - ${RUNAS} -c "LANG=$LANGUAGE ${DIRECTORY}/${BINARY} ${PARAMETER} &> ${LOGFILE} &"
    22 	if [ "$?" == 0 ]; then
    25 	if [ "$?" == 0 ]; then
    23 		echo " [started]"
    26 		echo " [started]"
    24 	fi
    27 	fi
    25 }
    28 }
    26 
    29 
    27 stop() {
    30 stop() {
    28 	echo -n "Stopping ${BINARY}"
    31 	echo -n " * Stopping ${BINARY}"
    29 	pid=`pidof ${BINARY}`
    32 	pid=`pidof ${BINARY}`
    30 	if [ "$pid" != "" ]; then
    33 	if [ "$pid" != "" ]; then
    31 		kill -TERM `pidof ${BINARY}`
    34 		kill -TERM `pidof ${BINARY}`
    32 		sleep 5
    35 		sleep 5
    33 	fi
    36 	fi