diff options
author | Francesco Colista <fcolista@alpinelinux.org> | 2016-08-22 07:28:39 +0000 |
---|---|---|
committer | Francesco Colista <fcolista@alpinelinux.org> | 2016-08-22 07:28:39 +0000 |
commit | 55738ff3967d067c059212161b02a8b9c2d04108 (patch) | |
tree | d606c38f8e8e99f1faab353a8aecf754d2435d0f /testing/anytun/anytun.initd | |
parent | e1858a4746c3817c4b0f36464548655c637d3e86 (diff) | |
download | aports-55738ff3967d067c059212161b02a8b9c2d04108.tar.bz2 aports-55738ff3967d067c059212161b02a8b9c2d04108.tar.xz |
community/anytun: moved from testing
Diffstat (limited to 'testing/anytun/anytun.initd')
-rw-r--r-- | testing/anytun/anytun.initd | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/testing/anytun/anytun.initd b/testing/anytun/anytun.initd deleted file mode 100644 index 0767a73802..0000000000 --- a/testing/anytun/anytun.initd +++ /dev/null @@ -1,155 +0,0 @@ -#!/sbin/openrc-run -# Distributed under the terms of the GNU General Public License v3 -# Written by Bernhard Tittelbach based on examples from Gentoo, openvpn and anytun debian init.rd script - -opts="${opts} reload" -depend() { - need net - use dns - after bootmisc -} - -DAEMON=/usr/sbin/anytun -ANYTUNCONFIG=/usr/bin/anytun-config -CONTROLDAEMON=/usr/bin/anytun-controld -NAME=anytun -DESC=anytun -CONFIG_DIR=/etc/anytun -VARCONFIG_DIR=/var/run/anytun-controld -VARRUN_DIR=/var/run/anytun - -VPN=${SVCNAME#*.} -[ "$VPN" = "$SVCNAME" ] && VPN="" - -# Include anytun defaults if available -if [ -f /etc/conf.d/anytun ] ; then - . /etc/conf.d/anytun -fi - -test -x $DAEMON || exit 1 - - -start_vpn () { - if [ -f $CONFIG_DIR/$NAME/config ] ; then - POSTUP='' - test -f $CONFIG_DIR/$NAME/post-up.sh && POSTUP="-x $CONFIG_DIR/$NAME/post-up.sh" - CHROOTDIR=`grep '^chroot' < $CONFIG_DIR/$NAME/config | sed 's/chroot\s*//'` - if [ -n "$CHROOTDIR" ] ; then - test -d $CHROOTDIR || mkdir -p $CHROOTDIR - fi - test -d $VARRUN_DIR || mkdir -p $VARRUN_DIR - DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e '\w' | sed 's/^/--/' | tr '\n' ' '` - start-stop-daemon --start --pidfile $VARRUN_DIR/${NAME}.pid --exec $DAEMON -- --write-pid $VARRUN_DIR/${NAME}.pid $POSTUP \ - $DAEMONOPTS $DAEMONARG || return 1 - else - eerror "no config found" - return 1 - fi - start_configd - return 0 -} -stop_vpn () { - start-stop-daemon --stop --pidfile $PIDFILE --exec $DAEMON - rm -f $PIDFILE - stop_configd -} - -start_configd () { - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - test -d $VARCONFIG_DIR || mkdir -p $VARCONFIG_DIR - chmod 700 $VARCONFIG_DIR - rm -f $VARCONFIG_DIR/$NAME 2>/dev/null - KDPRF=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'kd-prf' | sed 's/^/ --/' | xargs echo` - for CLIENTPATH in $CONFIG_DIR/$NAME/conf.d/* ; do - DAEMONARG=`sed 's/#.*//' < $CLIENTPATH | grep -e '\w' | sed 's/^/ --/' | xargs echo` - $ANYTUNCONFIG $DAEMONARG $CIPHER $AUTHALGO $KDPRF >> $VARCONFIG_DIR/$NAME - done - CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/'i | xargs echo` - start-stop-daemon --start --pidfile $VARCONFIG_DIR/${NAME}.pid --exec $CONTROLDAEMON \ - -- -f $VARCONFIG_DIR/$NAME $DAEMONOPTS $CONTROLHOST --write-pid $VARCONFIG_DIR/${NAME}.pid - fi -} -stop_configd () { - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - start-stop-daemon --stop --pidfile $VARCONFIG_DIR/${NAME}.pid --exec $CONTROLDAEMON - rm -f $VARCONFIG_DIR/${NAME}.pid - fi -} - -start () { - if test -z "$VPN" ; then - if [ -f $CONFIG_DIR/autostart ] ; then - for NAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do - ebegin "Starting ${DESC} VPN: ${NAME}" - start_vpn - eend $? - done - else - eerror "no config found" - return 1; - fi - else - NAME="$VPN" - ebegin "Starting ${DESC} VPN: ${NAME}" - start_vpn - eend $? - fi -} - -stop () { - if test -z "$VPN" ; then - for PIDFILE in ${VARRUN_DIR}/*.pid ; do - NAME=`basename $PIDFILE .pid` - ebegin "Stopping ${DESC} VPN: ${NAME}" - stop_vpn - eend $? - done - else - if test -e ${VARRUN_DIR}/${VPN}.pid ; then - PIDFILE=${VARRUN_DIR}/${VPN}.pid - NAME=`basename $PIDFILE .pid` - ebegin "Stopping ${DESC} VPN: ${NAME}" - stop_vpn - eend $? - else - eerror " failure: No such tunnel is running: $VPN" - fi - fi -} - -reload () { - if test -z "$VPN" ; then - for PIDFILE in ${VARRUN_DIR}/*.pid ; do - NAME=`basename $PIDFILE .pid` - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - ebegin "Reloading ${DESC} VPN: ${NAME}" - stop_vpn - start_vpn - eend $? - else - ebegin "Reloading ${DESC} VPN: ${NAME}" - stop_configd - start_configd - eend $? - fi - done - else - if test -e ${VARRUN_DIR}/${VPN}.pid ; then - PIDFILE=${VARRUN_DIR}/${VPN}.pid - NAME=`basename $PIDFILE .pid` - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - ebegin "Reloading ${DESC} VPN: ${NAME}" - stop_vpn - start_vpn - eend $? - else - ebegin "Reloading ${DESC} VPN: ${NAME}" - stop_configd - start_configd - eend $? - fi - else - eerror "failure: No such tunnel is running: $VPN" - fi - fi -} |