openfortivpn: use proper method to access configuration in hotplug

Use functions.sh to get configuration variables rather than calling uci

Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
This commit is contained in:
Aaron Goodman 2020-07-21 02:12:37 -04:00
parent c8a8afe8c0
commit a541f0be8a
2 changed files with 20 additions and 14 deletions

View file

@ -1,20 +1,27 @@
#!/bin/sh #!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh . /usr/share/libubox/jshn.sh
[ "$ACTION" != ifup ] && exit [ "$ACTION" != ifup ] && exit
networks=$(uci show network | sed "s/network.\([^.]*\).proto='openfortivpn'/\1/;t;d") handle_network()
for i in $networks; do {
iface=$(uci get "network.${i}.iface_name") config_get iface $1 iface_name
iface_success=$? [ $INTERFACE != "$iface" ] && return
[ $? -eq 0 ] && [ $INTERFACE == "$iface" ] && { [ $(config_get $1 proto) != "openfortivpn" ] && return
logger -t "openfortivpnhotplug" "$ACTION on $INTERFACE to bring up $i"
load_on_boot=$(uci get network.${i}.auto 2>/dev/null) config_get_bool load_on_boot $1 auto
[ -n "$load_on_boot" ] && [ "$load_on_boot" -eq 0 ] && continue [ -n "$load_on_boot" ] && [ "$load_on_boot" -eq 0 ] && return
json_load "$(ifstatus $i)" status="$(ifstatus $1)" || continue
json_load "$status"
json_get_var autostart autostart json_get_var autostart autostart
logger -t "openfortivpnhotplug" "$ACTION on $INTERFACE to bring up $1. Autostart is $autostart"
[ "$autostart" -eq 0 ] && { [ "$autostart" -eq 0 ] && {
logger -t "openfortivpnhotplug" "auto-start was false. bringing $i up" logger -t "openfortivpnhotplug" "auto-start was false. bringing $1 up"
ubus call network.interface up "{ \"interface\" : \"$i\" }" ubus call network.interface up "{ \"interface\" : \"$1\" }"
} }
} }
done
config_load network
config_foreach handle_network interface
exit 0

View file

@ -134,7 +134,6 @@ ip-down-script /lib/netifd/ppp-down
mru 1354" > $callfile mru 1354" > $callfile
append_args "--pppd-call=openfortivpn/$config" append_args "--pppd-call=openfortivpn/$config"
proto_export INTERFACE="$ifname"
logger -p 6 -t openfortivpn "$config: executing 'openfortivpn $cmdline'" logger -p 6 -t openfortivpn "$config: executing 'openfortivpn $cmdline'"
eval "proto_run_command '$config' /usr/sbin/openfortivpn-wrapper '$pwfile' '$config' $cmdline" eval "proto_run_command '$config' /usr/sbin/openfortivpn-wrapper '$pwfile' '$config' $cmdline"