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>
This commit is contained in:
parent
01d8f5c9be
commit
b2269ecbf7
1 changed files with 24 additions and 20 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue