0
|
1 |
#!/bin/sh
|
|
2 |
|
|
3 |
BINARY="mcbot"
|
|
4 |
DIRECTORY="/usr/local/sbin/"
|
|
5 |
LANGUAGE="de_DE.UTF-8"
|
|
6 |
|
|
7 |
[[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0
|
|
8 |
|
|
9 |
start() {
|
|
10 |
echo -n "Starting ${BINARY}"
|
|
11 |
su - nobody -c "LANG=$LANGUAGE ${DIRECTORY}/${BINARY} &>/var/lib/nobody/mcbot-`date "+%d-%m-%y"`.log &"
|
|
12 |
if [ "$?" == 0 ]; then
|
|
13 |
echo " [started]"
|
|
14 |
fi
|
|
15 |
}
|
|
16 |
|
|
17 |
stop() {
|
|
18 |
echo -n "Stopping ${BINARY}"
|
|
19 |
pid=`pidof ${BINARY}`
|
|
20 |
if [ "$pid" != "" ]; then
|
|
21 |
kill -TERM `pidof ${BINARY}`
|
|
22 |
sleep 5
|
|
23 |
fi
|
|
24 |
echo " [stopped]"
|
|
25 |
}
|
|
26 |
|
|
27 |
status() {
|
|
28 |
pid="`pidof ${BINARY}`"
|
|
29 |
if [ "$pid" != "" ]; then
|
|
30 |
echo "${BINARY} is started as ${pid}"
|
|
31 |
else
|
|
32 |
echo "${BINARY} is not running"
|
|
33 |
fi
|
|
34 |
}
|
|
35 |
|
|
36 |
case "$1" in
|
|
37 |
start)
|
|
38 |
start
|
|
39 |
;;
|
|
40 |
stop)
|
|
41 |
stop
|
|
42 |
;;
|
|
43 |
status)
|
|
44 |
status
|
|
45 |
;;
|
|
46 |
restart)
|
|
47 |
echo "Restarting ${BINARY}"
|
|
48 |
stop
|
|
49 |
start
|
|
50 |
;;
|
|
51 |
*)
|
|
52 |
echo "Usage: start|stop|restart|status"
|
|
53 |
;;
|
|
54 |
esac
|
|
55 |
|
|
56 |
exit 0
|