author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 27 Dec 2013 12:24:39 +0100 | |
changeset 61 | fb2cfcee38bd |
parent 42 | cb24a67ec3ec |
permissions | -rwxr-xr-x |
42
cb24a67ec3ec
This Bot uses bashisms und thus, a bash shell
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
33
diff
changeset
|
1 |
#!/bin/bash |
0 | 2 |
|
26
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
3 |
### BEGIN INIT INFO |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
4 |
# Provides: mcbot |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
5 |
# Required-Start: $remote_fs $syslog |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
6 |
# Required-Stop: $remote_fs $syslog |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
7 |
# Default-Start: 2 3 4 5 |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
8 |
# Default-Stop: 0 1 6 |
33
56571d34d754
safe buffers, a memory leak and cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
31
diff
changeset
|
9 |
# Short-Description: IRC BOT mcbot |
26
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
10 |
# Description: IRC BOT mcbot |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
11 |
### END INIT INFO |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
12 |
|
31
bbcb8a3366b4
mcbot needs a proper system account
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
27
diff
changeset
|
13 |
RUNAS="mcbot" |
0 | 14 |
BINARY="mcbot" |
26
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
15 |
DIRECTORY="/usr/sbin/" |
0 | 16 |
LANGUAGE="de_DE.UTF-8" |
27
4a2f7a1492ab
Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
26
diff
changeset
|
17 |
PARAMETER="" |
31
bbcb8a3366b4
mcbot needs a proper system account
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
27
diff
changeset
|
18 |
LOGFILE="/var/lib/mcbot/mcbot-`date \"+%d-%m-%y\"`.log" |
0 | 19 |
|
20 |
[[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0 |
|
21 |
||
22 |
start() { |
|
27
4a2f7a1492ab
Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
26
diff
changeset
|
23 |
echo -n " * Starting ${BINARY}" |
4a2f7a1492ab
Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
26
diff
changeset
|
24 |
su - ${RUNAS} -c "LANG=$LANGUAGE ${DIRECTORY}/${BINARY} ${PARAMETER} &> ${LOGFILE} &" |
0 | 25 |
if [ "$?" == 0 ]; then |
26 |
echo " [started]" |
|
27 |
fi |
|
28 |
} |
|
29 |
||
30 |
stop() { |
|
27
4a2f7a1492ab
Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
26
diff
changeset
|
31 |
echo -n " * Stopping ${BINARY}" |
0 | 32 |
pid=`pidof ${BINARY}` |
33 |
if [ "$pid" != "" ]; then |
|
34 |
kill -TERM `pidof ${BINARY}` |
|
35 |
sleep 5 |
|
36 |
fi |
|
37 |
echo " [stopped]" |
|
38 |
} |
|
39 |
||
40 |
status() { |
|
41 |
pid="`pidof ${BINARY}`" |
|
42 |
if [ "$pid" != "" ]; then |
|
43 |
echo "${BINARY} is started as ${pid}" |
|
44 |
else |
|
45 |
echo "${BINARY} is not running" |
|
46 |
fi |
|
47 |
} |
|
48 |
||
49 |
case "$1" in |
|
50 |
start) |
|
51 |
start |
|
52 |
;; |
|
53 |
stop) |
|
54 |
stop |
|
55 |
;; |
|
56 |
status) |
|
57 |
status |
|
58 |
;; |
|
59 |
restart) |
|
60 |
echo "Restarting ${BINARY}" |
|
61 |
stop |
|
62 |
start |
|
63 |
;; |
|
26
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
64 |
force-reload) |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
65 |
echo "Force reload stub" |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
66 |
stop |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
67 |
start |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
68 |
;; |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
69 |
|
0 | 70 |
*) |
26
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
71 |
echo "Usage: start|stop|restart|status|force-reload" |
0 | 72 |
;; |
73 |
esac |
|
74 |
||
75 |
exit 0 |