feat: track node version in slackware

This commit is contained in:
Eli Bosley
2024-11-06 09:13:44 -05:00
parent 972a19be04
commit 9d2796f2c9
2 changed files with 137 additions and 141 deletions

View File

@@ -11,29 +11,28 @@
<!ENTITY SHA256 ""> <!ENTITY SHA256 "">
<!ENTITY API_version ""> <!ENTITY API_version "">
<!ENTITY API_SHA256 ""> <!ENTITY API_SHA256 "">
<!ENTITY NODE "nodejs-20.18.0-x86_64-1.txz"> <!ENTITY NODE "">
<!ENTITY NODE_SHA256 "332f22a2a6722e9fad92b8d1eeaded228a6499b7335b2b54ee99c55b4fe49742"> <!ENTITY NODE_SHA256 "">
<!ENTITY NGHTTP3 "nghttp3-1.6.0-x86_64.txz"> <!ENTITY NODE_TXZ "">
<!ENTITY NGHTTP3_SHA256 "936c40071a99745efa35b1b8c9252b6d25b54e264cfafafca15b3f41d65ab8a6"> <!ENTITY NGHTTP3 "">
<!ENTITY NGHTTP3_TXZ "">
<!ENTITY NGHTTP3_SHA256 "">
<!ENTITY MAIN_TXZ ""> <!ENTITY MAIN_TXZ "">
<!ENTITY API_TGZ ""> <!ENTITY API_TGZ "">
]> ]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" launch="&launch;" min="6.9.0-rc1" icon="globe"> <PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" launch="&launch;" min="6.9.0-rc1" icon="globe">
<CHANGES> <CHANGES>
##a long time ago in a galaxy far far away ##a long time ago in a galaxy far far away
- initial release - initial release
</CHANGES> </CHANGES>
<!-- prevent prod plugin from installing when staging already installed, and vice versa --> <!-- prevent prod plugin from installing when staging already installed, and vice versa -->
<FILE Run="/bin/bash" Method="install"> <FILE Run="/bin/bash" Method="install">
<INLINE> <INLINE>
name="&name;" name="&name;" version="&version;" API_version="&API_version;" PLGTYPE="&env;"
version="&version;" <![CDATA[
API_version="&API_version;"
PLGTYPE="&env;"
<![CDATA[
echo "Installing ${name}.plg ${version} with Unraid API ${API_version}" echo "Installing ${name}.plg ${version} with Unraid API ${API_version}"
if [ "${PLGTYPE}" = "production" ] && [ -f /boot/config/plugins/dynamix.unraid.net.staging.plg ]; then if [ "${PLGTYPE}" = "production" ] && [ -f /boot/config/plugins/dynamix.unraid.net.staging.plg ]; then
echo "⚠️ Please uninstall the Unraid Connect staging plugin before installing the production version" echo "⚠️ Please uninstall the Unraid Connect staging plugin before installing the production version"
@@ -45,13 +44,13 @@ if [ "${PLGTYPE}" = "staging" ] && [ -f /boot/config/plugins/dynamix.unraid.net.
fi fi
exit 0 exit 0
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
<!-- gzip check, DNS check, then validate files before doing anything destructive --> <!-- gzip check, DNS check, then validate files before doing anything destructive -->
<FILE Run="/bin/bash" Method="install"> <FILE Run="/bin/bash" Method="install">
<INLINE> <INLINE>
<![CDATA[ <![CDATA[
version= version=
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source /etc/unraid-version source /etc/unraid-version
@@ -65,8 +64,7 @@ fi
dnscheck() { dnscheck() {
HOST=$1 HOST=$1
if [ -x /usr/bin/host ] && ! /usr/bin/host -W 10 "${HOST}" &>/dev/null; then if [ -x /usr/bin/host ] && ! /usr/bin/host -W 10 "${HOST}" &>/dev/null; then
echo "⚠️ Warning: Your DNS server (${DNS_SERVER1}) is unable to resolve '${HOST}'" echo "⚠️ Warning: Your DNS server (${DNS_SERVER1}) is unable to resolve '${HOST}'" DNSERR=yes
DNSERR=yes
fi fi
} }
@@ -92,8 +90,7 @@ sha256check() {
FILE=$1 FILE=$1
EXPECTED=$2 EXPECTED=$2
if [[ -f "${FILE}" ]]; then if [[ -f "${FILE}" ]]; then
echo -n "Validating ${FILE}... " echo -n "Validating ${FILE}... " ACTUAL=$(sha256sum "${FILE}" 2>/dev/null | grep -Po '^\S+')
ACTUAL=$(sha256sum "${FILE}" 2>/dev/null | grep -Po '^\S+')
if [[ "$EXPECTED" != "$ACTUAL" ]]; then if [[ "$EXPECTED" != "$ACTUAL" ]]; then
rm "${FILE}" rm "${FILE}"
echo " old. Deleted file." echo " old. Deleted file."
@@ -106,48 +103,48 @@ sha256check() {
sha256check "&source;.txz" "&SHA256;" sha256check "&source;.txz" "&SHA256;"
sha256check "/boot/config/plugins/dynamix.my.servers/unraid-api.tgz" "&API_SHA256;" sha256check "/boot/config/plugins/dynamix.my.servers/unraid-api.tgz" "&API_SHA256;"
exit 0 exit 0
</INLINE> </INLINE>
</FILE> </FILE>
<!-- download node --> <!-- download node -->
<FILE Name="/boot/config/plugins/dynamix.my.servers/&NODE;" Run="upgradepkg --install-new" max="7.0.0-beta.5"> <FILE Name="/boot/config/plugins/dynamix.my.servers/&NODE;" Run="upgradepkg --install-new" max="7.0.0-beta.5">
<URL>https://mirrors.slackware.com/slackware/slackware64-current/slackware64/l/&NODE;</URL> <URL>&NODE_TXZ;</URL>
<SHA256>&NODE_SHA256;</SHA256> <SHA256>&NODE_SHA256;</SHA256>
</FILE> </FILE>
<!-- download nghttp3 --> <!-- download nghttp3 -->
<FILE name="/boot/config/plugins/dynamix.my.servers/&NGHTTP3;" Run="upgradepkg --install-new" max="7.0.0-beta.5"> <FILE name="/boot/config/plugins/dynamix.my.servers/&NGHTTP3;" Run="upgradepkg --install-new" max="7.0.0-beta.5">
<URL>https://mirrors.slackware.com/slackware/slackware64-current/slackware64/n/&NGHTTP3;</URL> <URL>&NGHTTP3_TXZ;</URL>
<SHA256>&NGHTTP3_SHA256;</SHA256> <SHA256>&NGHTTP3_SHA256;</SHA256>
</FILE> </FILE>
<!-- download main txz --> <!-- download main txz -->
<FILE Name="&source;.txz"> <FILE Name="&source;.txz">
<URL>&MAIN_TXZ;</URL> <URL>&MAIN_TXZ;</URL>
<SHA256>&SHA256;</SHA256> <SHA256>&SHA256;</SHA256>
</FILE> </FILE>
<!-- download unraid-api --> <!-- download unraid-api -->
<FILE Name="/boot/config/plugins/dynamix.my.servers/unraid-api.tgz"> <FILE Name="/boot/config/plugins/dynamix.my.servers/unraid-api.tgz">
<URL>&API_TGZ;</URL> <URL>&API_TGZ;</URL>
<SHA256>&API_SHA256;</SHA256> <SHA256>&API_SHA256;</SHA256>
</FILE> </FILE>
<FILE Run="/bin/bash" Method="install"> <FILE Run="/bin/bash" Method="install">
<INLINE> <INLINE>
MAINTXZ="&source;.txz" MAINTXZ="&source;.txz"
<![CDATA[ <![CDATA[
# before proceeding with install, doubly confirm downloaded files exist. just being pedantic. # before proceeding with install, doubly confirm downloaded files exist. just being pedantic.
FILE=${MAINTXZ} && [[ ! -f "$FILE" ]] && echo "⚠️ file missing - $FILE" && exit 1 FILE=${MAINTXZ} && [[ ! -f "$FILE" ]] && echo "⚠️ file missing - $FILE" && exit 1
FILE=/boot/config/plugins/dynamix.my.servers/unraid-api.tgz && [[ ! -f "$FILE" ]] && echo "⚠️ file missing - $FILE" && exit 1 FILE=/boot/config/plugins/dynamix.my.servers/unraid-api.tgz && [[ ! -f "$FILE" ]] && echo "⚠️ file missing - $FILE" && exit 1
exit 0 exit 0
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
<FILE Run="/bin/bash" Method="remove"> <FILE Run="/bin/bash" Method="remove">
<INLINE> <INLINE>
<![CDATA[ <![CDATA[
version= version=
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source /etc/unraid-version source /etc/unraid-version
@@ -158,14 +155,14 @@ echo
exit 0 exit 0
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
<!-- disable features on uninstall --> <!-- disable features on uninstall -->
<!-- NOTE: this script is PHP not bash --> <!-- NOTE: this script is PHP not bash -->
<FILE Run="/usr/bin/php" Method="remove"> <FILE Run="/usr/bin/php" Method="remove">
<INLINE> <INLINE>
<![CDATA[ <![CDATA[
<? <?
$msini = @parse_ini_file('/boot/config/plugins/dynamix.my.servers/myservers.cfg', true); $msini = @parse_ini_file('/boot/config/plugins/dynamix.my.servers/myservers.cfg', true);
@@ -221,15 +218,15 @@ if ($msini !== false) {
} }
exit(0); exit(0);
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
<!-- disable features when upgrading on unsupported OS versions --> <!-- disable features when upgrading on unsupported OS versions -->
<!-- duplicated from above because the script can't distinguish between install and remove --> <!-- duplicated from above because the script can't distinguish between install and remove -->
<!-- NOTE: this script is PHP not bash --> <!-- NOTE: this script is PHP not bash -->
<FILE Run="/usr/bin/php" Method="install"> <FILE Run="/usr/bin/php" Method="install">
<INLINE> <INLINE>
<![CDATA[ <![CDATA[
<? <?
$ver = @parse_ini_file('/etc/unraid-version', true)['version']; $ver = @parse_ini_file('/etc/unraid-version', true)['version'];
$msini = @parse_ini_file('/boot/config/plugins/dynamix.my.servers/myservers.cfg', true); $msini = @parse_ini_file('/boot/config/plugins/dynamix.my.servers/myservers.cfg', true);
@@ -287,14 +284,14 @@ if ($msini !== false) {
} }
exit(0); exit(0);
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
<!-- uninstall existing plugin during update or removal --> <!-- uninstall existing plugin during update or removal -->
<FILE Run="/bin/bash" Method="install remove"> <FILE Run="/bin/bash" Method="install remove">
<INLINE> <INLINE>
MAINNAME="&name;" MAINNAME="&name;"
<![CDATA[ <![CDATA[
version= version=
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source /etc/unraid-version source /etc/unraid-version
@@ -315,29 +312,7 @@ if [ -e /etc/rc.d/rc.unraid-api ]; then
# uninstall the main source package # uninstall the main source package
[[ -f "/var/log/packages/${MAINNAME}" ]] && removepkg --terse "${MAINNAME}" [[ -f "/var/log/packages/${MAINNAME}" ]] && removepkg --terse "${MAINNAME}"
# restore stock files # restore stock files
FILE=/usr/local/emhttp/plugins/dynamix/DisplaySettings.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix/DisplaySettings.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix/Registration.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix/include/ProvisionCert.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix/include/UpdateDNS.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix/include/Wrappers.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/Downgrade.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/Update.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/include/ShowChanges.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/showchanges && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/MyServers.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/Registration.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers2.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/sbin/upgradepkg && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/reboot-details.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/translations.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE" DIR=/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components
FILE=/usr/local/emhttp/plugins/dynamix/Registration.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix/include/DefaultPageLayout.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix/include/ProvisionCert.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix/include/UpdateDNS.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix/include/Wrappers.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/Downgrade.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/Update.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/include/ShowChanges.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/showchanges && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.plugin.manager/include/UnraidCheck.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/Connect.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/MyServers.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/Registration.page && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers2.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/sbin/upgradepkg && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/reboot-details.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
FILE=/usr/local/emhttp/plugins/dynamix.my.servers/include/translations.php && [[ -f "$FILE-" ]] && mv -f "$FILE-" "$FILE"
DIR=/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components
# certain instances where the directory is not present and others where it is, ensure we delete it before we restore it # certain instances where the directory is not present and others where it is, ensure we delete it before we restore it
if [[ -d "$DIR" ]]; then if [[ -d "$DIR" ]]; then
rm -rf "$DIR" rm -rf "$DIR"
@@ -377,20 +352,18 @@ if [ -e /etc/rc.d/rc.unraid-api ]; then
fi fi
exit 0 exit 0
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
<!-- install all the things --> <!-- install all the things -->
<FILE Run="/bin/bash" Method="install"> <FILE Run="/bin/bash" Method="install">
<INLINE> <INLINE>
PLGTYPE="&env;" PLGTYPE="&env;" MAINTXZ="&source;.txz"
MAINTXZ="&source;.txz" <![CDATA[
<![CDATA[
appendTextIfMissing() { appendTextIfMissing() {
FILE="$1" FILE="$1" TEXT="$2"
TEXT="$2"
if test -f "${FILE}" && ! grep -q "${TEXT}" "${FILE}" &>/dev/null; then if test -f "${FILE}" && ! grep -q "${TEXT}" "${FILE}" &>/dev/null; then
echo "${TEXT}" >>"${FILE}" echo "${TEXT}">>"${FILE}"
fi fi
} }
@@ -487,9 +460,9 @@ if [[ -n $LINENUM ]]; then
cp -f "$FILE" "$FILE-" cp -f "$FILE" "$FILE-"
# sed should work, but it is very difficult to escape the search text # sed should work, but it is very difficult to escape the search text
# instead, make a new file containing everything before LINENUM, then the replacement text, then everything after LINENUM # instead, make a new file containing everything before LINENUM, then the replacement text, then everything after LINENUM
head -$((LINENUM-1)) "$FILE" > "$FILE~" head -$((LINENUM-1)) "$FILE"> "$FILE~"
echo '<unraid-i18n-host><unraid-header-os-version></unraid-header-os-version></unraid-i18n-host>' >> "$FILE~" echo '<unraid-i18n-host><unraid-header-os-version></unraid-header-os-version></unraid-i18n-host>' >> "$FILE~"
tail +$((LINENUM+1)) "$FILE" >> "$FILE~" tail +$((LINENUM+1)) "$FILE">> "$FILE~"
# disable these lines: <?$readme = @file_get_contents("$docroot/plugins/unRAIDServer/README.md",false,null,0,20)?:''?> # disable these lines: <?$readme = @file_get_contents("$docroot/plugins/unRAIDServer/README.md",false,null,0,20)?:''?>
# <?$readme = @file_get_contents("$docroot/plugins/unRAIDServer/README.md",false,null,0,20)??'';?> # <?$readme = @file_get_contents("$docroot/plugins/unRAIDServer/README.md",false,null,0,20)??'';?>
@@ -539,10 +512,10 @@ if [[ -n $LINENUM ]]; then
cp -f "$FILE" "$FILE-" cp -f "$FILE" "$FILE-"
# sed should work, but it is very difficult to escape # sed should work, but it is very difficult to escape
# instead, make a new file containing everything before LINENUM, then the new text, then everything including and after LINENUM # instead, make a new file containing everything before LINENUM, then the new text, then everything including and after LINENUM
head -$((LINENUM-1)) "$FILE" > "$FILE~" head -$((LINENUM-1)) "$FILE"> "$FILE~"
echo "$ADDTEXT4" >> "$FILE~" echo "$ADDTEXT4">> "$FILE~"
echo "" >> "$FILE~" echo "">> "$FILE~"
tail +$LINENUM "$FILE" >> "$FILE~" tail +$LINENUM "$FILE">> "$FILE~"
mv -f "$FILE~" "$FILE" mv -f "$FILE~" "$FILE"
fi fi
@@ -672,10 +645,10 @@ if [[ -n "${ADDTEXT1}" || -n "${ADDTEXT2}" || -n "${ADDTEXT3}" ]]; then
if test $( tail -n 1 "${TMP}" ) = '?>' ; then if test $( tail -n 1 "${TMP}" ) = '?>' ; then
sed -i '$ d' "${TMP}" sed -i '$ d' "${TMP}"
fi fi
[[ -n "${ADDTEXT1}" ]] && echo "${ADDTEXT1}" >>"${TMP}" [[ -n "${ADDTEXT1}" ]] && echo "${ADDTEXT1}">>"${TMP}"
[[ -n "${ADDTEXT2}" ]] && echo "${ADDTEXT2}" >>"${TMP}" [[ -n "${ADDTEXT2}" ]] && echo "${ADDTEXT2}">>"${TMP}"
[[ -n "${ADDTEXT3}" ]] && echo "${ADDTEXT3}" >>"${TMP}" [[ -n "${ADDTEXT3}" ]] && echo "${ADDTEXT3}">>"${TMP}"
echo "?>" >>"${TMP}" echo "?>">>"${TMP}"
mv "${TMP}" "${FILE}" mv "${TMP}" "${FILE}"
fi fi
@@ -692,7 +665,7 @@ echo
# setup env # setup env
if [ "${PLGTYPE}" = "production" ] || [ ! -f /boot/config/plugins/dynamix.my.servers/env ]; then if [ "${PLGTYPE}" = "production" ] || [ ! -f /boot/config/plugins/dynamix.my.servers/env ]; then
echo "env=\"${PLGTYPE}\"" >/boot/config/plugins/dynamix.my.servers/env echo "env=\"${PLGTYPE}\"">/boot/config/plugins/dynamix.my.servers/env
fi fi
echo echo
@@ -711,8 +684,7 @@ if ([[ -n "${email}" && (-z "${apikey}" || "${#apikey}" -ne "64") ]]); then
if($0 ~ /\[remote\]/){output="off"; next} if($0 ~ /\[remote\]/){output="off"; next}
if($0 ~ /\[/){output="on"; print; next} if($0 ~ /\[/){output="on"; print; next}
if(output == "on"){print} if(output == "on"){print}
}' "${CFG}" >"${CFG}-new" && mv "${CFG}-new" "${CFG}" }' "${CFG}">"${CFG}-new" && mv "${CFG}-new" "${CFG}" CFG_CLEANED=1
CFG_CLEANED=1
echo "⚠️ Automatically signed out of Unraid.net" echo "⚠️ Automatically signed out of Unraid.net"
fi fi
# if there wasn't an email or the CFG was cleaned # if there wasn't an email or the CFG was cleaned
@@ -736,18 +708,14 @@ FILE=/etc/nginx/nginx.conf
# brings older versions of Unraid in sync with 6.12.0 # brings older versions of Unraid in sync with 6.12.0
if grep -q "SAMEORIGIN" "${FILE}"; then if grep -q "SAMEORIGIN" "${FILE}"; then
CHANGED=yes CHANGED=yes
cp "$FILE" "$FILE-" cp "$FILE" "$FILE-" OLD="add_header X-Frame-Options 'SAMEORIGIN';" NEW="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect.myunraid.net/\";"
OLD="add_header X-Frame-Options 'SAMEORIGIN';"
NEW="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect.myunraid.net/\";"
sed -i "s#${OLD}#${NEW}#" "${FILE}" sed -i "s#${OLD}#${NEW}#" "${FILE}"
fi fi
if [ "${PLGTYPE}" = "staging" ]; then if [ "${PLGTYPE}" = "staging" ]; then
# staging plugin allows an additional origin # staging plugin allows an additional origin
if ! grep -q "dev-my.myunraid.net:4000" "${FILE}"; then if ! grep -q "dev-my.myunraid.net:4000" "${FILE}"; then
CHANGED=yes CHANGED=yes
[[ ! -f "$FILE-" ]] && cp "$FILE" "$FILE-" [[ ! -f "$FILE-" ]] && cp "$FILE" "$FILE-" OLD="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect.myunraid.net/\";" NEW="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect-staging.myunraid.net https://connect.myunraid.net/ https://dev-my.myunraid.net:4000/\";"
OLD="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect.myunraid.net/\";"
NEW="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect-staging.myunraid.net https://connect.myunraid.net/ https://dev-my.myunraid.net:4000/\";"
sed -i "s#${OLD}#${NEW}#" "${FILE}" sed -i "s#${OLD}#${NEW}#" "${FILE}"
fi fi
fi fi
@@ -755,8 +723,7 @@ FILE=/etc/rc.d/rc.nginx
# brings older versions of Unraid in sync with 6.12.0 # brings older versions of Unraid in sync with 6.12.0
if ! grep -q "#robots.txt any origin" "${FILE}"; then if ! grep -q "#robots.txt any origin" "${FILE}"; then
CHANGED=yes CHANGED=yes
cp "$FILE" "$FILE-" cp "$FILE" "$FILE-" FIND="location = \/robots.txt {"
FIND="location = \/robots.txt {"
# escape tabs and spaces # escape tabs and spaces
ADD="\ \ \ \ \ add_header Access-Control-Allow-Origin *; #robots.txt any origin" ADD="\ \ \ \ \ add_header Access-Control-Allow-Origin *; #robots.txt any origin"
sed -i "/${FIND}/a ${ADD}" "${FILE}" sed -i "/${FIND}/a ${ADD}" "${FILE}"
@@ -802,10 +769,7 @@ preventDowngradeAction() {
} }
# Extract "ts" values from both files # Extract "ts" values from both files
plgWebComponentPath="/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components" plgWebComponentPath="/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components" backupWebComponentPath="/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components-" plgManifestTs=$(extract_ts "$plgWebComponentPath/manifest.json")
backupWebComponentPath="/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components-"
plgManifestTs=$(extract_ts "$plgWebComponentPath/manifest.json")
webguiManifestTs=$(extract_ts "$backupWebComponentPath/manifest.json") webguiManifestTs=$(extract_ts "$backupWebComponentPath/manifest.json")
# Compare the "ts" values and return the file path of the higher value # Compare the "ts" values and return the file path of the higher value
@@ -837,12 +801,12 @@ echo
exit 0 exit 0
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
<FILE Run="/bin/bash" Method="remove"> <FILE Run="/bin/bash" Method="remove">
<INLINE> <INLINE>
<![CDATA[ <![CDATA[
version= version=
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source /etc/unraid-version source /etc/unraid-version
@@ -853,7 +817,7 @@ echo
exit 0 exit 0
]]> ]]>
</INLINE> </INLINE>
</FILE> </FILE>
</PLUGIN> </PLUGIN>

View File

@@ -62,6 +62,28 @@ elif [[ "${env}" == "staging" ]]; then
API_TGZ="https://preview.dl.unraid.net/unraid-api/unraid-api-${API_VERSION}.tgz" API_TGZ="https://preview.dl.unraid.net/unraid-api/unraid-api-${API_VERSION}.tgz"
fi fi
# Get latest node version (based on main_node_version) from slackware
main_node_version=$(find "${MAINDIR}/../.." -type f -path "*/api/.nvmrc" -exec sed 's/^v//' {} \;)
base_node_url="https://mirrors.slackware.com/slackware/slackware64-current/slackware64/l/"
latest_nodejs=$(wget -q -O- "${base_node_url}" | grep -o "nodejs-${main_node_version}\.[0-9.]*-x86_64-[0-9]*\.txz" | tail -n 1)
if [[ -z "${latest_nodejs}" ]]; then
echo "Error: Failed to fetch the latest nodejs version."
exit 1
fi
node_download_url="${base_node_url}${latest_nodejs}"
wget -q "${node_download_url}" -O "/tmp/${latest_nodejs}"
node_sha256=$(sha256sum "/tmp/${latest_nodejs}" | cut -f 1 -d ' ')
rm "/tmp/${latest_nodejs}"
# Get latest nghttp3 version
base_nghttp3_url="https://mirrors.slackware.com/slackware/slackware64-current/slackware64/n/"
latest_nghttp3=$(wget -q -O- "${base_nghttp3_url}" | grep -o "nghttp3-[0-9.]*-x86_64-[0-9]*\.txz" | tail -n 1)
nghttp3_download_url="${base_nghttp3_url}${latest_nghttp3}"
wget -q "${nghttp3_download_url}" -O "/tmp/${latest_nghttp3}"
nghttp3_sha256=$(sha256sum "/tmp/${latest_nghttp3}" | cut -f 1 -d ' ')
rm "/tmp/${latest_nghttp3}"
# update plg file # update plg file
sed -i -E "s#(ENTITY name\s*)\".*\"#\1\"${plugin}\"#g" "${plgfile}" sed -i -E "s#(ENTITY name\s*)\".*\"#\1\"${plugin}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY env\s*)\".*\"#\1\"${env}\"#g" "${plgfile}" sed -i -E "s#(ENTITY env\s*)\".*\"#\1\"${env}\"#g" "${plgfile}"
@@ -71,6 +93,16 @@ sed -i -E "s#(ENTITY SHA256\s*)\".*\"#\1\"${sha256}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY MAIN_TXZ\s*)\".*\"#\1\"${MAIN_TXZ}\"#g" "${plgfile}" sed -i -E "s#(ENTITY MAIN_TXZ\s*)\".*\"#\1\"${MAIN_TXZ}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY API_TGZ\s*)\".*\"#\1\"${API_TGZ}\"#g" "${plgfile}" sed -i -E "s#(ENTITY API_TGZ\s*)\".*\"#\1\"${API_TGZ}\"#g" "${plgfile}"
# update node versions
sed -i -E "s#(ENTITY NODE\s*)\".*\"#\1\"${latest_nodejs}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY NODE_SHA256\s*)\".*\"#\1\"${node_sha256}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY NODE_TXZ\s*)\".*\"#\1\"${node_download_url}\"#g" "${plgfile}"
# update nghttp3 versions
sed -i -E "s#(ENTITY NGHTTP3\s*)\".*\"#\1\"${latest_nghttp3}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY NGHTTP3_SHA256\s*)\".*\"#\1\"${nghttp3_sha256}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY NGHTTP3_TXZ\s*)\".*\"#\1\"${nghttp3_download_url}\"#g" "${plgfile}"
# set from environment vars # set from environment vars
sed -i -E "s#(ENTITY API_version\s*)\".*\"#\1\"${API_VERSION}\"#g" "${plgfile}" sed -i -E "s#(ENTITY API_version\s*)\".*\"#\1\"${API_VERSION}\"#g" "${plgfile}"
sed -i -E "s#(ENTITY API_SHA256\s*)\".*\"#\1\"${API_SHA256}\"#g" "${plgfile}" sed -i -E "s#(ENTITY API_SHA256\s*)\".*\"#\1\"${API_SHA256}\"#g" "${plgfile}"