aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-support
diff options
context:
space:
mode:
authorFabian Klemp <fabian.klemp@axino-group.com>2019-07-30 12:35:36 +0200
committerArmin Kuster <akuster808@gmail.com>2019-09-02 19:39:29 -0700
commitf62c85e86b6b61f494e67d328cc76c4a55ce145f (patch)
tree9a50898f3b38650aefe99d82a8d5041a921d2883 /meta-networking/recipes-support
parent1d57c52f0701c871ef74574d677d0f1948cbc575 (diff)
downloadmeta-openembedded-f62c85e86b6b61f494e67d328cc76c4a55ce145f.tar.gz
openvpn: respect pid file in init.d service start
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.klemp@axino-group.com> Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-networking/recipes-support')
-rwxr-xr-xmeta-networking/recipes-support/openvpn/openvpn/openvpn12
1 files changed, 10 insertions, 2 deletions
diff --git a/meta-networking/recipes-support/openvpn/openvpn/openvpn b/meta-networking/recipes-support/openvpn/openvpn/openvpn
index a3cd6a2f49..e5af4b2301 100755
--- a/meta-networking/recipes-support/openvpn/openvpn/openvpn
+++ b/meta-networking/recipes-support/openvpn/openvpn/openvpn
@@ -4,6 +4,7 @@
# <rob@mars.org>, edited by iwj and cs
# Modified for openvpn by Alberto Gonzalez Iniesta <agi@agi.as>
# Modified for restarting / starting / stopping single tunnels by Richard Mueller <mueller@teamix.net>
+# Modified for respecting pid file on service start by Fabian Klemp <fabian.klemp@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