openvpn: add start_path_instance function
This commit moves the part for starting an instance to a sub function. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
b2269ecbf7
commit
0b633a0886
1 changed files with 33 additions and 18 deletions
|
@ -10,6 +10,7 @@ STOP=10
|
|||
USE_PROCD=1
|
||||
PROG=/usr/sbin/openvpn
|
||||
|
||||
PATH_INSTANCE_DIR="/etc/openvpn"
|
||||
LIST_SEP="
|
||||
"
|
||||
|
||||
|
@ -207,28 +208,42 @@ start_uci_instance() {
|
|||
}
|
||||
|
||||
start_path_instances() {
|
||||
local path name up down
|
||||
local path name
|
||||
|
||||
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
|
||||
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() {
|
||||
local instance="$1"
|
||||
local instance_found=0
|
||||
|
|
Loading…
Reference in a new issue