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 e2f25e607d)
This commit is contained in:
Martin Schiller 2017-10-09 10:12:04 +02:00 committed by Jo-Philipp Wich
parent e5c284bb81
commit 91e48304a9
2 changed files with 37 additions and 18 deletions

View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=openvpn PKG_NAME:=openvpn
PKG_VERSION:=2.4.4 PKG_VERSION:=2.4.4
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_SOURCE_URL:=\ PKG_SOURCE_URL:=\
https://build.openvpn.net/downloads/releases/ \ https://build.openvpn.net/downloads/releases/ \

View File

@ -60,7 +60,7 @@ openvpn_add_instance() {
local dir="$2" local dir="$2"
local conf="$3" local conf="$3"
procd_open_instance procd_open_instance "$name"
procd_set_param command "$PROG" \ procd_set_param command "$PROG" \
--syslog "openvpn($name)" \ --syslog "openvpn($name)" \
--status "/var/run/openvpn.$name.status" \ --status "/var/run/openvpn.$name.status" \
@ -103,8 +103,26 @@ start_instance() {
} }
start_service() { 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 . /usr/share/openvpn/openvpn.options
config_load 'openvpn' config_load 'openvpn'
if [ -n "$instance" ]; then
[ "$instance_found" -gt 0 ] || return
start_instance "$instance"
else
config_foreach start_instance 'openvpn' config_foreach start_instance 'openvpn'
local path name local path name
@ -125,6 +143,7 @@ start_service() {
openvpn_add_instance "$name" "${path%/*}" "$path" openvpn_add_instance "$name" "${path%/*}" "$path"
fi fi
done done
fi
} }
service_triggers() { service_triggers() {