[OpenVPN home] [Date Prev] [Date Index] [Date Next]
[OpenVPN mailing lists] [Thread Prev] [Thread Index] [Thread Next]
Google
 
Web openvpn.net

Re: [Openvpn-users] Start OpenVPN


  • Subject: Re: [Openvpn-users] Start OpenVPN
  • From: Giancarlo Razzolini <linux-fan@xxxxxxxxxxx>
  • Date: Thu, 02 Jun 2005 13:12:39 -0300

Irek SÅonina wrote:
> Paulo Andre wrote:
> 
>>Trying to start openvpn from within '/etc/rc.d/' but 'openvpn --config
>>/etc/vpn.conf', will not work.
>>Looks like the 'openvpn' will not accept a path to the file.
>>Any suggestions.
>>
> 
> 
> openvpn --daemon --writepid "/var/run/openvpn/$tun.pid" \
>                                 --config "/etc/openvpn/$tun.conf" \
> 				--cd /etc/openvpn
> 
> (from a PLD openvpn init script)
> 
> 
> Regards,
> Irek SÅonina
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=fad-ysdn-ostg-q22005
> _______________________________________________
> Openvpn-users mailing list
> Openvpn-users@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/openvpn-users
> 
I'm attaching an script that i made for my slackware, because it didn't
had one. There are some verifications that it doesn't do, but for the
average it works. Fell free to use and modify it.
You should also put these line on the file /etc/rc.d/rc.ine2 if you use
slackware:
# Start the Openvpn Tunnels:
if [ -x /etc/rc.d/rc.openvpn ]; then
  /etc/rc.d/rc.openvpn start
fi

If not, you can use only my script, and as said, fell free to modify.

-- 
Giancarlo Razzolini
Linux User 172199
Moleque Sem Conteudo Numero #002
Slackware Current
Snike Tecnologia em InformÃtica
4386 2A6F FFD4 4D5F 5842  6EA0 7ABE BBAB 9C0E 6B85
#!/bin/sh
# Start/stop/restart all the openvpn processes
#by Giancarlo Razzolini

#openvpn binary
openvpn=/usr/sbin/openvpn
#piddir
piddir=/var/run/openvpn
#conf dir
confdir=/etc/openvpn

#Let us check if the binary exists
if [ ! -f $openvpn -o ! -x $openvpn ] ; then
    echo "Openvpn binary not found or is not executable."
    exit 1
fi

openvpn_start() {
    #for all the conf files in the openvpn dir, start a new process
    cd $confdir
    echo "Starting Openvpn Tunnels:"
    for conf in `ls *.conf` ; do
	echo -e "\t$openvpn $confdir/$conf"
	$openvpn --writepid /var/run/openvpn/`echo $conf | cut -d. -f1`.pid --daemon --config $conf 
    done
    return 0
}

openvpn_status() {
    cd $piddir
    ls *.pid 1&>2 /dev/null
    if [ "$?" != "0" ] ; then
	echo "No openvpn process is running."
    else
	for process in `ls *.pid` ; do
	    echo Process `cat $process` is running...
	done
    fi
    return 0
}

openvpn_stop() {
    echo "Stoping Openvpn Tunnels"
    killall openvpn 2&>1 /dev/null
    rm -rf $piddir/*.pid
    return 0
}

openvpn_restart() {
    openvpn_stop
    sleep 1
    openvpn_start
}
    
case "$1" in
'start')
	openvpn_start
	;;
'status')
	openvpn_status
	;;
'stop')
	openvpn_stop
  ;;
'restart')
	openvpn_restart
	;;
    *)
	echo "usage $0 start|stop|restart"
esac

Attachment: signature.asc
Description: OpenPGP digital signature