packages/net/openfortivpn/files/14-openforticlient
Aaron Goodman a541f0be8a 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>
2020-07-30 20:47:33 -04:00

27 lines
830 B
Bash

#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
[ "$ACTION" != ifup ] && exit
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 $1 up"
ubus call network.interface up "{ \"interface\" : \"$1\" }"
}
}
config_load network
config_foreach handle_network interface
exit 0