diff options
author | Maxim Biro <nurupo.contributions@gmail.com> | 2014-01-19 00:43:31 -0500 |
---|---|---|
committer | Maxim Biro <nurupo.contributions@gmail.com> | 2014-01-19 04:34:58 -0500 |
commit | 28edc23329ff630a7ce3d594f2d972d47eb5c6f9 (patch) | |
tree | 2e9f77fe204670fe642ce841e735abc5dd8d7bf7 /other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh | |
parent | 91b06da0c3aa399edf7e00e33a8f380b42e44f43 (diff) |
Improved DHT bootstrap daemon
Supports "unlimited" number of bootstrap nodes in the config file, instead of
just 32.
PID and keys file paths are not limited by 512 chars anymore.
Doesn't read the whole list of bootstrap servers into a global datastructure
that just sits there after being processed once -- reads bootstrap servers
one by one, processing them between reads.
Supports IPv6.
Has an option for IPv6.
Supports LAN discovery.
Has an option for LAN discovery.
Writes to syslog.
Uses new functions introduced in the core.
`status` in the bash script now works.
Has a simple README, with instructions for Debian-based distros.
Diffstat (limited to 'other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh')
-rwxr-xr-x | other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh deleted file mode 100755 index 936bc808..00000000 --- a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.sh +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
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 | ||
14 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
15 | DESC="ProjectTox bootstrap server daemon" | ||
16 | NAME=DHT_bootstrap_daemon | ||
17 | CFG=/home/$USER/server.cfg | ||
18 | DAEMON=/home/$USER/$NAME | ||
19 | DAEMON_ARGS="$CFG" | ||
20 | PIDFILE=/home/$USER/.$NAME.pid | ||
21 | SCRIPTNAME=/etc/init.d/$NAME | ||
22 | |||
23 | # Exit if the package is not installed | ||
24 | [ -x "$DAEMON" ] || exit 0 | ||
25 | |||
26 | # Read configuration variable file if it is present | ||
27 | #[ -r /etc/default/$NAME ] && . /etc/default/$NAME | ||
28 | |||
29 | # Load the VERBOSE setting and other rcS variables | ||
30 | . /lib/init/vars.sh | ||
31 | |||
32 | # Define LSB log_* functions. | ||
33 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present | ||
34 | # and status_of_proc is working. | ||
35 | . /lib/lsb/init-functions | ||
36 | |||
37 | # | ||
38 | # Function that starts the daemon/service | ||
39 | # | ||
40 | do_start() | ||
41 | { | ||
42 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ | ||
43 | || return 1 | ||
44 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ | ||
45 | $DAEMON_ARGS \ | ||
46 | || return 2 | ||
47 | sleep 1 | ||
48 | } | ||
49 | |||
50 | # | ||
51 | # Function that stops the daemon/service | ||
52 | # | ||
53 | do_stop() | ||
54 | { | ||
55 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON | ||
56 | RETVAL="$?" | ||
57 | [ "$RETVAL" = 2 ] && return 2 | ||
58 | |||
59 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON | ||
60 | [ "$?" = 2 ] && return 2 | ||
61 | # Many daemons don't delete their pidfiles when they exit. | ||
62 | rm -f $PIDFILE | ||
63 | return "$RETVAL" | ||
64 | } | ||
65 | |||
66 | case "$1" in | ||
67 | start) | ||
68 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" | ||
69 | do_start | ||
70 | case "$?" in | ||
71 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | ||
72 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | ||
73 | esac | ||
74 | ;; | ||
75 | stop) | ||
76 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" | ||
77 | do_stop | ||
78 | case "$?" in | ||
79 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | ||
80 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | ||
81 | esac | ||
82 | ;; | ||
83 | status) | ||
84 | status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? | ||
85 | ;; | ||
86 | |||
87 | restart) #|force-reload) | ||
88 | log_daemon_msg "Restarting $DESC" "$NAME" | ||
89 | do_stop | ||
90 | case "$?" in | ||
91 | 0|1) | ||
92 | do_start | ||
93 | case "$?" in | ||
94 | 0) log_end_msg 0 ;; | ||
95 | 1) log_end_msg 1 ;; # Old process is still running | ||
96 | *) log_end_msg 1 ;; # Failed to start | ||
97 | esac | ||
98 | ;; | ||
99 | *) | ||
100 | # Failed to stop | ||
101 | log_end_msg 1 | ||
102 | ;; | ||
103 | esac | ||
104 | ;; | ||
105 | *) | ||
106 | echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2 | ||
107 | exit 3 | ||
108 | ;; | ||
109 | esac | ||