author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Sat, 13 Dec 2008 15:42:17 +0100 | |
changeset 27 | 4a2f7a1492ab |
parent 26 | 767f79e69de1 |
child 31 | bbcb8a3366b4 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/bin/sh |
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 |
767f79e69de1
Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
9 |
# Short-Description: IRC BOT mcbot |
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 |
|
27
4a2f7a1492ab
Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
26
diff
changeset
|
13 |
RUNAS="nobody" |
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="" |
4a2f7a1492ab
Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
26
diff
changeset
|
18 |
LOGFILE="/var/lib/nobody/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 |