-
Notifications
You must be signed in to change notification settings - Fork 0
/
wub-daemon
executable file
·90 lines (80 loc) · 2 KB
/
wub-daemon
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
86
87
88
89
90
#! /bin/sh
#
# Start/Stop Wub server
#
set -x
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON_OPTS=""
DAEMON_VERBOSE=1
DESC="Wub Web Server"
TCLSH=/usr/bin/tclsh
STARTER="daemon"
HOME=/var/www/wub/Wub/
DAEMON=$HOME/Site.tcl
LOGDIR=/var/log/wub/
USER=www-data
# load defaults by service
NAME=`sed -e 's/-.*$//' <<EOF
$0
EOF`
NAME=`basename $NAME`
if [ $NAME = ""]; then
NAME="wub";
fi
# Include named defaults if available
if [ -f "/etc/default/$NAME" ] ; then
. /etc/default/$NAME
fi
if [ $HOME = ""]; then
HOME = `dirname $DAEMON`;
fi
set -e
ulimit -c 1000000
case "$1" in
start)
echo -n "Starting $DESC with $STARTER: "
if [ $STARTER = "daemon" ]; then
/usr/bin/daemon --name=$NAME --chdir=$HOME --dbglog=$LOGDIR/wub.daemon --user=$USER.$USER --umask=005 --respawn --inherit --core --verbose=$DAEMON_VERBOSE --debug=1 --errlog=$LOGDIR/wub.err --output=$LOGDIR/wub.out --command="$TCLSH $DAEMON $DAEMON_OPTS"
else
start-stop-daemon --start --quiet --background \
--chuid $USER:$USER \
--pidfile /var/run/$NAME.pid --make-pidfile \
--exec $TCLSH -- $DAEMON $DAEMON_OPTS
fi
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
if [ $STARTER = "daemon" ]; then
/usr/bin/daemon --user $USER.$USER --name=$NAME --stop
else
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--exec $TCLSH
fi
echo "$NAME."
;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo -n "Restarting $DESC: "
if [ $STARTER = "daemon" ]; then
/usr/bin/daemon --user $USER.$USER --name=$NAME --restart
else
start-stop-daemon --stop --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
fi
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac
exit 0