This repository was archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathunRAIDServer.plg
More file actions
270 lines (257 loc) · 9.36 KB
/
unRAIDServer.plg
File metadata and controls
270 lines (257 loc) · 9.36 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "unRAIDServer">
<!ENTITY author "LimeTech">
<!ENTITY version "6.5.3">
<!ENTITY category "stable">
<!ENTITY pluginURL "https://s3.amazonaws.com/dnld.lime-technology.com/&category;/&name;.plg">
<!ENTITY zip "https://s3.amazonaws.com/dnld.lime-technology.com/&category;/&name;-&version;-x86_64.zip">
<!ENTITY md5 "https://s3.amazonaws.com/dnld.lime-technology.com/&category;/&name;-&version;-x86_64.md5">
<!ENTITY files "bz*,make_bootable.bat,make_bootable_linux,make_bootable_mac,memtest,*.txt,syslinux/syslinux.cfg-">
<!ENTITY infozip "infozip-6.0-i486-1.txz">
]>
<PLUGIN name="&name;"
author="&author;"
version="&version;"
category="&category;"
pluginURL="&pluginURL;">
<CHANGES>
<![CDATA[
### Version 6.5.3 2018-06-12
Linux kernel:
- version 4.14.49
- set CONFIG_PREEMPT=no and CONFIG_PREEMPT_VOLUNTARY=yes
Management:
- Small update to create_network_ini to suppress progress information when using cURL.
- update smartmontools drivedb and hwdata/{pci.ids,usb.ids,oui.txt,manuf.txt}
- webgui: Remove unused tags from docker templates
- webgui: apcups: ensure numeric fields are 0 if the values are empty
- webgui: bug fix: prevent deleting user template when (letter case) renaming a docker container
- webgui: Strip HTML from back-end
- webgui: make entire menu items clickable for gray and azure themes
]]>
</CHANGES>
<!--
Be compatible with unRAID-5 installplg
-->
<FILE Name="/tmp/&name;.sh" Run="/bin/bash">
<INLINE>
rm /tmp/&name;.sh
# cleanup possibly failed previous download/install attempt
rm -rf /tmp/&name;*
mkdir /tmp/&name;
# check if this is unRAID-5
source /etc/unraid-version
if [[ "${version:0:2}" == "5." ]]; then
# prevent endless install loop
rm -rf /boot/plugins/&name;.plg
rm -rf /boot/config/plugins/&name;.plg
# check if 64-bit capable CPU
if ! grep -q " lm" /proc/cpuinfo ; then
echo "CPU is not 64-bit capable"
exit 1
fi
# Wait until network is ready by pinging google - thanks bonienl!
ip=8.8.4.4
timer=30
while [[ $timer -gt 0 ]]; do
if [[ -n $(route -n|awk '/^0.0.0.0/{print $2}') && $(ping -qnc1 $ip|awk '/received/{print $4}') -eq 1 ]]; then
break
fi
((timer--))
sleep 1
done
if [[ $timer -eq 0 ]]; then
echo "No network communication !!!"
exit 1
fi
# unRAID-5 needs infozip
if [ ! -f /boot/extra/&infozip; ]; then
echo "Downloading &infozip; package"
mkdir -p /boot/extra
wget http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/a/&infozip; -O /boot/extra/&infozip;
upgradepkg --install-new /boot/extra/&infozip;
fi
# download the release
if ! wget --no-check-certificate &zip; -O /tmp/&name;.zip ; then
echo "&zip; download error $?"
exit 1
fi
if ! wget --no-check-certificate &md5; -O /tmp/&name;.md5 ; then
echo "&md5; download error $?"
exit 1
fi
fi
</INLINE>
</FILE>
<!--
Download release from S3
For unRAID-5 this will be skipped because already downloaded above
For unRAID-6 we download here, verifying certificiate
-->
<FILE Name="/tmp/&name;.zip">
<URL>&zip;</URL>
</FILE>
<FILE Name="/tmp/&name;.md5">
<URL>&md5;</URL>
</FILE>
<FILE Name="/tmp/&name;.sh" Run="/bin/bash">
<INLINE>
rm /tmp/&name;.sh
# check download and extract
sum1=$(/usr/bin/md5sum /tmp/&name;.zip)
sum2=$(cat /tmp/&name;.md5)
if [[ "${sum1:0:32}" != "${sum2:0:32}" ]]; then
echo "wrong md5"
exit 1
fi
if ! unzip -d /tmp/&name; /tmp/&name;.zip ; then
echo "unzip error $?"
exit 1
fi
# check if enough free space on flash
have=$(df -k /boot | awk ' END { print $4 } ')
need=$(du -Ssk /tmp/&name; | awk ' END { print $1 } ')
source /etc/unraid-version
if [[ "${version:0:2}" == "5." ]]; then
# to permit another upgrade
need=$(($need * 2))
fi
# add some margin for possible additional config info
need=$(($need + 8192))
if [[ $need -gt $have ]]; then
echo "boot device shows $have free but upgrade needs $need"
exit 1
fi
# move release files to flash
mkdir -p /boot/&name;
rm -rf /boot/&name;/*
if ! mv /tmp/&name;/{&files;} /boot/&name; ; then
echo "flash write error $?, maybe corrupted?"
rm -rf /boot/&name;/*
exit 1
fi
# preserve previous version
source /etc/unraid-version
if [[ "${version:0:2}" == "6." ]]; then
mkdir -p /boot/previous
rm -rf /boot/previous/*
mv /boot/{&files;} /boot/previous
else
mkdir -p /boot/unRAID5
rm -rf /boot/unRAID5/*
# preserve all files in root of flash except ldlinux.sys needed to boot
find /boot -maxdepth 1 -type f -not -name ldlinux.sys -exec mv {} /boot/unRAID5 \;
# preserve a few directories
mv /boot/extra /boot/unRAID5 &> /dev/null
mv /boot/packages /boot/unRAID5 &> /dev/null
mv /boot/plugins /boot/unRAID5 &> /dev/null
mkdir /boot/unRAID5/config
mv /boot/config/plugins /boot/unRAID5/config &> /dev/null
# grab a fresh 'go' file
mv /boot/config/go /boot/unRAID5/config
cp /tmp/&name;/config/go /boot/config
# ensure key file is in the 'config' directory
cp /boot/unRAID5/*.key /boot/config &> /dev/null
fi
# move new version files into place
mv /boot/&name;/* /boot
rmdir /boot/&name;
# move the new syslinux.cfg- in to the syslinux folder
if [[ -f /boot/syslinux.cfg- ]]; then
mv /boot/syslinux.cfg- /boot/syslinux
fi
# if unRaid-6 replace the readme file
if [[ "${version:0:2}" == "6." ]]; then
echo "**REBOOT REQUIRED!**" > /usr/local/emhttp/plugins/&name;/README.md
fi
# if unRaid-6.3 ensure GUI Safe Mode syslinux option exists
if [[ "${version:0:3}" == "6.3" ]]; then
if ! grep -q 'initrd=/bzroot,/bzroot-gui unraidsafemode' /boot/syslinux/syslinux.cfg &> /dev/null ; then
sed -i 's|label Memtest86+|label unRAID OS GUI Safe Mode (no plugins)\r\n kernel /bzimage\r\n append initrd=/bzroot,/bzroot-gui unraidsafemode\r\nlabel Memtest86+|g' /boot/syslinux/syslinux.cfg &> /dev/null
fi
fi
# when upgrading any version prior to 6.2
if [[ "${version:0:3}" < "6.2" ]]; then
if ! grep -q '/bzroot-gui' /boot/syslinux/syslinux.cfg &> /dev/null ; then
sed -i 's|menu title Lime Technology\r|menu title Lime Technology, Inc.\r|g' /boot/syslinux/syslinux.cfg &> /dev/null
sed -i 's|label unRAID OS Safe Mode (no plugins)|label unRAID OS GUI Mode\r\n kernel /bzimage\r\n append initrd=/bzroot,/bzroot-gui\r\nlabel unRAID OS Safe Mode (no plugins, no GUI)|g' /boot/syslinux/syslinux.cfg &> /dev/null
fi
fi
# when upgrading any version prior to 6.1
if [[ "${version:0:3}" < "6.1" ]]; then
if ! grep -q 'shareDisk' /boot/config/share.cfg &> /dev/null ; then
echo 'shareDisk="yes"' >> /boot/config/share.cfg
fi
fi
# when upgrading from 6.0.x
if [[ "${version:0:3}" == "6.0" ]]; then
sed -i 's|dynamix.docker.manager/dockerupdate.php|dynamix.docker.manager/scripts/dockerupdate.php|g' /boot/config/plugins/dynamix/docker-update.cron &> /dev/null
sed -i 's|sbin/monitor|emhttp/plugins/dynamix/scripts/monitor|g' /boot/config/plugins/dynamix/monitor.cron &> /dev/null
sed -i 's|/root/mdcmd|/usr/local/sbin/mdcmd|g' /boot/config/plugins/dynamix/parity-check.cron &> /dev/null
sed -i 's|sbin/plugincheck|emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck|g' /boot/config/plugins/dynamix/plugin-check.cron &> /dev/null
sed -i 's|sbin/statuscheck|emhttp/plugins/dynamix/scripts/statuscheck|g' /boot/config/plugins/dynamix/status-check.cron &> /dev/null
fi
# if template-repos does not exist
if [[ ! -e /boot/config/plugins/dockerMan/template-repos ]]; then
mkdir -p /boot/config/plugins/dockerMan
echo "https://github.com/limetech/docker-templates" > /boot/config/plugins/dockerMan/template-repos
fi
# correct initial EFI syslinux.cfg
if [[ -d /boot/EFI/boot && "${version}" == "6.4.0-rc4" ]]; then
cp /tmp/&name;/EFI-/boot/syslinux.cfg /boot/EFI/boot
fi
# if EFI or EFI- directory does not exist
if [[ ! -e /boot/EFI && ! -e /boot/EFI- ]]; then
mv /tmp/&name;/EFI- /boot
sed -i 's|default /syslinux/menu.c32|default menu.c32|g' /boot/syslinux/syslinux.cfg &> /dev/null
fi
# if metric appended to GATEWAY get rid of it
if [[ -f /boot/config/network.cfg ]]; then
sed -ri 's|^(GATEWAY.+)#[0-9]+|\1|' /boot/config/network.cfg
fi
echo "syncing - please wait..."
sync
echo "Update successful - PLEASE REBOOT YOUR SERVER"
</INLINE>
</FILE>
<!--
The 'remove' script.
-->
<FILE Name="/tmp/&name;.sh" Run="/bin/bash" Method="remove">
<INLINE>
rm /tmp/&name;.sh
# unRAID-5 doesn't support 'remove' method, so we're done
source /etc/unraid-version
if [[ "${version:0:2}" == "5." ]]; then
exit 0
fi
if [[ -d /boot/previous ]]; then
# restore previous unRAID-6 release
mv /boot/previous/* /boot
rmdir /boot/previous
echo "**REBOOT REQUIRED!**" > /usr/local/emhttp/plugins/&name;/README.md
elif [[ -d /boot/unRAID5 ]]; then
# restore previous unRAID-5 release
rm -rf /boot/extra
mv /boot/unRAID5/extra /boot &> /dev/null
rm -rf /boot/plugins
mv /boot/unRAID5/plugins /boot &> /dev/null
rm -rf /boot/packages
mv /boot/unRAID5/packages /boot &> /dev/null
rm -rf /boot/config/plugins
mv /boot/unRAID5/config/plugins /boot/config &> /dev/null
mv /boot/unRAID5/config/go /boot/config
rmdir /boot/unRAID5/config
mv /boot/unRAID5/* /boot
rmdir /boot/unRAID5
else
echo "Cannot remove, no previous version"
exit 1
fi
echo "syncing..."
sync
echo "Remove successful - PLEASE REBOOT YOUR SERVER"
</INLINE>
</FILE>
</PLUGIN>