X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@lists.alpinelinux.org Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.186]) by lists.alpinelinux.org (Postfix) with ESMTP id 36772170000BA for ; Wed, 18 Feb 2009 12:00:28 +0000 (UTC) Received: by fk-out-0910.google.com with SMTP id 18so1609212fkq.9 for ; Wed, 18 Feb 2009 04:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=DZZsHr1JhReY9yGL26qz04cOHzLVhxkVf6QADl0DcBY=; b=rh5rqn83LciKin7kTBJkbHkjwuPV78CMUycXfojSQHjkxn84NVsec6LUyvRVj1CNBD K3ak4i2eU9DBog0fh4WhVuyM3X0KzeId4EL4SKY6CMHvvsqQjM4CsLjLrGvzXLm4gHDB qu8Glh/j3WM9I1Q9XYQTE0wkoAXKBeCugyE+M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=F3LrwFJZFxQEGuYSf6t/a8ng3whlf3dB3448z86saZCixadCJ7GwBpbGsl9HeU7Dut Wmcyhr2cO7mDHcu9Kl+mB8EshlacUGfx4fHPHcei9FuoFdDuht2wKwtb6s+NiJ91aALi 6o0JUWG7Ttfbn+oB+2XmHXzFpk+Zzv3GijQ9I= X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: MIME-Version: 1.0 Received: by 10.181.206.7 with SMTP id i7mr1057441bkq.57.1234958427000; Wed, 18 Feb 2009 04:00:27 -0800 (PST) Date: Wed, 18 Feb 2009 15:00:26 +0300 Message-ID: Subject: [alpine-devel] openvpn: check tunnel patch From: Ilya Strelkin To: alpine-devel@lists.alpinelinux.org Content-Type: multipart/alternative; boundary=0016e6d646885a8e620463302a5f --0016e6d646885a8e620463302a5f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 @@ -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() { --0016e6d646885a8e620463302a5f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi!

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

1. new /etc/conf.d/openvpn file i= s required

# Suspend processing until tunnel is connected
SUSPEND= _UNTIL_CONNECTED=3DYES

# Probe IP to check tunnel connectivity
PROBE_IP=3D192.168.0.1
2. /etc/init.d/openvpn patch
--- openvpn     Wed F= eb 18 11:26:58 2009
+++ openvpn-new Wed Feb 18 11:28:13 2009
@@ -52,7= +52,29 @@
        start-stop-daemon = --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \
            &nb= sp;   -- --config "${VPNCONF}" --writepid "${VPNPI= D}" --daemon ${args}

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

 stop() {
--0016e6d646885a8e620463302a5f-- --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---