summaryrefslogtreecommitdiff
path: root/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh
diff options
context:
space:
mode:
Diffstat (limited to 'other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh')
-rwxr-xr-xother/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh111
1 files changed, 111 insertions, 0 deletions
diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh
new file mode 100755
index 00000000..d5e9d9c0
--- /dev/null
+++ b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh
@@ -0,0 +1,111 @@
1#! /bin/sh
2### BEGIN INIT INFO
3# Provides: DHT_bootstrap_daemon
4# Required-Start: $remote_fs $syslog
5# Required-Stop: $remote_fs $syslog
6# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6
8# Short-Description: Start the Tox bootstrapping server
9# Description: Use this piece of junk to start the Tox
10# bootstrap server.
11### END INIT INFO
12
13# PATH should only include /usr/* if it runs after the mountnfs.sh script
14PATH=/sbin:/usr/sbin:/bin:/usr/bin
15DESC="ProjectTox bootstrap server daemon"
16NAME=DHT_bootstrap_daemon
17CFG=/home/$USER/server.cfg
18DAEMON=/home/$USER/$NAME
19DAEMON_ARGS="$CFG"
20PIDFILE=/home/$USER/.$NAME.pid
21SCRIPTNAME=/etc/init.d/$NAME
22
23
24VERBOSE=yes
25# Exit if the package is not installed
26[ -x "$DAEMON" ] || exit 0
27
28# Read configuration variable file if it is present
29#[ -r /etc/default/$NAME ] && . /etc/default/$NAME
30
31# Load the VERBOSE setting and other rcS variables
32. /lib/init/vars.sh
33
34# Define LSB log_* functions.
35# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
36# and status_of_proc is working.
37. /lib/lsb/init-functions
38
39#
40# Function that starts the daemon/service
41#
42do_start()
43{
44 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
45 || return 1
46 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
47 $DAEMON_ARGS \
48 || return 2
49 sleep 1
50}
51
52#
53# Function that stops the daemon/service
54#
55do_stop()
56{
57 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
58 RETVAL="$?"
59 [ "$RETVAL" = 2 ] && return 2
60
61 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
62 [ "$?" = 2 ] && return 2
63 # Many daemons don't delete their pidfiles when they exit.
64 rm -f $PIDFILE
65 return "$RETVAL"
66}
67
68case "$1" in
69 start)
70 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
71 do_start
72 case "$?" in
73 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
74 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
75 esac
76 ;;
77 stop)
78 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
79 do_stop
80 case "$?" in
81 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
82 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
83 esac
84 ;;
85 status)
86 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
87 ;;
88
89 restart) #|force-reload)
90 log_daemon_msg "Restarting $DESC" "$NAME"
91 do_stop
92 case "$?" in
93 0|1)
94 do_start
95 case "$?" in
96 0) log_end_msg 0 ;;
97 1) log_end_msg 1 ;; # Old process is still running
98 *) log_end_msg 1 ;; # Failed to start
99 esac
100 ;;
101 *)
102 # Failed to stop
103 log_end_msg 1
104 ;;
105 esac
106 ;;
107 *)
108 echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
109 exit 3
110 ;;
111esac