From: Fabian Klemp <fabian.kl...@axino-group.com>

openvpn only provides options to update a pid file but not to check it
for running processes. Consecutive issued start commands therefore lead
to multiple running processes with the same configurations, which is the
origin of all kinds of problems of which unnecessary resource usage is the 
least.

Using start-stop-daemon the pid file is inspected for running processes
before start.

Signed-off-by: Fabian Klemp <fabian.kl...@axino-group.com>
Signed-off-by: Khem Raj <raj.k...@gmail.com>
Signed-off-by: Armin Kuster <akuster...@gmail.com>
---
 meta-networking/recipes-support/openvpn/openvpn/openvpn | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/meta-networking/recipes-support/openvpn/openvpn/openvpn 
b/meta-networking/recipes-support/openvpn/openvpn/openvpn
index a3cd6a2..e5af4b2 100755
--- a/meta-networking/recipes-support/openvpn/openvpn/openvpn
+++ b/meta-networking/recipes-support/openvpn/openvpn/openvpn
@@ -4,6 +4,7 @@
 # <r...@mars.org>, edited by iwj and cs
 # Modified for openvpn by Alberto Gonzalez Iniesta <a...@agi.as>
 # Modified for restarting / starting / stopping single tunnels by Richard 
Mueller <muel...@teamix.net>
+# Modified for respecting pid file on service start by Fabian Klemp 
<fabian.kl...@axino-group.com>
 
 test $DEBIAN_SCRIPT_DEBUG && set -v -x
 
@@ -14,10 +15,17 @@ test -d $CONFIG_DIR || exit 0
 
 start_vpn () {
     modprobe tun >/dev/null 2>&1 || true
-    $DAEMON --daemon --writepid /var/run/openvpn.$NAME.pid \
-            --config $CONFIG_DIR/$NAME.conf --cd $CONFIG_DIR || echo -n " 
FAILED->"
+    start-stop-daemon --start --quiet --pidfile /var/run/openvpn.$NAME.pid \
+            --exec $DAEMON -- \
+            --daemon --writepid /var/run/openvpn.$NAME.pid \
+            --config $CONFIG_DIR/$NAME.conf --cd $CONFIG_DIR || rc="$?"
+    case $rc in
+        1) echo -n " ALREADY STARTED->";;
+        3) echo -n " FAILED->";;
+    esac
     echo -n " $NAME"
 }
+
 stop_vpn () {
    kill `cat $PIDFILE` || true
   rm $PIDFILE
-- 
2.7.4

-- 
_______________________________________________
Openembedded-devel mailing list
Openembedded-devel@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-devel

Reply via email to