123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- #!/bin/sh
- USERID=13
- DESC="TCP-over-Tox daemon"
- NAME=tuntox
- DAEMON=/usr/bin/$NAME
- DAEMON_CFG_DIR=/etc/tuntox/
- PIDFILE=/var/run/$NAME/$NAME.pid
- DAEMON_ARGS="-C $DAEMON_CFG_DIR -D -F $PIDFILE -U $USERID -d"
- SCRIPTNAME=/etc/init.d/$NAME
- [ -x "$DAEMON" ] || exit 5
- [ -r /etc/default/$NAME ] && . /etc/default/$NAME
- [ -x /lib/init/vars.sh ] && . /lib/init/vars.sh
- . /lib/init/vars.sh
- . /lib/lsb/init-functions
- mkdir -p /var/run/$NAME
- chown $USERID /var/run/$NAME
- do_start()
- {
-
-
-
-
-
- start-stop-daemon --test --start --quiet --pidfile $PIDFILE \
- --exec $DAEMON > /dev/null \
- || return 1
-
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
- --exec $DAEMON -- $DAEMON_ARGS \
- || return 2
-
-
-
- sleep 1s
- }
- do_stop() {
-
-
-
-
-
-
-
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
- RETVAL="$?"
-
- [ "$RETVAL" = 1 ] && return 1
-
- [ "$RETVAL" = 2 ] && return 2
-
-
-
-
-
-
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
- [ "$?" = 2 ] && return 2
-
- rm -f $PIDFILE
- return "$RETVAL"
- }
- do_reload()
- {
-
-
- start-stop-daemon --stop --quiet --signal 1 --pidfile $PIDFILE --name $NAME
- return 0
- }
- case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- *) log_end_msg 1 ;;
- esac
- ;;
- stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- *) log_end_msg 1 ;;
- esac
- ;;
-
-
-
-
-
-
-
-
-
-
- restart|force-reload)
-
-
-
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;;
- *) log_end_msg 1 ;;
- esac
- ;;
- *)
-
- log_end_msg 1
- ;;
- esac
- ;;
- status)
- log_daemon_msg "Checking status of $DESC" "$NAME"
- status_of_proc -p $PIDFILE "$DAEMON" "$NAME"
- log_end_msg "$?"
- exit $?
- ;;
- *)
-
- echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
- exit 3
- ;;
- esac
- :
|