summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2016-07-07 22:48:58 +0200
committerChristian Pointner <equinox@anytun.org>2016-07-07 22:48:58 +0200
commit2c3c2955a29135ecc2a7920c9816bc8ccd0f9086 (patch)
tree34c537ad3da97a302bd41362c4e8179879ea8fcb /etc
parentadded some privilege limitations to sample systemd services (diff)
streamlined systemd integration/installation
Diffstat (limited to 'etc')
-rwxr-xr-xetc/init.d/anytun227
-rw-r--r--etc/tmpfiles.d/anytun.conf2
2 files changed, 114 insertions, 115 deletions
diff --git a/etc/init.d/anytun b/etc/init.d/anytun
index aa5f0af..6ecfb26 100755
--- a/etc/init.d/anytun
+++ b/etc/init.d/anytun
@@ -9,22 +9,24 @@
# Description: Enables networking over vpn tunnel interfaces
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-ANYTUNLAUNCHER=/usr/bin/anytun-launcher.sh
-NAME=anytun
-DESC=anytun
-CONFIG_DIR=/etc/anytun
-VARCONFIG_DIR=/var/run/anytun-controld
-VARRUN_DIR=/var/run/$NAME/
+DAEMON=anytun
+LAUNCHER=/usr/local/bin/$DAEMON-launcher.sh
+DESC=secure anycast tunneling daemon
+CONFIG_DIR=/usr/local/etc/$DAEMON
+VARCONTROL_DIR=/var/run/$DAEMON-controld
+VARRUN_DIR=/var/run/$DAEMON/
# Include anytun defaults if available
if [ -f /etc/default/anytun ] ; then
. /etc/default/anytun
fi
+. /lib/lsb/init-functions
+
start_vpn () {
STATUS="OK"
- if [ -f $CONFIG_DIR/$NAME/config ] ; then
- $ANYTUNLAUNCHER vpn || STATUS="FAILED"
+ if [ -f $CONFIG_DIR/$1/config ] ; then
+ $LAUNCHER vpn $1 || STATUS="FAILED"
else
STATUS="no config found"
fi
@@ -38,143 +40,142 @@ stop_vpn () {
}
start_configd () {
- $ANYTUNLAUNCHER configd
+ $LAUNCHER configd $1
}
stop_configd () {
- if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then
- echo -n " ($NAME-controlld)"
- kill `cat $VARCONFIG_DIR/$NAME.pid` || true
- rm $VARCONFIG_DIR/$NAME.pid
- fi
+ if [ -d $CONFIG_DIR/$1/conf.d ] ; then
+ echo -n " ($1-controlld)"
+ kill `cat $VARCONTROL_DIR/$1.pid` || true
+ rm $VARCONTROL_DIR/$1.pid
+ fi
}
set -e
case "$1" in
start)
- echo -n "Starting $DESC:"
- if test -z "$2" ; then
- if [ -f $CONFIG_DIR/autostart ] ; then
- for NAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do
- echo -n " $NAME"
- start_vpn
- done
+ echo -n "Starting $DESC:"
+ if test -z "$2" ; then
+ if [ -f $CONFIG_DIR/autostart ] ; then
+ for NAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do
+ echo -n " $NAME"
+ start_vpn $NAME
+ done
+ else
+ echo "no config found"
+ exit 1;
+ fi
else
- echo "no config found"
- exit 1;
+ while shift ; do
+ [ -z "$1" ] && break
+ echo -n " $1"
+ start_vpn $1
+ done
fi
- else
- while shift ; do
- [ -z "$1" ] && break
- NAME=$1
- echo -n " $NAME"
- start_vpn
- done
- fi
- echo "."
- ;;
+ echo "."
+ ;;
stop)
- echo -n "Stoping $DESC:"
- if test -z "$2" ; then
- for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do
- NAME=`basename $PIDFILE`
- NAME=${NAME%%.pid}
- echo -n " $NAME"
- stop_vpn
- done
- else
- while shift ; do
- [ -z "$1" ] && break
- if test -e $VARRUN_DIR/$1.pid ; then
- PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null`
+ echo -n "Stoping $DESC:"
+ if test -z "$2" ; then
+ for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do
NAME=`basename $PIDFILE`
NAME=${NAME%%.pid}
echo -n " $NAME"
- stop_vpn
- else
- echo -n " (failure: No such tunnel is running: $1)"
- fi
- done
- fi
- echo "."
- ;;
+ stop_vpn $NAME
+ done
+ else
+ while shift ; do
+ [ -z "$1" ] && break
+ if test -e $VARRUN_DIR/$1.pid ; then
+ PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null`
+ NAME=`basename $PIDFILE`
+ NAME=${NAME%%.pid}
+ echo -n " $NAME"
+ stop_vpn $NAME
+ else
+ echo -n " (failure: No such tunnel is running: $1)"
+ fi
+ done
+ fi
+ echo "."
+ ;;
reload)
- echo -n "Reloading $DESC:"
- if test -z "$2" ; then
- for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do
- NAME=`basename $PIDFILE`
- NAME=${NAME%%.pid}
- echo -n " $NAME"
- if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then
- stop_vpn
- start_vpn
- else
- stop_configd
- start_configd
- fi
- done
- else
- while shift ; do
- [ -z "$1" ] && break
- if test -e $VARRUN_DIR/$1.pid ; then
- PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null`
+ echo -n "Reloading $DESC:"
+ if test -z "$2" ; then
+ for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do
NAME=`basename $PIDFILE`
NAME=${NAME%%.pid}
echo -n " $NAME"
if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then
- stop_vpn
- start_vpn
+ stop_vpn $NAME
+ start_vpn $NAME
else
- stop_configd
- start_configd
+ stop_configd $NAME
+ start_configd $NAME
fi
- else
- echo -n " (failure: No such tunnel is running: $1)"
- fi
- done
- fi
- echo "."
- ;;
+ done
+ else
+ while shift ; do
+ [ -z "$1" ] && break
+ if test -e $VARRUN_DIR/$1.pid ; then
+ PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null`
+ NAME=`basename $PIDFILE`
+ NAME=${NAME%%.pid}
+ echo -n " $NAME"
+ if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then
+ stop_vpn $NAME
+ start_vpn $NAME
+ else
+ stop_configd $NAME
+ start_configd $NAME
+ fi
+ else
+ echo -n " (failure: No such tunnel is running: $1)"
+ fi
+ done
+ fi
+ echo "."
+ ;;
force-reload)
- echo -n "Restarting $DESC:"
- if test -z "$2" ; then
- for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do
- NAME=`basename $PIDFILE`
- NAME=${NAME%%.pid}
- echo -n " $NAME"
- stop_vpn
- sleep 1
- start_vpn
- done
- else
- while shift ; do
- [ -z "$1" ] && break
- if test -e $VARRUN_DIR/$1.pid ; then
- PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null`
+ echo -n "Restarting $DESC:"
+ if test -z "$2" ; then
+ for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do
NAME=`basename $PIDFILE`
NAME=${NAME%%.pid}
echo -n " $NAME"
- stop_vpn
+ stop_vpn $NAME
sleep 1
- start_vpn
- else
- echo -n " (failure: No such tunnel is running: $1)"
- fi
- done
- fi
- echo "."
- ;;
+ start_vpn $NAME
+ done
+ else
+ while shift ; do
+ [ -z "$1" ] && break
+ if test -e $VARRUN_DIR/$1.pid ; then
+ PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null`
+ NAME=`basename $PIDFILE`
+ NAME=${NAME%%.pid}
+ echo -n " $NAME"
+ stop_vpn $NAME
+ sleep 1
+ start_vpn $NAME
+ else
+ echo -n " (failure: No such tunnel is running: $1)"
+ fi
+ done
+ fi
+ echo "."
+ ;;
restart)
SCRIPT=$0
shift
$SCRIPT stop $*
sleep 1
$SCRIPT start $*
- ;;
+ ;;
*)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
- exit 1
- ;;
+ N=/etc/init.d/$DAEMON
+ echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+ exit 1
+ ;;
esac
exit 0
diff --git a/etc/tmpfiles.d/anytun.conf b/etc/tmpfiles.d/anytun.conf
deleted file mode 100644
index c685cdd..0000000
--- a/etc/tmpfiles.d/anytun.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-d /run/anytun-controld 0700 anytun anytun -
-d /run/anytun/ 0700 anytun anytun -