Isto não conserta o problema, já que o wifi vai acabar extinguindo-se novamente - tudo isso faz com que você tenha wifi novamente sem precisar reiniciar (salve como fixwifi.sh e execute como sudo):
#!/bin/sh
# If an interface name was not passed in then assume that wlan0 is the interface name.
if [ -z "$1" ]; then
interface="wlan0"
else
interface=$1
fi
# Figure out what pci slot Linux has assigned the Network controller: Intel Corporation Wireless 7260
wirelessPCI=$(lspci |grep "Wireless 7260")
pci=$(echo ${wirelessPCI} | awk '{ print $1 }')
devicePath="/sys/bus/pci/devices/0000:$pci/remove"
# Not the best solution as this script can hang.
# But since if this script fails the ONLY way to revive the wifi anyway is a reboot...
# Feel free to improve the script if you have the scriptfu ninja skills to do so.
while true; do
# Tell Linux to remove the wifi card from the PCI device list only if it exists in the first place.
if [ -f $devicePath ]; then
echo 1 | sudo tee $devicePath > /dev/null
sleep 1
fi
# Reprobe the driver modules in case we have removed them in a failed attempt to wake the network card.
sudo modprobe iwlmvm
sudo modprobe iwlwifi
# Try to have Linux bring the network card back online as a PCI device.
echo 1 | sudo tee /sys/bus/pci/rescan > /dev/null
sleep 1
# Check if Linux managed to bring the network card back online as a PCI device.
if [ -f $devicePath ]; then
# Looks like we are back in business.
# So we try to set the PCI slot with some voodoo I don't understand that the Intel devs told me to try.
# https://bugzilla.kernel.org/show_bug.cgi?id=191601
sudo setpci -s $pci 0x50.B=0x40
# Bring the wireless network interface up.
sudo ifconfig $interface up
# Did the wifi interface actually go live?
exitCode=$?
if [ $exitCode -eq 0 ];then
# Not sure why in the hell this is not the default for wireless intefaces.
# It is well documented that: (power_management === ON) === Wifi-Stupidity
sudo iwconfig $interface power off
# The exit code will be the exit code of our attempt at turning power management off for $interface/wlan0.
break
fi
else
# It's worse than that the wifi's dead Jim! Dead Jim! Dead!
# We tell Linux to remove the the wifi driver modules and loop back in an attempt to revive the wifi.
sudo modprobe -r iwlmvm
sudo modprobe -r iwlwifi
fi
done