packages/net/openfortivpn/files/14-openforticlient
Aaron Goodman d134b7ffbb openfortivpn: Only start autostart interfaces on hotplug event
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
2020-07-21 22:01:46 -04:00

20 lines
779 B
Bash

#!/bin/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)"
json_get_var autostart autostart
[ "$autostart" -eq 0 ] && {
logger -t "openfortivpnhotplug" "auto-start was false. bringing $i up"
ubus call network.interface up "{ \"interface\" : \"$i\" }"
}
}
done