aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Goodman <aaronjg@stanford.edu>2020-07-21 02:12:37 -0400
committerAaron Goodman <aaronjg@stanford.edu>2020-07-30 20:47:33 -0400
commita541f0be8a8f28b8bb66c2fb433fa89e25704555 (patch)
treef509bea1b21778d21bb20b817c67c6217aecca27
parentc8a8afe8c0ee7eccb5466e2096021aeb7284d42e (diff)
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>
-rw-r--r--net/openfortivpn/files/14-openforticlient33
-rwxr-xr-xnet/openfortivpn/files/openfortivpn.sh1
2 files changed, 20 insertions, 14 deletions
diff --git a/net/openfortivpn/files/14-openforticlient b/net/openfortivpn/files/14-openforticlient
index 9cff9bd21..a9a24b18b 100644
--- a/net/openfortivpn/files/14-openforticlient
+++ b/net/openfortivpn/files/14-openforticlient
@@ -1,20 +1,27 @@
#!/bin/sh
+. /lib/functions.sh
. /usr/share/libubox/jshn.sh
[ "$ACTION" != ifup ] && exit
-networks=$(uci show network | sed "s/network.\([^.]*\).proto='openfortivpn'/\1/;t;d")
-for i in $networks; do
- iface=$(uci get "network.${i}.iface_name")
- iface_success=$?
- [ $? -eq 0 ] && [ $INTERFACE == "$iface" ] && {
- logger -t "openfortivpnhotplug" "$ACTION on $INTERFACE to bring up $i"
- load_on_boot=$(uci get network.${i}.auto 2>/dev/null)
- [ -n "$load_on_boot" ] && [ "$load_on_boot" -eq 0 ] && continue
- json_load "$(ifstatus $i)"
+handle_network()
+{
+ config_get iface $1 iface_name
+ [ $INTERFACE != "$iface" ] && return
+ [ $(config_get $1 proto) != "openfortivpn" ] && return
+
+ config_get_bool load_on_boot $1 auto
+ [ -n "$load_on_boot" ] && [ "$load_on_boot" -eq 0 ] && return
+ status="$(ifstatus $1)" || continue
+ json_load "$status"
json_get_var autostart autostart
+ logger -t "openfortivpnhotplug" "$ACTION on $INTERFACE to bring up $1. Autostart is $autostart"
[ "$autostart" -eq 0 ] && {
- logger -t "openfortivpnhotplug" "auto-start was false. bringing $i up"
- ubus call network.interface up "{ \"interface\" : \"$i\" }"
+ logger -t "openfortivpnhotplug" "auto-start was false. bringing $1 up"
+ ubus call network.interface up "{ \"interface\" : \"$1\" }"
}
- }
-done
+}
+
+
+config_load network
+config_foreach handle_network interface
+exit 0
diff --git a/net/openfortivpn/files/openfortivpn.sh b/net/openfortivpn/files/openfortivpn.sh
index 5599f3150..893510ce8 100755
--- a/net/openfortivpn/files/openfortivpn.sh
+++ b/net/openfortivpn/files/openfortivpn.sh
@@ -134,7 +134,6 @@ ip-down-script /lib/netifd/ppp-down
mru 1354" > $callfile
append_args "--pppd-call=openfortivpn/$config"
- proto_export INTERFACE="$ifname"
logger -p 6 -t openfortivpn "$config: executing 'openfortivpn $cmdline'"
eval "proto_run_command '$config' /usr/sbin/openfortivpn-wrapper '$pwfile' '$config' $cmdline"