2023-04-10 11:55:17 +08:00

91 lines
2.0 KiB
Bash

#!/bin/sh /etc/rc.common
. /lib/functions.sh
START=98
log() {
wifilog "Hotspot Initialize" "$@"
}
do_zone() {
local config=$1
local name
local network
config_get name $1 name
config_get network $1 network
newnet="$network"
if [ $name = wan ]; then
WWAN=$(echo "$network" | grep "wwan2")
if [ -z "$WWAN" ]; then
newnet="$newnet wwan2 wwan5"
uci_set firewall "$config" network "$newnet"
uci_commit firewall
/etc/init.d/firewall restart
fi
fi
}
do_radio() {
local config=$1
local channel
local hwmode
config_get channel $1 channel
config_get hwmode $1 hwmode
if [ $hwmode = "11g" ]; then
w2=$(uci -q get wireless.wwan2.device)
if [ -z $w2 ]; then
uci set wireless.wwan2=wifi-iface
uci set wireless.wwan2.device=$config
uci set wireless.wwan2.network="wwan2"
uci set wireless.wwan2.mode="sta"
uci set wireless.wwan2.ssid="Hotspot Manager Interface"
uci set wireless.wwan2.encryption="none"
uci set wireless.wwan2.disabled="1"
uci commit wireless
fi
else
w2=$(uci -q get wireless.wwan5.device)
if [ -z $w2 ]; then
uci set wireless.wwan5=wifi-iface
uci set wireless.wwan5.device=$config
uci set wireless.wwan5.network="wwan5"
uci set wireless.wwan5.mode="sta"
uci set wireless.wwan5.ssid="Hotspot Manager Interface"
uci set wireless.wwan5.encryption="none"
uci set wireless.wwan5.disabled="1"
uci commit wireless
fi
fi
}
start()
{
log "Hotspot Firewall"
PRO=$(uci get network.wwan2.proto)
if [ -z $PRO ]; then
uci set network.wwan2=interface
uci set network.wwan2.proto=dhcp
uci set network.wwan26=interface
uci set network.wwan26.proto=dhcpv6
uci set network.wwan5=interface
uci set network.wwan5.proto=dhcp
uci set network.wwan56=interface
uci set network.wwan56.proto=dhcpv6
uci commit network
fi
config_load firewall
config_foreach do_zone zone
config_load wireless
config_foreach do_radio wifi-device
uci set travelmate.global.lost="0"
uci set travelmate.global.delay="30"
uci set travelmate.global.state='0'
uci commit travelmate
}