10 |
10 |
### END INIT INFO
|
11 |
11 |
|
12 |
12 |
# Author: Brad Neuman <bradneuman@gmail.com>
|
|
13 |
# This is a decently big hack that runs a screen to run the tooltron script
|
13 |
14 |
|
14 |
15 |
# Do NOT "set -e"
|
15 |
16 |
|
... | ... | |
17 |
18 |
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
18 |
19 |
DESC="Tooltron Server"
|
19 |
20 |
NAME=tooltron
|
20 |
|
DAEMON=/usr/sbin/$NAME
|
21 |
|
#DAEMON_ARGS="--options args"
|
|
21 |
DAEMON=/usr/bin/screen
|
|
22 |
#/usr/sbin/$NAME
|
|
23 |
DAEMON_ARGS="-dmS tooltron /usr/sbin/runtron.sh"
|
22 |
24 |
PIDFILE=/var/run/$NAME.pid
|
23 |
25 |
SCRIPTNAME=/etc/init.d/$NAME
|
|
26 |
USER=tooltron
|
24 |
27 |
|
25 |
28 |
# Exit if the package is not installed
|
26 |
29 |
[ -x "$DAEMON" ] || exit 0
|
... | ... | |
44 |
47 |
# 0 if daemon has been started
|
45 |
48 |
# 1 if daemon was already running
|
46 |
49 |
# 2 if daemon could not be started
|
47 |
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
|
50 |
start-stop-daemon --start --quiet -c $USER --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
48 |
51 |
|| return 1
|
49 |
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
|
|
52 |
start-stop-daemon --start --quiet -c $USER --pidfile $PIDFILE --exec $DAEMON -- \
|
50 |
53 |
$DAEMON_ARGS \
|
51 |
54 |
|| return 2
|
52 |
55 |
# Add code here, if necessary, that waits for the process to be ready
|
... | ... | |
64 |
67 |
# 1 if daemon was already stopped
|
65 |
68 |
# 2 if daemon could not be stopped
|
66 |
69 |
# other if a failure occurred
|
67 |
|
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
|
|
70 |
start-stop-daemon --stop --quiet -u $USER
|
68 |
71 |
RETVAL="$?"
|
69 |
|
[ "$RETVAL" = 2 ] && return 2
|
70 |
|
# Wait for children to finish too if this is a daemon that forks
|
71 |
|
# and if the daemon is only ever run from this initscript.
|
72 |
|
# If the above conditions are not satisfied then add some other code
|
73 |
|
# that waits for the process to drop all resources that could be
|
74 |
|
# needed by services started subsequently. A last resort is to
|
75 |
|
# sleep for some time.
|
76 |
|
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
|
77 |
|
[ "$?" = 2 ] && return 2
|
78 |
|
# Many daemons don't delete their pidfiles when they exit.
|
|
72 |
# [ "$RETVAL" = 2 ] && return 2
|
|
73 |
# # Wait for children to finish too if this is a daemon that forks
|
|
74 |
# # and if the daemon is only ever run from this initscript.
|
|
75 |
# # If the above conditions are not satisfied then add some other code
|
|
76 |
# # that waits for the process to drop all resources that could be
|
|
77 |
# # needed by services started subsequently. A last resort is to
|
|
78 |
# # sleep for some time.
|
|
79 |
# start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
|
|
80 |
# [ "$?" = 2 ] && return 2
|
|
81 |
# # Many daemons don't delete their pidfiles when they exit.
|
79 |
82 |
rm -f $PIDFILE
|
80 |
83 |
return "$RETVAL"
|
81 |
84 |
}
|