-
Notifications
You must be signed in to change notification settings - Fork 0
/
debian-startscript
85 lines (73 loc) · 2.06 KB
/
debian-startscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: pcwbot
# Required-Start: $network $local_fs
# Required-Stop: $network $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Initscript for pcwbot
# Description: Start/Stop/Restart the pcwbot service daemon
### END INIT INFO
set -e
# Installation:
# Move this file to /etc/init.d/pcwbot
# Make it executable: sudo chmod +x /etc/init.d/pcwbot
# Start at boot: sudo update-rc.d pcwbot defaults 80 10
# Manual start: sudo /etc/init.d/pcwbot start
# Change the next 3 lines to suit where you installed pcwbot, and which user is running the Urban Terror server
DIR=/opt/pcwbot
USER=q3ut4
GROUP=q3ut4
# Don't modify the code below
DAEMON=$DIR/pcwbot.py
NAME=pcwbot
RUNDIR=/var/run/$NAME
PIDFILE=$RUNDIR/$NAME.pid
# Get LSB functions
. /lib/lsb/init-functions
# See if the daemon is present
if [ -e "$DAEMON" ]; then
chmod +x "$DAEMON"
chown -R "$USER:$GROUP" "$DIR"
fi
# Make sure /var/run/pcwbot exists
test -d "$RUNDIR" || {
mkdir -p "$RUNDIR"
chown -R "$USER:$GROUP" "$RUNDIR"
}
case "$1" in
start)
if [ -e "$PIDFILE" ]; then
echo "$0:"
echo " Another instance of \`${DAEMON##*/}' seems to be running."
echo " If this is not the case, please remove \"$PIDFILE\"."
exit 1
fi
log_begin_msg "Starting service $NAME..."
umask 002
if start-stop-daemon --start --quiet --background --chdir $DIR --chuid $USER:$GROUP --pidfile "$PIDFILE" --make-pidfile --exec $DAEMON; then
log_end_msg 0
else
log_end_msg $?
fi
;;
stop)
log_begin_msg "Stopping service $NAME..."
if start-stop-daemon --stop --quiet --pidfile "$PIDFILE" && rm -f "$PIDFILE"; then
log_end_msg 0
else
log_end_msg $?
fi
;;
restart|force-reload)
$0 stop
sleep 3
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0