|
@@ -0,0 +1,66 @@
|
|
1
|
+#!/bin/sh
|
|
2
|
+### BEGIN INIT INFO
|
|
3
|
+# Provides: <NAME>
|
|
4
|
+# Required-Start: $local_fs $network $named $time $syslog
|
|
5
|
+# Required-Stop: $local_fs $network $named $time $syslog
|
|
6
|
+# Default-Start: 2 3 4 5
|
|
7
|
+# Default-Stop: 0 1 6
|
|
8
|
+# Description: <DESCRIPTION>
|
|
9
|
+### END INIT INFO
|
|
10
|
+
|
|
11
|
+SCRIPT='screen -dmS fake-tracker /var/fake-tracker/fake-tracker.py /var/fake-tracker/config.conf'
|
|
12
|
+RUNAS=root
|
|
13
|
+
|
|
14
|
+PIDFILE=/var/run/fake-tracker.pid
|
|
15
|
+
|
|
16
|
+start() {
|
|
17
|
+ if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
|
|
18
|
+ echo 'Service already running' >&2
|
|
19
|
+ return 1
|
|
20
|
+ fi
|
|
21
|
+ echo 'Starting service…' >&2
|
|
22
|
+ local CMD="$SCRIPT & echo \$!"
|
|
23
|
+ su -c "$CMD" $RUNAS > "$PIDFILE"
|
|
24
|
+ echo 'Service started' >&2
|
|
25
|
+}
|
|
26
|
+
|
|
27
|
+stop() {
|
|
28
|
+ if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
|
|
29
|
+ echo 'Service not running' >&2
|
|
30
|
+ return 1
|
|
31
|
+ fi
|
|
32
|
+ echo 'Stopping service…' >&2
|
|
33
|
+ kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
|
|
34
|
+ echo 'Service stopped' >&2
|
|
35
|
+}
|
|
36
|
+
|
|
37
|
+uninstall() {
|
|
38
|
+ echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
|
|
39
|
+ local SURE
|
|
40
|
+ read SURE
|
|
41
|
+ if [ "$SURE" = "yes" ]; then
|
|
42
|
+ stop
|
|
43
|
+ rm -f "$PIDFILE"
|
|
44
|
+ echo "Notice: log file is not be removed: '$LOGFILE'" >&2
|
|
45
|
+ update-rc.d -f <NAME> remove
|
|
46
|
+ rm -fv "$0"
|
|
47
|
+ fi
|
|
48
|
+}
|
|
49
|
+
|
|
50
|
+case "$1" in
|
|
51
|
+ start)
|
|
52
|
+ start
|
|
53
|
+ ;;
|
|
54
|
+ stop)
|
|
55
|
+ stop
|
|
56
|
+ ;;
|
|
57
|
+ uninstall)
|
|
58
|
+ uninstall
|
|
59
|
+ ;;
|
|
60
|
+ retart)
|
|
61
|
+ stop
|
|
62
|
+ start
|
|
63
|
+ ;;
|
|
64
|
+ *)
|
|
65
|
+ echo "Usage: $0 {start|stop|restart|uninstall}"
|
|
66
|
+esac
|