/scripts/tuntox.debian-init (1501f9dab102b7b0d348fc3d0cecd3b050a2fbb4) (5158 bytes) (mode 100755) (type blob)
#!/bin/sh
### BEGIN INIT INFO
# Provides: tuntox
# Required-start: $network $syslog
# Required-stop: $network $syslog
# Default-start: 2 3 4 5
# Default-stop: 0 1 6
# Short-description: This script takes care of starting and stopping the Tutnox daemon.
# Description: tuntox is a daemon for tunnelling TCP connections over the Tox protocol
# Notes
# Modeled after init script for NSCA written by Ethan Galstad (nagios@nagios.org)
### END INIT INFO
#
# If you want to use tuntox as a system service, do the following:
# cp tuntox /usr/bin/
# cp scripts/tuntox.debian-init /etc/init.d/tuntox
# update-rc.d tuntox defaults
#
# Edit the User ID below (it needs to be a number in static builds)
#
# User ID to which the program will drop
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
# Exit if packages not installed
[ -x "$DAEMON" ] || exit 5
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
[ -x /lib/init/vars.sh ] && . /lib/init/vars.sh
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
mkdir -p /var/run/$NAME
chown $USERID /var/run/$NAME
#
# Function that starts the daemon/service
#
do_start()
{
# Return value
# 0 if daemon has been started
# 1 if daemon was already started
# 2 if daemon could not be started
# Test if daemon already exist
start-stop-daemon --test --start --quiet --pidfile $PIDFILE \
--exec $DAEMON > /dev/null \
|| return 1
# Start it if not
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--exec $DAEMON -- $DAEMON_ARGS \
|| return 2
# Add code here, if the process need to be ready to handle
# request form service that depend on it. At last resort,
# sleep some time.
sleep 1s
}
#
# Function that stop the dameon
#
do_stop() {
# Return value
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stop
# other if a failure occured
###
# When nsca exits, clean lock file.
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
# If process was already stop. Nothing to do. Exit with 1
[ "$RETVAL" = 1 ] && return 1
# If process could not be stop. Exit with 2
[ "$RETVAL" = 2 ] && return 2
# If the daemon is only run from initscript
# and forks, wait for children to finish.
# If this two condition are not satisfied the add code
# that waits for the process to drop all resources that
# could be needed by services started subsequently.
# At a last resort, sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemon do not delete their pidfiles when they exit
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon
#
do_reload()
{
#
# A basic reload function. Not used.
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 ;; # Failed to start. Fatal
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 ;; # Failed to stop. Fatal
esac
;;
#reload|force-reload)
# #
# # If do_reload() is not implemented then leave this comment out
# # and leave "force-reload" as an alias for "restart".
# #
# log_daemon_msg "Reloading $DESC" "$NAME"
# do_reload
# # Note : the basic do_reload always return 0
# log_end_msg "$?"
# ;;
restart|force-reload)
#
# If the "reload" option is implemented then remove
# the "force-reload" alias.
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 ;; # Old process still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
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|reload|force-reload|status}" >&2
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
exit 3
;;
esac
# ":" = "exit 0"
:
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
281 |
8b6eea76cbea14a93132b1ec7744f471c073041c |
.gitignore |
100644 |
blob |
2830 |
78666bbb9f73ac52929dcf8cdefd61ac6d98321c |
.travis.yml |
100644 |
blob |
951 |
5de078c758a1286082bab80e48f64d4783efe9bf |
BUILD.md |
100644 |
blob |
35058 |
2061be2b732ea86101a7c0d5f4df0bbbfb830a30 |
LICENSE.md |
100644 |
blob |
669 |
5e19d0a3ee2725091cd7c51900dffbec3ffc0997 |
Makefile |
100644 |
blob |
637 |
ee41cdaf376b4cb8eca51751b170e4c698167dda |
Makefile.mac |
100644 |
blob |
5180 |
1d97fd91128dcb82cde77c929d63e0b58e494bbe |
README.md |
100644 |
blob |
1697 |
ec1f8cf068b00049cdbdedc9966f5847e2767907 |
VPN.md |
100644 |
blob |
17181 |
bfcab148a15c7969c75aa029fb4274f70c92ae1e |
client.c |
100644 |
blob |
742 |
1ac50085e349329987ff615195ecfde70ab35088 |
client.h |
100644 |
blob |
176 |
52f9d71f3415d613e0cf73edd6d05a2a27fdfd8a |
gitversion.c |
100644 |
blob |
2085 |
acb45b84f5abf7ead93318f1680d0a3af1bdc070 |
log.c |
100644 |
blob |
686 |
ed48364b9e8c9451c3ca334e6397e0b67a1040b1 |
log.h |
100644 |
blob |
549 |
a9095f6b9cc0f97ddc698e07a4606b37822ba61c |
mach.c |
100644 |
blob |
287 |
5ac9a4e29fbb831ba2cfa6dc98589ffaf381b91b |
mach.h |
100644 |
blob |
35606 |
0535e675d5c4b7a1890d4cf09347c9ac5ffa8300 |
main.c |
100644 |
blob |
2680 |
41a7995d316fd42860b12143a1feda8f6c6a250b |
main.h |
040000 |
tree |
- |
9fc0b45bf62d115143aae3926e70bbb221d1d982 |
scripts |
100644 |
blob |
7328 |
0bae45515dbb84b4c394de71dff04571edde7c4c |
tox_bootstrap.h |
100644 |
blob |
12536 |
75e9dc5ed9399120416e8da5f24d1ccde41cf901 |
utarray.h |
100644 |
blob |
61492 |
7205c67efa27c66884c8d4d1c8a105d4854a0548 |
uthash.h |
100644 |
blob |
4006 |
a2f60deeed5ba62684753f2aef363d06ff76ded2 |
util.c |
100644 |
blob |
464 |
1a210d51a11eb6983a2984eec1443bd6d5c8006e |
util.h |
100644 |
blob |
55882 |
b5f3f04c104785a57d8280c37c1b19b36068e56e |
utlist.h |
100644 |
blob |
11555 |
867442c843dbe6bf096a488e3ce9ec6323809f7f |
utstring.h |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/gdr/tuntox
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/gdr/tuntox
Clone this repository using git:
git clone git://git.rocketgit.com/user/gdr/tuntox
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main