aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorMartin Schiller <ms@dev.tdt.de>2017-10-09 10:12:04 +0200
committerJo-Philipp Wich <jo@mein.io>2017-12-13 16:48:57 +0100
commit91e48304a9279358537c939bef5e0a678cb621fc (patch)
tree7cd5543db7383363a623bcca3e69453673324758 /package
parente5c284bb812a2342f678c854383267c166cf8678 (diff)
downloadupstream-91e48304a9279358537c939bef5e0a678cb621fc.tar.gz
upstream-91e48304a9279358537c939bef5e0a678cb621fc.tar.bz2
upstream-91e48304a9279358537c939bef5e0a678cb621fc.zip
openvpn: add support to start/stop single instances
Signed-off-by: Martin Schiller <ms@dev.tdt.de> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> (PKG_RELEASE increase) (cherry picked from commit e2f25e607d2092cffa45196e7997854feb464232)
Diffstat (limited to 'package')
-rw-r--r--package/network/services/openvpn/Makefile2
-rw-r--r--package/network/services/openvpn/files/openvpn.init53
2 files changed, 37 insertions, 18 deletions
diff --git a/package/network/services/openvpn/Makefile b/package/network/services/openvpn/Makefile
index 9d8f047613..fee0296ed4 100644
--- a/package/network/services/openvpn/Makefile
+++ b/package/network/services/openvpn/Makefile
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=openvpn
PKG_VERSION:=2.4.4
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL:=\
https://build.openvpn.net/downloads/releases/ \
diff --git a/package/network/services/openvpn/files/openvpn.init b/package/network/services/openvpn/files/openvpn.init
index 98c1710f03..ab4f7dba0d 100644
--- a/package/network/services/openvpn/files/openvpn.init
+++ b/package/network/services/openvpn/files/openvpn.init
@@ -60,7 +60,7 @@ openvpn_add_instance() {
local dir="$2"
local conf="$3"
- procd_open_instance
+ procd_open_instance "$name"
procd_set_param command "$PROG" \
--syslog "openvpn($name)" \
--status "/var/run/openvpn.$name.status" \
@@ -103,28 +103,47 @@ start_instance() {
}
start_service() {
+ local instance="$1"
+ local instance_found=0
+
+ config_cb() {
+ local type="$1"
+ local name="$2"
+ if [ "$type" = "openvpn" ]; then
+ if [ -n "$instance" -a "$instance" = "$name" ]; then
+ instance_found=1
+ fi
+ fi
+ }
+
. /usr/share/openvpn/openvpn.options
config_load 'openvpn'
- config_foreach start_instance 'openvpn'
- local path name
- for path in /etc/openvpn/*.conf; do
- if [ -f "$path" ]; then
- name="${path##*/}"; name="${name%.conf}"
+ if [ -n "$instance" ]; then
+ [ "$instance_found" -gt 0 ] || return
+ start_instance "$instance"
+ else
+ config_foreach start_instance 'openvpn'
- # don't start configs again that are already started by uci
- if echo "$UCI_STARTED" | grep -qxF "$path"; then
- continue
+ local path name
+ for path in /etc/openvpn/*.conf; do
+ if [ -f "$path" ]; then
+ name="${path##*/}"; name="${name%.conf}"
- # don't start configs which are set to disabled in uci
- elif echo "$UCI_DISABLED" | grep -qxF "$path"; then
- logger -t openvpn "$name.conf is disabled in /etc/config/openvpn"
- continue
- fi
+ # don't start configs again that are already started by uci
+ if echo "$UCI_STARTED" | grep -qxF "$path"; then
+ continue
- openvpn_add_instance "$name" "${path%/*}" "$path"
- fi
- done
+ # don't start configs which are set to disabled in uci
+ elif echo "$UCI_DISABLED" | grep -qxF "$path"; then
+ logger -t openvpn "$name.conf is disabled in /etc/config/openvpn"
+ continue
+ fi
+
+ openvpn_add_instance "$name" "${path%/*}" "$path"
+ fi
+ done
+ fi
}
service_triggers() {