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

@@ -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