-
Notifications
You must be signed in to change notification settings - Fork 5
/
unraid-r8126.plg
197 lines (172 loc) · 7.33 KB
/
unraid-r8126.plg
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "r8126-driver">
<!ENTITY author "jinlife">
<!ENTITY version "2024.06.12">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unraid-r8125-r8152-driver/main">
<!ENTITY pluginURL "&gitURL;/unraid-r8126.plg">
<!ENTITY plugin "/boot/config/plugins/&name;">
<!ENTITY emhttp "/usr/local/emhttp/plugins/&name;">
<!ENTITY packages "/boot/config/plugins/&name;/packages">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" min="6.12.10" support="https://forums.unraid.net/topic/141349-plugin-realtek-r8125-r8168-and-r8152-drivers/">
<CHANGES>
###2024.06.12
- Initial release v10.013.00
</CHANGES>
<FILE Name="&emhttp;/README.md">
<INLINE>
**RTL8126 Drivers**
This package contains the Realtek OOT Drivers and installs them, a reboot is required after installing the plugin (upgrading to a newer Unraid version maybe needs a second reboot too).
Source: https://github.com/jinlife/unraid-r8125-r8152-driver
</INLINE>
</FILE>
<FILE Run="/bin/bash">
<INLINE>
download() {
# Download r8126 package
if wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}" "${DL_URL}/${LAT_PACKAGE}" 2>/dev/null ; then
wget -q -nc --show-progress --progress=bar:force:noscroll -O "&packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5" "${DL_URL}/${LAT_PACKAGE}.md5"
if [ "$(md5sum &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE} | awk '{print $1}')" != "$(cat &packages;/${KERNEL_V%%-*}/${LAT_PACKAGE}.md5 | awk '{print $1}')" ]; then
echo
echo "---CHECKSUM ERROR!---"
rm -rf &plugin; &emhttp;
if [ ! -f /boot/config/plugins/unraid-r8168.plg ] && [ ! -f /boot/config/plugins/unraid-r8125.plg ]; then
remove_blacklist_r8169
fi
exit 1
fi
echo
echo "-------------------Sucessfully downloaded RTL8126 package-------------------"
else
echo
echo "-----------------------Can't download RTL8126 package-----------------------"
rm -rf &plugin; &emhttp;
if [ ! -f /boot/config/plugins/unraid-r8168.plg ] && [ ! -f /boot/config/plugins/unraid-r8125.plg ]; then
remove_blacklist_r8169
fi
exit 1
fi
}
check() {
if ! ls -1 &packages;/${KERNEL_V%%-*}/ | grep -q "${PACKAGE}" ; then
LAT_PACKAGE="$(wget -qO- https://api.github.com/repos/jinlife/unraid-r8125-r8152-driver/releases/tags/${KERNEL_V} | jq -r '.assets[].name' | grep "${PACKAGE}" | grep -E -v '\.md5$' | sort -V | tail -1)"
echo
echo "-----------------------Downloading RTL8126 package!-------------------------"
echo "--------This could take some time, please don't close this window!----------"
download
else
echo
echo "-----------------------RTL8126 package found locally------------------------"
fi
}
remove_blacklist_r8169() {
if [ "$(grep -v "blacklist" /boot/config/modprobe.d/r8169.conf 2>/dev/null)" ]; then
sed -i '/blacklist r8169/d' /boot/config/modprobe.d/r8169.conf 2>/dev/null
else
rm -rf /boot/config/modprobe.d/r8169.conf 2>/dev/null
fi
/sbin/modprobe r8169 2>/dev/null
/etc/rc.d/rc.inet1 restart 2>/dev/null
}
# Define Variables
KERNEL_V="$(uname -r)"
PACKAGE="r8126"
DL_URL="https://github.com/jinlife/unraid-r8125-r8152-driver/releases/download/$KERNEL_V"
if [ ! -d "&packages;/${KERNEL_V%%-*}" ]; then
mkdir -p "&packages;/${KERNEL_V%%-*}"
fi
# Check for old packages
rm -rf $(ls -d &packages;/* | grep -v "${KERNEL_V%%-*}")
# Check if RTL8126 package is already downloaded and installed
check
if [ ! -f "&plugin;/&name;.png" ]; then
wget -q -nc --show-progress --progress=bar:force:noscroll -O "&plugin;/&name;.png" "https://raw.githubusercontent.com/ich777/docker-templates/master/ich777/images/realtek.png"
fi
#Install icon
if [ ! -f "&emhttp;/images/&name;.png" ]; then
if [ ! -d "&emhttp;/images" ]; then
mkdir -p &emhttp;/images
fi
cp &plugin;/&name;.png &emhttp;/images/
fi
#Check if r8169 module is already blacklisted
if [ ! "$(grep "blacklist" /boot/config/modprobe.d/r8169.conf 2>/dev/null)" ]; then
if [ ! -d /boot/config/modprobe.d ]; then
mkdir -p /boot/config/modprobe.d
fi
echo "----Blacklisting r8169 module to ensure module r8126 is working properly----"
echo "blacklist r8169" >> /boot/config/modprobe.d/r8169.conf
fi
# Check if module is found, if not display message to reboot
if modinfo r8126 2>/dev/null ; then
echo
echo "-----------Nothing to do, OOT RTL8126 package already installed-------------"
echo
else
echo
echo "-----------Please reboot your server to activate the OOT driver!------------"
echo
fi
#Check if Plugin Update Helper is downloaded and up-to-date
if [ ! -f &plugin;/plugin_update_helper ]; then
wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper"
else
CUR_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')"
if [ ! -s /tmp/update-helper ]; then
echo "$(wget -T5 -qO- https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper | grep -E "Plugin-Update-Helper version:" | awk '{print $4}')" > /tmp/update-helper
AVAIL_V="$(cat /tmp/update-helper)"
else
AVAIL_V="$(cat /tmp/update-helper)"
fi
if [ ! -z "$AVAIL_V" ]; then
COMPARE="$(sort -V <(echo -e "${AVAIL_V}\n$CUR_V") | tail -1)"
if [ "$CUR_V" != "$COMPARE" ]; then
wget -q -T 5 -O &plugin;/plugin_update_helper "https://raw.githubusercontent.com/ich777/unraid-plugin_update_helper/master/plugin_update_helper"
fi
fi
fi
#Check if Plugin Update Helper is installed and up to date
if [ ! -f /usr/bin/plugin_update_helper ]; then
cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper
chmod +x /usr/bin/plugin_update_helper
else
PLUGIN_V="$(grep -E "Plugin-Update-Helper version:" &plugin;/plugin_update_helper | awk '{print $4}')"
INST_V="$(grep -E "Plugin-Update-Helper version:" /usr/bin/plugin_update_helper | awk '{print $4}')"
COMPARE="$(sort -V <(echo -e "${PLUGIN_V}\n$INST_V") | tail -1)"
if [ "$INST_V" != "$COMPARE" ]; then
kill $(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}') 2>/dev/null
sleep 1
cp &plugin;/plugin_update_helper /usr/bin/plugin_update_helper
chmod +x /usr/bin/plugin_update_helper
fi
fi
#Start Plugin Update Helper
if [ -z "$(ps aux | grep -E "inotifywait -q /boot/changes.txt -e move_self,delete_self" | grep -v "grep -E inotifywait" | awk '{print $2}')" ]; then
echo "/usr/bin/plugin_update_helper" | at now -M > /dev/null 2>&1
fi
</INLINE>
</FILE>
<FILE Run="/bin/bash" Method="remove">
<INLINE>
echo "--------------------------"
echo "---Uninstalling RTL8126---"
echo "--------------------------"
# Remove plugin related files
if [ ! -f /boot/config/plugins/unraid-r8168.plg ] && [ ! -f /boot/config/plugins/unraid-r8125.plg ]; then
if [ "$(grep -v "blacklist" /boot/config/modprobe.d/r8169.conf 2>/dev/null)" ]; then
sed -i '/blacklist r8169/d' /boot/config/modprobe.d/r8169.conf 2>/dev/null
else
rm -rf /boot/config/modprobe.d/r8169.conf 2>/dev/null
fi
fi
rm -rf &emhttp;
rm -rf &plugin;
echo
echo "-----------------------------------------------------"
echo "---RTL8126 uninstalled, please reboot your server!---"
echo "-----------------------------------------------------"
echo
</INLINE>
</FILE>
</PLUGIN>