diff options
author | Christian Pointner <equinox@anytun.org> | 2008-04-15 14:39:11 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2008-04-15 14:39:11 +0000 |
commit | 61ed673b08f83e371589213d0c748966d1c27021 (patch) | |
tree | caabc49f6cd5ecbee3072392f5f1679500ba9bc4 /etc/init.d | |
parent | added LSBize an Init Script (diff) |
initscript tabs2spaces
Diffstat (limited to 'etc/init.d')
-rwxr-xr-x | etc/init.d/anytun | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/etc/init.d/anytun b/etc/init.d/anytun index 0bb5f5d..b7193a1 100755 --- a/etc/init.d/anytun +++ b/etc/init.d/anytun @@ -23,81 +23,81 @@ test -x $DAEMON || exit 0 # Include anytun defaults if available if [ -f /etc/default/anytun ] ; then - . /etc/default/anytun + . /etc/default/anytun fi start_vpn () { - STATUS=OK - if [ -f $CONFIG_DIR/$NAME/config ] ; then - POSTUP='' - test -f $CONFIG_DIR/$NAME/post-up.sh && POSTUP="-x $CONFIG_DIR/$NAME/post-up.sh" - DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e '\w' | sed 's/^/ --/' | xargs echo` - $DAEMON --write-pid /var/run/anytun.$NAME.pid $POSTUP \ - $DAEMONOPTS $DAEMONARG || STATUS="FAILED" - else - STATUS="no config found" - fi - start_configd + STATUS=OK + if [ -f $CONFIG_DIR/$NAME/config ] ; then + POSTUP='' + test -f $CONFIG_DIR/$NAME/post-up.sh && POSTUP="-x $CONFIG_DIR/$NAME/post-up.sh" + DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e '\w' | sed 's/^/ --/' | xargs echo` + $DAEMON --write-pid /var/run/anytun.$NAME.pid $POSTUP \ + $DAEMONOPTS $DAEMONARG || STATUS="FAILED" + else + STATUS="no config found" + fi + start_configd echo -n "($STATUS)" } stop_vpn () { kill `cat $PIDFILE` || true rm $PIDFILE - stop_configd + 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 + 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 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 >> $VARCONFIG_DIR/$NAME - done - CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/'` - $CONTROLDAEMON -f $VARCONFIG_DIR/$NAME $DAEMONOPTS $CONTROLHOST \ - --write-pid $VARCONFIG_DIR/$NAME.pid - # rm -f $VARCONFIG_DIR/$NAME - fi + echo -n " ($CLIENTNAME)" + DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/conf.d/$CLIENTNAME | grep -e '\w' | sed 's/^/ --/' | xargs echo` + $ANYTUNCONFIG $DAEMONARG >> $VARCONFIG_DIR/$NAME + done + CONTROLHOST=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e 'control-host' | sed 's/^/ --/'` + $CONTROLDAEMON -f $VARCONFIG_DIR/$NAME $DAEMONOPTS $CONTROLHOST \ + --write-pid $VARCONFIG_DIR/$NAME.pid + # rm -f $VARCONFIG_DIR/$NAME + fi } stop_configd () { - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - echo -n " ($NAME)" - kill `cat $VARCONFIG_DIR/$NAME.pid` || true - rm $VARCONFIG_DIR/$NAME.pid - fi + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + echo -n " ($NAME)" + kill `cat $VARCONFIG_DIR/$NAME.pid` || true + rm $VARCONFIG_DIR/$NAME.pid + fi } set -e case "$1" in start) - echo -n "Starting $DESC: " - test -d $CHROOTDIR || mkdir -p $CHROOTDIR + echo -n "Starting $DESC: " + test -d $CHROOTDIR || mkdir -p $CHROOTDIR if test -z "$2" ; then - if [ -f $CONFIG_DIR/autostart ] ; then + if [ -f $CONFIG_DIR/autostart ] ; then for NAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do - echo -n "$NAME" + echo -n "$NAME" start_vpn done - else - echo "no config found" - exit 1; - fi - else - while shift ; do - if [ ! -z $1 ] ; then - NAME=$1 - echo -n "$NAME" - start_vpn - fi - done - fi - echo "." - ;; + else + echo "no config found" + exit 1; + fi + else + while shift ; do + if [ ! -z $1 ] ; then + NAME=$1 + echo -n "$NAME" + start_vpn + fi + done + fi + echo "." + ;; stop) - echo -n "Stoping $DESC: " + echo -n "Stoping $DESC: " if test -z "$2" ; then for PIDFILE in `ls /var/run/anytun.*.pid 2> /dev/null`; do NAME=`echo $PIDFILE | cut -c17-` @@ -117,22 +117,22 @@ case "$1" in else echo -n " (failure: No such tunnel is running: $1)" fi - done - fi - echo . - ;; + done + fi + echo . + ;; reload) if test -z "$2" ; then for PIDFILE in `ls /var/run/anytun.*.pid 2> /dev/null`; do NAME=`echo $PIDFILE | cut -c17-` NAME=${NAME%%.pid} - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - stop_vpn - start_vpn - else - stop_config - start_config - fi + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + stop_vpn + start_vpn + else + stop_config + start_config + fi echo -n " $NAME" done else @@ -143,21 +143,21 @@ case "$1" in NAME=`echo $PIDFILE | cut -c17-` NAME=${NAME%%.pid} echo -n " $NAME" - if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then - stop_vpn - start_vpn - else - stop_config - start_config - fi + if [ -d $CONFIG_DIR/$NAME/conf.d ] ; then + stop_vpn + start_vpn + else + stop_config + start_config + fi else echo -n " (failure: No such tunnel is running: $1)" fi - done - fi + done + fi ;; force-reload) - echo -n "Restarting $DESC: " + echo -n "Restarting $DESC: " if test -z "$2" ; then for PIDFILE in `ls /var/run/anytun.*.pid 2> /dev/null`; do NAME=`echo $PIDFILE | cut -c17-` @@ -165,7 +165,7 @@ case "$1" in echo -n " $NAME" stop_vpn sleep 1 - start_vpn + start_vpn done else while shift ; do @@ -176,26 +176,26 @@ case "$1" in NAME=${NAME%%.pid} echo -n " $NAME" stop_vpn - start_vpn + start_vpn else echo -n " (failure: No such tunnel is running: $1)" fi - done - fi - echo . - ;; + done + fi + echo . + ;; restart) - SCRIPT=$0 - shift - $SCRIPT stop $* - sleep 1 - $SCRIPT start $* - ;; + 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/$NAME + echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 + exit 1 + ;; esac exit 0 |