#!/sbin/runscript # Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 ## recupere l'ip du peer peer=$(/sbin/ifconfig ppp0 | /bin/grep "P-t-P" | /usr/bin/cut -d":" -f3 | /usr/bin/cut -d" " -f1) vpnew="/etc/openvpn/euroweb.conf" vpnnosf="/etc/openvpn/openvpn.conf" vpndir="/etc/openvpn" pidew="/var/run/openvpn.ew.pid" pidnos="/var/run/openvpn.nos.pid" echo $peer echo $vpnew echo $vpnnosf ip route add 81.93.243.132/32 via ${peer} ip route add 81.93.247.160/32 via ${peer} echo `route -n` depend() { need localmount net before netmount after bootmisc } checktundevice() { if [ ! -e /dev/net/tun ]; then if ! modprobe tun ; then eerror "TUN/TAP support is not available in this kernel" return 1 fi fi if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then ebegin "Detected broken /dev/net/tun symlink, fixing..." rm -f /dev/net/tun ln -s /dev/misc/net/tun /dev/net/tun eend $? fi } start() { ebegin "Starting euroweb" if [ ! -e "${vpnew}" ]; then eend 1 "${vpnew} does not exist" return 1 fi if ! grep -q "^[ \t]*cd[ \t].*" "${vpnew}" ; then args="${args} --cd ${vpndir}" fi start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${pidew}" \ -- --config "${vpnew}" --writepid "${pidew}" --daemon ${args} if ! grep -q "^[ \t]*cd[ \t].*" "${vpnnosf}" ; then args="${args} --cd ${vpndir}" fi start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${pidnos}" \ -- --config "${vpnnosf}" --writepid "${pidnos}" --daemon ${args} eend $? } stop() { ebegin "stop ew" start-stop-daemon --stop --exec /usr/sbin/openvpn --pidfile "${pidew}" start-stop-daemon --stop --exec /usr/sbin/openvpn --pidfile "${pidnos}" ip route del 81.93.243.132/32 via ${peer} ip route del 81.93.247.160/32 via ${peer} eend $? }