From e88a0d5fcbb8bad848080716b96d3a5cf72fb62f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 8 Jul 2016 00:17:10 +0200 Subject: moved anytun-lanucher to /lib --- usr/bin/anytun-launcher.sh | 62 -------------------------- usr/lib/anytun-launcher | 62 ++++++++++++++++++++++++++ usr/lib/systemd/system/anytun-control@.service | 2 +- usr/lib/systemd/system/anytun@.service | 2 +- 4 files changed, 64 insertions(+), 64 deletions(-) delete mode 100755 usr/bin/anytun-launcher.sh create mode 100755 usr/lib/anytun-launcher (limited to 'usr') diff --git a/usr/bin/anytun-launcher.sh b/usr/bin/anytun-launcher.sh deleted file mode 100755 index 60773fd..0000000 --- a/usr/bin/anytun-launcher.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -NAME="${NAME:-$2}" - -DAEMON=/usr/local/sbin/anytun -ANYTUNCONFIG=/usr/local/bin/anytun-config -CONTROLDAEMON=/usr/local/bin/anytun-controld -CONFIG_DIR=/usr/local/etc/anytun -VARRUN_DIR=/run/anytun -VARCONTROL_DIR=/run/anytun-controld - -test -x $DAEMON || exit 0 -test -z $NAME && 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' ' '` - $DAEMON --write-pid $VARRUN_DIR/$NAME.pid $POSTUP $DAEMONOPTS $DAEMONARG - else - echo "no config found" >&2 - return 1 - fi -} - -start_configd () { - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - test -d $VARCONTROL_DIR || mkdir -p $VARCONTROL_DIR - chmod 700 $VARCONTROL_DIR - rm -f $VARCONTROL_DIR/$NAME 2>/dev/null - KDPRF=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'kd-prf' | sed 's/^/ --/' | xargs echo` - for CLIENTNAME in `ls $CONFIG_DIR/$NAME/conf.d`; do - echo -n " ($CLIENTNAME)" - DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/conf.d/$CLIENTNAME | grep -e '\w' | sed 's/^/ --/' | xargs echo` - $ANYTUNCONFIG $DAEMONARG $CIPHER $AUTHALGO $KDPRF >> $VARCONTROL_DIR/$NAME - done - CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/' | xargs echo` - $CONTROLDAEMON -f $VARCONTROL_DIR/$NAME $DAEMONOPTS $CONTROLHOST \ - --write-pid $VARCONTROL_DIR/$NAME.pid - else - echo "no conf.d directory found (maybe $NAME is an anytun client not a server?)" >&2 - return 1 - fi -} - -case $1 in - vpn) - start_vpn - ;; - configd) - start_configd - ;; - *) - exit 2 - ;; -esac diff --git a/usr/lib/anytun-launcher b/usr/lib/anytun-launcher new file mode 100755 index 0000000..60773fd --- /dev/null +++ b/usr/lib/anytun-launcher @@ -0,0 +1,62 @@ +#!/bin/sh + +NAME="${NAME:-$2}" + +DAEMON=/usr/local/sbin/anytun +ANYTUNCONFIG=/usr/local/bin/anytun-config +CONTROLDAEMON=/usr/local/bin/anytun-controld +CONFIG_DIR=/usr/local/etc/anytun +VARRUN_DIR=/run/anytun +VARCONTROL_DIR=/run/anytun-controld + +test -x $DAEMON || exit 0 +test -z $NAME && 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' ' '` + $DAEMON --write-pid $VARRUN_DIR/$NAME.pid $POSTUP $DAEMONOPTS $DAEMONARG + else + echo "no config found" >&2 + return 1 + fi +} + +start_configd () { + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + test -d $VARCONTROL_DIR || mkdir -p $VARCONTROL_DIR + chmod 700 $VARCONTROL_DIR + rm -f $VARCONTROL_DIR/$NAME 2>/dev/null + KDPRF=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'kd-prf' | sed 's/^/ --/' | xargs echo` + for CLIENTNAME in `ls $CONFIG_DIR/$NAME/conf.d`; do + echo -n " ($CLIENTNAME)" + DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/conf.d/$CLIENTNAME | grep -e '\w' | sed 's/^/ --/' | xargs echo` + $ANYTUNCONFIG $DAEMONARG $CIPHER $AUTHALGO $KDPRF >> $VARCONTROL_DIR/$NAME + done + CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/' | xargs echo` + $CONTROLDAEMON -f $VARCONTROL_DIR/$NAME $DAEMONOPTS $CONTROLHOST \ + --write-pid $VARCONTROL_DIR/$NAME.pid + else + echo "no conf.d directory found (maybe $NAME is an anytun client not a server?)" >&2 + return 1 + fi +} + +case $1 in + vpn) + start_vpn + ;; + configd) + start_configd + ;; + *) + exit 2 + ;; +esac diff --git a/usr/lib/systemd/system/anytun-control@.service b/usr/lib/systemd/system/anytun-control@.service index 014dba4..e8a2289 100644 --- a/usr/lib/systemd/system/anytun-control@.service +++ b/usr/lib/systemd/system/anytun-control@.service @@ -7,7 +7,7 @@ Requires=anytun@%i.service Type=simple PIDFile=/run/anytun-controld/%i.pid Environment="NAME=%i" "DAEMONOPTS=-D -L stdout:3 --username anytun" -ExecStart=/usr/local/bin/anytun-launcher.sh configd +ExecStart=/usr/local/lib/anytun-launcher configd Restart=on-failure PrivateTmp=yes PrivateDevices=yes diff --git a/usr/lib/systemd/system/anytun@.service b/usr/lib/systemd/system/anytun@.service index aa7f32b..70fbd17 100644 --- a/usr/lib/systemd/system/anytun@.service +++ b/usr/lib/systemd/system/anytun@.service @@ -6,7 +6,7 @@ After=syslog.target network.target Type=simple PIDFile=/run/anytun/%i.pid Environment="NAME=%i" "DAEMONOPTS=-D -L stdout:3 --username anytun" -ExecStart=/usr/local/bin/anytun-launcher.sh vpn +ExecStart=/usr/local/lib/anytun-launcher vpn Restart=on-failure PrivateTmp=yes PrivateDevices=yes -- cgit v1.2.3