/
upnet
executable file
·24 lines (22 loc) · 1.05 KB
/
upnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/bash
# Workaround for RT8822BE wireless cards wifi issue when using the new rtwpci driver.
if [[ "$UID" -ne 0 ]]; then
echo "You need to run the script as root."
exit
fi
# Change the ASPM mode using the Link Control Register according to https://wireless.wiki.kernel.org/en/users/documentation/aspm#enabling_aspm_with_setpci (requires pciutils)
if command -v setpci >/dev/null; then
# Replace 00:1c.5 if needed. Execute `lspci | grep -i wifi | awk '{print $1}'`, then have in mind that result. Now execute `lspci -t` and see where that value belongs.
if setpci -s 00:1c.5 0x50.B=0x40 >/dev/null; then
sleep 2
modprobe rtwpci
# Uncomment the next two lines and change it to match your network services and init in use.
# sleep 2
# systemctl restart iwd systemd-networkd systemd-resolved
echo "ASPM configurations applied. Restart your network services if you haven't set them in the script."
else
echo "An unknown error has occurred. Reboot and try again."
fi
else
echo "You need to have pciutils installed in your system."
fi