mirror of
https://github.com/unraid/api.git
synced 2026-05-24 02:08:57 -05:00
refactor(plg): remove upc js download on install (#694)
This commit is contained in:
@@ -137,73 +137,6 @@ exit 0
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<!-- download and install JavaScript web components -->
|
||||
<!-- (installing this won't hurt anything if we exit the installer later) -->
|
||||
<FILE Run="/bin/bash" Method="install">
|
||||
<INLINE>
|
||||
js_dl_server=&js_dl_server;
|
||||
<![CDATA[
|
||||
version=
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/unraid-version
|
||||
|
||||
# skip this install block on isUnsupportedVersion
|
||||
if [[ "${version:0:3}" == "6.9" || "${version:0:7}" == "6.10.0-" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "⚠️ Do not close this window yet"
|
||||
echo
|
||||
|
||||
# manually download the JavaScript web components
|
||||
JS_FLASH_DEST=/boot/config/plugins/dynamix.my.servers/webComps/
|
||||
JS_FINAL_DEST=/usr/local/emhttp/plugins/dynamix.my.servers/webComps/
|
||||
JS_FILE=unraid.min.js
|
||||
|
||||
echo "🕹️ Installing JavaScript web components"
|
||||
|
||||
# on first install, no limits to wget retries/timeouts.
|
||||
# on subsequent installs, don't let wget prevent Unraid from booting when network is down
|
||||
WGET_LIMIT=
|
||||
[[ -f "${JS_FLASH_DEST}${JS_FILE}" ]] && WGET_LIMIT=" -t 1 -T 20 "
|
||||
|
||||
# always re-download latest unraid.min.js
|
||||
rm -f "/tmp/${JS_FILE}.tmp1"
|
||||
rm -f "/tmp/${JS_FILE}.tmp2"
|
||||
|
||||
wget ${WGET_LIMIT} -q --compression=auto --no-cache "${js_dl_server}/webComps/${JS_FILE}" -O "/tmp/${JS_FILE}.tmp1" &>/dev/null
|
||||
if [[ -f "/tmp/${JS_FILE}.tmp1" && -s "/tmp/${JS_FILE}.tmp1" ]]; then
|
||||
# simple validatation that the file was downloaded correctly
|
||||
if grep -q "sourceMappingURL=unraid.min.js.map" "/tmp/${JS_FILE}.tmp1"; then
|
||||
# remove source mapping from js
|
||||
head -n -1 "/tmp/${JS_FILE}.tmp1" >"/tmp/${JS_FILE}.tmp2"
|
||||
rm "/tmp/${JS_FILE}.tmp1"
|
||||
fi
|
||||
fi
|
||||
|
||||
# if /tmp/${JS_FILE}.tmp2 was downloaded above, move it to JS_FLASH_DEST
|
||||
[[ -f "/tmp/${JS_FILE}.tmp2" ]] && mkdir -p "${JS_FLASH_DEST}" && mv "/tmp/${JS_FILE}.tmp2" "${JS_FLASH_DEST}${JS_FILE}"
|
||||
|
||||
# NOTE: if download was not successful, there may still be a previous copy in JS_FLASH_DEST
|
||||
# if unraid.min.js exists in JS_FLASH_DEST, copy it from JS_FLASH_DEST to JS_FINAL_DEST
|
||||
# @TODO: validate that the unraid.min.js in JS_FLASH_DEST is not older than an existing one in JS_FINAL_DEST
|
||||
[[ -f "${JS_FLASH_DEST}${JS_FILE}" ]] && mkdir -p "${JS_FINAL_DEST}" && cp "${JS_FLASH_DEST}${JS_FILE}" "${JS_FINAL_DEST}"
|
||||
|
||||
# NOTE: if file does not exist in JS_FLASH_DEST, there should still be a previous copy in JS_FINAL_DEST (unless Unraid 6.9)
|
||||
# if not, we have to exit
|
||||
[[ ! -f "${JS_FINAL_DEST}${JS_FILE}" ]] && echo "⚠️ Install failed - ${JS_FILE} missing" && exit 1
|
||||
echo "✅ Finished installing web components"
|
||||
|
||||
echo
|
||||
echo "⚠️ Do not close this window yet"
|
||||
echo
|
||||
|
||||
exit 0
|
||||
]]>
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<FILE Run="/bin/bash" Method="remove">
|
||||
<INLINE>
|
||||
<![CDATA[
|
||||
|
||||
Reference in New Issue
Block a user