Hello, OpenVPN developers!

 I was advised to send you this shell, and I hope this can be helpful

Afanasyev Nikolay
afanasye...@unc.ru
 

> -----Original Message-----
> From: James Yonan [mailto:j...@yonan.net] 
> Sent: Thursday, December 02, 2004 7:21 PM
> To: Николай Афанасьев
> Subject: Re: Init script/Debian for OpenVPN
> 
> Thanks for your contribution.
> 
> It would be best if you send it to openvpn-devel@lists.sourceforge.net
> 
> Thanks,
> James
> 
> On Thu, 2 Dec 2004, [koi8-r] Николай Афанасьев wrote:
> 
> > Hello, James 
> >     Can I contribute a little to your project? I have init 
> script for Debian GNU Linux that I wrote for OpenVPN: 
> > 
> > PS: sorry bout permissions 8-)
> > 
> > >>>>>>>>>>>> Start openvpn.sh >>>>>>>>>>>>>>>>>>

#!/bin/sh

DAEMON="/usr/local/sbin/openvpn"
piddir="/var/run/openvpn"
work=/etc/openvpn
export LANG=C
export PATH

test -f $DAEMON || exit 0



case "$1" in
  start)
    cd $work
    # Start every .conf in $work and run .sh if exists
    for c in `/bin/ls *.conf 2>/dev/null`; do
      bn=${c%%.conf}
      echo -n "Starting OpenVPN whith config $c"
      args="--daemon --writepid $piddir/$bn.pid --config $c --cd $work"
      start-stop-daemon --start --pidfile $piddir/$bn.pid --exec $DAEMON -- 
$args
      if [ $? == 0 ]; then 
       echo " [OK]" 
      else 
       echo " [failed]" 
      fi 
    done
    ;;

  stop)
    for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do
      if [ -s $pidf ]; then
        echo -n  "Shuttin' down OpenVPN whith PID file $pidf"
        start-stop-daemon --stop --pidfile $pidf --oknodo --exec $DAEMON  
        if [ $? == 0 ]; then 
          echo " [OK]" 
        else 
          echo " [failed]" 
        fi
        rm -f $pidf
      fi
    done
    ;;

  reload)
    for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do
      if [ -s $pidf ]; then
        echo -n "Reload OpenVPN whith PID file $pidf"
        start-stop-daemon --stop --pidfile $pidf --signal USR1 --exec $DAEMON  
        if [ $? == 0 ]; then 
          echo " [OK]" 
        else 
          echo " [failed]" 
        fi
      fi
    done
    ;;

  restart)
    $0 stop
    $0 start
    exit $?
    ;;

  *)
    echo "Usage: $0 {start|stop|reload|restart}"
    exit 1
    ;;
esac

if [ $? == 0 ]; then 
 exit 0
else 
 exit 1 
fi


> > <<<<<<<<<<<< End openvpn.sh  <<<<<<<<<<<<<<<<<<
> > 
> > 
> > 
> > 
> > Afanasyev Nikolay
> > afanasye...@unc.ru
> > 
> > 
> 
> 
> 

Reply via email to