Mail archive
alpine-devel

[alpine-devel] openvpn: check tunnel patch

From: Ilya Strelkin <iilluzion_at_gmail.com>
Date: Wed, 18 Feb 2009 15:00:26 +0300

Hi!

Here is the patch for /etc/init.d/openvpn script to check if tunnel is up
before going any further

1. new /etc/conf.d/openvpn file is required

# Suspend processing until tunnel is connected
SUSPEND_UNTIL_CONNECTED=YES

# Probe IP to check tunnel connectivity
PROBE_IP=192.168.0.1

2. /etc/init.d/openvpn patch
--- openvpn Wed Feb 18 11:26:58 2009
+++ openvpn-new Wed Feb 18 11:28:13 2009
_at__at_ -52,7 +52,29 @@
        start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile
"${VPNPID}" \
                -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon
${args}

+ R=$?
        eend $? "Check your logs to see why startup failed"
+
+ #iilluzion: Check if tunnel is up but no longer than 1 minute
+ if [ "$SUSPEND_UNTIL_CONNECTED" = "YES" -a $R -eq 0 ]; then
+ ebegin "Waiting for tunnel is up (max 1 min)"
+ PROBE_IP=${PROBE_IP:-10.8.0.1}
+ COUNT=0
+ while true; do
+ echo -n "."
+ ping -W 2 -w 3 -c 1 -q $PROBE_IP > /dev/null
2>&1
+ R=$?
+ if [ $R -eq 0 ]; then
+ break
+ else
+ COUNT=$((COUNT + 1))
+ if [ $COUNT -gt 29 ]; then
+ break
+ fi
+ fi
+ done
+ eend $R "Check your logs to see why tunnel failed"
+ fi
 }

 stop() {



---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Wed Feb 18 2009 - 15:00:26 UTC