rfkill unblock wifi if needed

This commit is contained in:
garywill 2021-01-20 13:10:02 +08:00
parent 98b4d03307
commit c8c20c3094
2 changed files with 10 additions and 1 deletions

View File

@ -319,6 +319,7 @@ Options:
> These changes to system will not be restored by script's cleanup:
> 1. `/proc/sys/net/ipv4/ip_forward = 1` and `/proc/sys/net/ipv6/conf/all/forwarding = 1`, needed by NAT Internet sharing.
> 2. dnsmasq in Apparmor complain mode
> 3. The wifi device which is used to create hotspot is `rfkill unblock`ed
## Dependencies

View File

@ -499,7 +499,7 @@ get_phy_device() { # only for wifi interface
}
get_adapter_info() { # only for wifi interface
local PHY
#local PHY
PHY=$(get_phy_device "$1")
[[ $? -ne 0 ]] && return 1
iw phy $PHY info
@ -1685,6 +1685,14 @@ if [[ -n "$NEW_MACADDR" ]]; then
ip link set dev ${SUBNET_IFACE} address ${NEW_MACADDR} || die "Failed setting new MAC address"
fi
if [[ $WIFI_IFACE ]]; then
if which rfkill > /dev/null 2>&1 ; then
PHY=$(get_phy_device ${SUBNET_IFACE})
[[ -n $PHY ]] && rfkill unblock $(rfkill | grep $PHY | awk '{print $1}') >/dev/null 2>&1
fi
fi
ip link set up dev ${SUBNET_IFACE} || die "Failed bringing ${SUBNET_IFACE} up"
if [[ $WIFI_IFACE ]]; then