forked from morrownr/88x2bu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-driver.sh
executable file
·80 lines (68 loc) · 2.17 KB
/
install-driver.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
77
78
79
80
#!/bin/bash
DRV_NAME="rtl88x2bu"
DRV_VERSION="5.8.7.4"
OPTIONS_FILE="88x2bu.conf"
DRV_DIR="$(pwd)"
KRNL_VERSION="$(uname -r)"
SCRIPT_NAME="install-driver.sh"
if [[ $EUID -ne 0 ]]; then
echo "You must run this script with superuser (root) privileges."
echo "Try: \"sudo ./${SCRIPT_NAME}\""
exit 1
fi
if [[ -d "/usr/lib/dkms" ]]; then
echo "Installing ${DRV_NAME}-${DRV_VERSION}"
else
echo "dkms does not appear to be installed."
echo "Please install dkms and try again."
exit 1
fi
echo "Copying source files to: /usr/src/${DRV_NAME}-${DRV_VERSION}"
cp -r "${DRV_DIR}" /usr/src/${DRV_NAME}-${DRV_VERSION}
echo "Copying ${OPTIONS_FILE} to: /etc/modprobe.d"
cp -r ${OPTIONS_FILE} /etc/modprobe.d
dkms add ${DRV_NAME}/${DRV_VERSION}
RESULT=$?
if [[ "$RESULT" != "0" ]]; then
echo "An error occurred while running: dkms add : ${RESULT}"
echo "Removing ${OPTIONS_FILE} from: /etc/modprobe.d"
rm -f /etc/modprobe.d/${OPTIONS_FILE}
echo "Removing source files from: /usr/src/${DRV_NAME}-${DRV_VERSION}"
rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION}
echo "Cleanup complete"
echo "dkms status:"
dkms status
exit $RESULT
fi
dkms build ${DRV_NAME}/${DRV_VERSION}
RESULT=$?
if [[ "$RESULT" != "0" ]]; then
echo "An error occurred while running: dkms build : ${RESULT}"
dkms remove ${DRV_NAME}/${DRV_VERSION} --all
echo "Removing ${OPTIONS_FILE} from: /etc/modprobe.d"
rm -f /etc/modprobe.d/${OPTIONS_FILE}
echo "Removing source files from: /usr/src/${DRV_NAME}-${DRV_VERSION}"
rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION}
echo "Cleanup complete"
echo "dkms status:"
dkms status
exit $RESULT
fi
dkms install ${DRV_NAME}/${DRV_VERSION}
RESULT=$?
if [[ "$RESULT" != "0" ]]; then
echo "An error occurred while running: dkms install : ${RESULT}"
dkms remove ${DRV_NAME}/${DRV_VERSION} --all
echo "Removing ${OPTIONS_FILE} from: /etc/modprobe.d"
rm -f /etc/modprobe.d/${OPTIONS_FILE}
echo "Removing source files from: /usr/src/${DRV_NAME}-${DRV_VERSION}"
rm -rf /usr/src/${DRV_NAME}-${DRV_VERSION}
echo "Cleanup complete"
dkms status
exit $RESULT
else
echo "dkms status:"
dkms status
echo "The driver was installed successfully."
exit 0
fi