4
# Required-Start: $remote_fs $syslog $named
5
# Required-Stop: $remote_fs $syslog $named
6
# Default-Start: 2 3 4 5
8
# Short-Description: PageKite system service
9
# Description: PageKite makes localhost servers publicly visible.
12
# Authors: Bjarni R. Einarsson <bre@pagekite.net>
13
# Hrafnkell Eiriksson <he@klaki.net>
17
# PATH should only include /usr/* if it runs after the mountnfs.sh script
18
PATH=/sbin:/usr/sbin:/bin:/usr/bin
19
DESC="PageKite system service"
23
WRAPPER=/usr/bin/daemon
24
PIDFILE=/var/run/$NAME.pid
25
LOGFILE=/var/log/$NAME/$NAME.log
26
WRAPPER_PIDFILE=$PIDFILE.wrapper
27
WRAPPER_ARGS="--noconfig --unsafe --respawn --delay=60 --name=$NAME"
28
DAEMON_ARGS="--clean \
31
--optdir=/etc/$NAME.d"
32
SCRIPTNAME=/etc/init.d/$NAME
34
# Exit if the package is not installed
35
[ -x "$DAEMON" ] || exit 0
37
# Exit if package is unconfigured
38
grep -c ^abort_not_configured /etc/pagekite.d/10_account.rc \
39
2>/dev/null >/dev/null && exit 0
41
# Read configuration variable file if it is present
42
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
44
# Load the VERBOSE setting and other rcS variables
47
# Define LSB log_* functions.
48
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
49
. /lib/lsb/init-functions
52
# Function that starts the daemon/service
57
# 0 if daemon has been started
58
# 1 if daemon was already running
59
# 2 if daemon could not be started
61
chown $RUNAS $(dirname $LOGFILE) $LOGFILE
62
if [ -x $WRAPPER ]; then
63
start-stop-daemon --quiet --pidfile $WRAPPER_PIDFILE --test --start \
64
--startas $WRAPPER > /dev/null \
67
--quiet --pidfile $WRAPPER_PIDFILE --start --startas $WRAPPER -- \
68
--pidfile $WRAPPER_PIDFILE $WRAPPER_ARGS -- $DAEMON \
69
--pidfile $PIDFILE $DAEMON_ARGS --noloop \
72
start-stop-daemon --quiet --pidfile $PIDFILE --test --start \
73
--startas $DAEMON > /dev/null \
76
--quiet --pidfile $PIDFILE --start --startas $DAEMON -- \
77
--pidfile $PIDFILE --daemonize $DAEMON_ARGS \
80
# Add code here, if necessary, that waits for the process to be ready
81
# to handle requests from services started subsequently which depend
82
# on this one. As a last resort, sleep for some time.
86
# Function that stops the daemon/service
91
# 0 if daemon has been stopped
92
# 1 if daemon was already stopped
93
# 2 if daemon could not be stopped
94
# other if a failure occurred
95
if [ -e $WRAPPER_PIDFILE ]; then
96
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
97
--pidfile $WRAPPER_PIDFILE
99
WRAPPERS=$(ps axw |grep $WRAPPER |grep $DAEMON \
100
|grep $LOGFILE |cut -b1-5)
101
if [ "$WRAPPERS" = "" ]; then
102
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
106
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
107
--pidfile $PIDFILE --oknodo
111
[ "$RETVAL" = 2 ] && return 2
113
# Many daemons don't delete their pidfiles when they exit.
114
rm -f $PIDFILE $WRAPPER_PIDFILE
120
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
123
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
124
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
128
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
131
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
132
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
136
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
138
#reload|force-reload)
140
# If do_reload() is not implemented then leave this commented out
141
# and leave 'force-reload' as an alias for 'restart'.
143
#log_daemon_msg "Reloading $DESC" "$NAME"
147
restart|force-reload)
149
# If the "reload" option is implemented then remove the
150
# 'force-reload' alias
152
log_daemon_msg "Restarting $DESC" "$NAME"
159
1) log_end_msg 1 ;; # Old process is still running
160
*) log_end_msg 1 ;; # Failed to start
170
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2