scripts/runbot
changeset 0 586472add385
child 26 767f79e69de1
new file mode 100755
--- /dev/null
+++ b/scripts/runbot
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+BINARY="mcbot"
+DIRECTORY="/usr/local/sbin/"
+LANGUAGE="de_DE.UTF-8"
+
+[[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0
+
+start() {
+	echo -n "Starting ${BINARY}"
+	su - nobody -c "LANG=$LANGUAGE ${DIRECTORY}/${BINARY} &>/var/lib/nobody/mcbot-`date "+%d-%m-%y"`.log &"
+	if [ "$?" == 0 ]; then
+		echo " [started]"
+	fi
+}
+
+stop() {
+	echo -n "Stopping ${BINARY}"
+	pid=`pidof ${BINARY}`
+	if [ "$pid" != "" ]; then
+		kill -TERM `pidof ${BINARY}`
+		sleep 5
+	fi
+	echo " [stopped]"
+}
+
+status() {
+	pid="`pidof ${BINARY}`"
+	if [ "$pid" != "" ]; then
+		echo "${BINARY} is started as ${pid}"
+	else
+		echo "${BINARY} is not running"
+	fi
+}
+
+case "$1" in
+	start)
+		start
+	;;
+	stop)
+		stop
+	;;
+	status)
+		status
+	;;
+	restart)
+		echo "Restarting ${BINARY}"
+		stop
+		start
+	;;
+	*)
+		echo "Usage: start|stop|restart|status"
+	;;
+esac
+
+exit 0