forked from Netgear-A6210-linux-driver/Netgear-A6210
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·76 lines (65 loc) · 1.7 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
function install_driver {
make -j $1
STATUS=$?
if [ $STATUS -ne 0 ]; then
error $STATUS
else
sudo make install -j $1
dkms_add
fi
}
# Adds the driver to dkms so that the kernel will include it in future upgrades
function dkms_add {
if [ -n "$(pacman -Q dkms)" ]; then
read -p "Add $(pkgname)-$(pkgver) to dkms for including this driver in future kernel upgrades? [Y/n] " yn
case $yn in
[Y/y]* ) ;;
[N/n]* ) exit;;
* ) ;;
esac
else
read -p "Install dkms for reloading this driver into the kernel upon updating? [Y/n] " yn
case $yn in
[Y/y]* ) pacman -S dkms;;
[N/n]* ) exit;;
* ) exit;;
esac
fi
echo "Adding ${pkgdir}-${pkgver} to dkms module list"
mv "$pkgdir/*" $pkgdir/usr/src/${pkgname}-${pkgver}
dkms install ${pkgname}-${pkgver}
}
function error_deps {
echo -e "\033[0;31merror: linux-headers not found\033[0m"
read -p "Install 'linux-headers'? [Y/n] " yn
case $yn in
[Y/y]* ) sudo pacman -S linux-headers; install_driver;;
[N/n]* ) exit 2;;
* ) sudo pacman -S linux-headers; install_driver;;
esac
}
function error_reboot {
echo "\033[0;31merror: kernel version mismatch\033[0m"
echo "The current version of the kernel doesn't match the installed version"
echo "You must to reboot before installing ${pkgname}-${pkgver}"
read -p "Reboot now? [Y/n] " yn
# TODO: Add this script to systemd and run it on boot to install the driver, then delete the script
case $yn in
[Y/y]* ) sudo reboot;;
[N/n]* ) exit 2;;
* ) exit 2;;
esac
}
function error {
if [ $1 -eq 2 ]; then
if [[ -n "$(pacman -Q linux-headers)" ]]; then
error_deps
else
error_reboot
fi
fi
}
trap exit INT
CORES=$(lscpu | awk '/^Core/{ print $4 }')
install_driver $CORES