summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2023-12-20 09:59:13 +0100
committerFlorian Eckert <fe@dev.tdt.de>2023-12-20 15:01:24 +0100
commitb2269ecbf779b712db8ef40203ef1bcaaf4175ce (patch)
treecd4f95b22c88218912aa5a320cdb09184b695bcb
parent01d8f5c9befdce35d4d254aaa0793b8daa4b0008 (diff)
openvpn: move path instances call to sub function
Move the start of the OpenVPN configurations in '/etc/openvpn' in a function. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
-rw-r--r--net/openvpn/files/openvpn.init44
1 files changed, 24 insertions, 20 deletions
diff --git a/net/openvpn/files/openvpn.init b/net/openvpn/files/openvpn.init
index af59098af..c282021ae 100644
--- a/net/openvpn/files/openvpn.init
+++ b/net/openvpn/files/openvpn.init
@@ -206,6 +206,29 @@ start_uci_instance() {
openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" "$script_security" "$up" "$down"
}
+start_path_instances() {
+ local path name up down
+
+ for path in /etc/openvpn/*.conf; do
+ if [ -f "$path" ]; then
+ name="${path##*/}"; name="${name%.conf}"
+
+ # don't start configs again that are already started by uci
+ 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
+}
+
start_service() {
local instance="$1"
local instance_found=0
@@ -230,26 +253,7 @@ start_service() {
else
config_foreach start_uci_instance 'openvpn'
- local path name up down
- for path in /etc/openvpn/*.conf; do
- if [ -f "$path" ]; then
- name="${path##*/}"; name="${name%.conf}"
-
- # don't start configs again that are already started by uci
- 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
+ start_path_instances
fi
}