mirror of
https://git.openwrt.org/feed/packages.git
synced 2024-06-13 10:59:13 +02:00
Merge pull request #22941 from TDT-AG/pr/20231220-openvpn
openvpn: start openvpn connection located under '/etc/openvpn' not only on system start
This commit is contained in:
commit
8ab4147773
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||||
PKG_NAME:=openvpn
|
PKG_NAME:=openvpn
|
||||||
|
|
||||||
PKG_VERSION:=2.6.8
|
PKG_VERSION:=2.6.8
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE_URL:=\
|
PKG_SOURCE_URL:=\
|
||||||
https://build.openvpn.net/downloads/releases/ \
|
https://build.openvpn.net/downloads/releases/ \
|
||||||
|
|
|
@ -10,6 +10,7 @@ STOP=10
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
PROG=/usr/sbin/openvpn
|
PROG=/usr/sbin/openvpn
|
||||||
|
|
||||||
|
PATH_INSTANCE_DIR="/etc/openvpn"
|
||||||
LIST_SEP="
|
LIST_SEP="
|
||||||
"
|
"
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ openvpn_add_instance() {
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
start_instance() {
|
start_uci_instance() {
|
||||||
local s="$1"
|
local s="$1"
|
||||||
|
|
||||||
config_get config "$s" config
|
config_get config "$s" config
|
||||||
|
@ -206,6 +207,43 @@ start_instance() {
|
||||||
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" "$script_security" "$up" "$down"
|
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" "$script_security" "$up" "$down"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start_path_instances() {
|
||||||
|
local path name
|
||||||
|
|
||||||
|
for path in ${PATH_INSTANCE_DIR}/*.conf; do
|
||||||
|
[ -f "$path" ] && {
|
||||||
|
name="${path##*/}"
|
||||||
|
name="${name%.conf}"
|
||||||
|
start_path_instance "$name"
|
||||||
|
}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
start_path_instance() {
|
||||||
|
local name="$1"
|
||||||
|
|
||||||
|
local path up down
|
||||||
|
|
||||||
|
path="${PATH_INSTANCE_DIR}/${name}.conf"
|
||||||
|
|
||||||
|
# don't start configs again that are already started by uci
|
||||||
|
if echo "$UCI_STARTED" | grep -qxF "$path"; then
|
||||||
|
logger -t openvpn "$name.conf already started"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# don't start configs which are set to disabled in uci
|
||||||
|
if echo "$UCI_DISABLED" | grep -qxF "$path"; then
|
||||||
|
logger -t openvpn "$name.conf is disabled in /etc/config/openvpn"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
get_openvpn_option "$path" up up || up=""
|
||||||
|
get_openvpn_option "$path" down down || down=""
|
||||||
|
|
||||||
|
openvpn_add_instance "$name" "${path%/*}" "$path" "" "$up" "$down"
|
||||||
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
local instance="$1"
|
local instance="$1"
|
||||||
local instance_found=0
|
local instance_found=0
|
||||||
|
@ -225,31 +263,20 @@ start_service() {
|
||||||
config_load 'openvpn'
|
config_load 'openvpn'
|
||||||
|
|
||||||
if [ -n "$instance" ]; then
|
if [ -n "$instance" ]; then
|
||||||
[ "$instance_found" -gt 0 ] || return
|
if [ "$instance_found" -gt 0 ]; then
|
||||||
start_instance "$instance"
|
start_uci_instance "$instance"
|
||||||
|
else
|
||||||
|
start_path_instance "$instance"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
config_foreach start_instance 'openvpn'
|
config_foreach start_uci_instance 'openvpn'
|
||||||
|
|
||||||
local path name up down
|
auto="$(uci_get openvpn globals autostart 1)"
|
||||||
for path in /etc/openvpn/*.conf; do
|
if [ "$auto" = "1" ]; then
|
||||||
if [ -f "$path" ]; then
|
start_path_instances
|
||||||
name="${path##*/}"; name="${name%.conf}"
|
else
|
||||||
|
logger -t openvpn "Autostart for configs in '$PATH_INSTANCE_DIR/*.conf' disabled"
|
||||||
# don't start configs again that are already started by uci
|
fi
|
||||||
if echo "$UCI_STARTED" | grep -qxF "$path"; then
|
|
||||||
continue
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
get_openvpn_option "$path" up up || up=""
|
|
||||||
get_openvpn_option "$path" down down || down=""
|
|
||||||
openvpn_add_instance "$name" "${path%/*}" "$path" "" "$up" "$down"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user