diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e73f79ba51..eb00b59f8d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -163,12 +163,56 @@ jobs: with: name: unraid-web path: ./plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components + - name: Download Node.js From Slackbuilds (skipped due to node.js issues) + if: false + id: download-nodejs + run: | + # Get latest node version (based on main_node_version) from slackware + main_node_version=$(sed 's/^v//' ../api/.nvmrc) + 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" | sort -V | 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}" + if ! wget -q "${node_download_url}" -O "${{ github.workspace }}/plugin/archive/${latest_nodejs}"; then + echo "Error: Failed to download nodejs package." + exit 1 + fi + node_sha256=$(sha256sum "${{ github.workspace }}/plugin/archive/${latest_nodejs}" | cut -f 1 -d ' ') + echo "NODEJS_FILENAME=${latest_nodejs}" >> $GITHUB_OUTPUT + echo "NODEJS_SHA256=${node_sha256}" >> $GITHUB_OUTPUT + - name: Download nghttp3 + id: download-nghttp3 + run: | + # 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" | sort -V | tail -n 1) + nghttp3_download_url="${base_nghttp3_url}${latest_nghttp3}" + if ! wget -q "${nghttp3_download_url}" -O "${{ github.workspace }}/plugin/archive/${latest_nghttp3}"; then + echo "Error: Failed to download nghttp3 package." + exit 1 + fi + nghttp3_sha256=$(sha256sum "${{ github.workspace }}/plugin/archive/${latest_nghttp3}" | cut -f 1 -d ' ') + echo "NGHTTP3_FILENAME=${latest_nghttp3}" >> $GITHUB_OUTPUT + echo "NGHTTP3_SHA256=${nghttp3_sha256}" >> $GITHUB_OUTPUT - name: Build Plugin run: | cd source/dynamix.unraid.net export API_VERSION=${{needs.build-test-api.outputs.API_VERSION}} export API_MD5=${{needs.build-test-api.outputs.API_MD5}} export API_SHA256=${{needs.build-test-api.outputs.API_SHA256}} + export NGHTTP3_FILENAME=${{ steps.download-nghttp3.outputs.NGHTTP3_FILENAME }} + export NGHTTP3_SHA256=${{ steps.download-nghttp3.outputs.NGHTTP3_SHA256 }} + if [ -z "${API_VERSION}" ] || + [ -z "${API_MD5}" ] || + [ -z "${API_SHA256}" ] || + [ -z "${NGHTTP3_FILENAME}" ] || + [ -z "${NGHTTP3_SHA256}" ]; then + echo "Error: One or more required variables are not set." + exit 1 + fi bash ./pkg_build.sh s ${{github.event.pull_request.number}} bash ./pkg_build.sh p @@ -222,7 +266,7 @@ jobs: - name: Copy other release files to pr-release run: | - cp archive/dynamix.unraid.net.staging-*.txz pr-release/ + cp archive/*.txz pr-release/ cp plugins/dynamix.unraid.net.staging.plg pr-release/ - name: Upload to Cloudflare @@ -275,9 +319,9 @@ jobs: removeMarkdown: false filePath: "./api/CHANGELOG.md" - - name: Run LS in unraid-api folder + - name: Copy Files for Staging Release run: | - cp archive/dynamix.unraid.net.staging-*.txz staging-release/ + cp archive/*.txz staging-release/ cp plugins/dynamix.unraid.net.staging.plg staging-release/ ls -al staging-release @@ -331,6 +375,6 @@ jobs: files: | unraid-api-*.tgz plugins/dynamix.unraid.net* - archive/dynamix.unraid.net* + archive/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/plugin/plugins/dynamix.unraid.net.plg b/plugin/plugins/dynamix.unraid.net.plg index 83ef24f616..111afb6ca0 100755 --- a/plugin/plugins/dynamix.unraid.net.plg +++ b/plugin/plugins/dynamix.unraid.net.plg @@ -1,39 +1,38 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + ]> - - - -##a long time ago in a galaxy far far away -- initial release - - - - - -name="&name;" -version="&version;" -API_version="&API_version;" -PLGTYPE="&env;" - + + + ##a long time ago in a galaxy far far away + - initial release + + + + + + name="&name;" version="&version;" API_version="&API_version;" PLGTYPE="&env;" + - - + + - - - - + + + /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 fi } @@ -103,51 +102,53 @@ sha256check() { fi } ]]> -sha256check "&source;.txz" "&SHA256;" -sha256check "/boot/config/plugins/dynamix.my.servers/unraid-api.tgz" "&API_SHA256;" -exit 0 - - - - - - https://mirrors.slackware.com/slackware/slackware64-current/slackware64/l/&NODE; - &NODE_SHA256; - - - - - https://mirrors.slackware.com/slackware/slackware64-current/slackware64/n/&NGHTTP3; - &NGHTTP3_SHA256; - - - - -&MAIN_TXZ; -&SHA256; - - - - -&API_TGZ; -&API_SHA256; - - - - -MAINTXZ="&source;.txz" - + + + + + &NODEJS_TXZ; + &NODEJS_SHA256; + + + + + &NGHTTP3_TXZ; + &NGHTTP3_SHA256; + + + + + &MAIN_TXZ; + &SHA256; + + + + + &API_TGZ; + &API_SHA256; + + + + + MAINTXZ="&source;.txz" + - - + + - - - + + - - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - -MAINNAME="&name;" - + + + + + + MAINNAME="&name;" + - - - - - - -PLGTYPE="&env;" -MAINTXZ="&source;.txz" - + + + + + + PLGTYPE="&env;" MAINTXZ="&source;.txz" + /dev/null; then - echo "${TEXT}" >>"${FILE}" + echo "${TEXT}">>"${FILE}" fi } @@ -487,9 +464,9 @@ if [[ -n $LINENUM ]]; then cp -f "$FILE" "$FILE-" # 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 - head -$((LINENUM-1)) "$FILE" > "$FILE~" + head -$((LINENUM-1)) "$FILE"> "$FILE~" echo '' >> "$FILE~" - tail +$((LINENUM+1)) "$FILE" >> "$FILE~" + tail +$((LINENUM+1)) "$FILE">> "$FILE~" # disable these lines: # @@ -539,10 +516,10 @@ if [[ -n $LINENUM ]]; then cp -f "$FILE" "$FILE-" # 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 - head -$((LINENUM-1)) "$FILE" > "$FILE~" - echo "$ADDTEXT4" >> "$FILE~" - echo "" >> "$FILE~" - tail +$LINENUM "$FILE" >> "$FILE~" + head -$((LINENUM-1)) "$FILE"> "$FILE~" + echo "$ADDTEXT4">> "$FILE~" + echo "">> "$FILE~" + tail +$LINENUM "$FILE">> "$FILE~" mv -f "$FILE~" "$FILE" fi @@ -672,10 +649,10 @@ if [[ -n "${ADDTEXT1}" || -n "${ADDTEXT2}" || -n "${ADDTEXT3}" ]]; then if test $( tail -n 1 "${TMP}" ) = '?>' ; then sed -i '$ d' "${TMP}" fi - [[ -n "${ADDTEXT1}" ]] && echo "${ADDTEXT1}" >>"${TMP}" - [[ -n "${ADDTEXT2}" ]] && echo "${ADDTEXT2}" >>"${TMP}" - [[ -n "${ADDTEXT3}" ]] && echo "${ADDTEXT3}" >>"${TMP}" - echo "?>" >>"${TMP}" + [[ -n "${ADDTEXT1}" ]] && echo "${ADDTEXT1}">>"${TMP}" + [[ -n "${ADDTEXT2}" ]] && echo "${ADDTEXT2}">>"${TMP}" + [[ -n "${ADDTEXT3}" ]] && echo "${ADDTEXT3}">>"${TMP}" + echo "?>">>"${TMP}" mv "${TMP}" "${FILE}" fi @@ -692,7 +669,7 @@ echo # setup env 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 echo @@ -711,8 +688,7 @@ if ([[ -n "${email}" && (-z "${apikey}" || "${#apikey}" -ne "64") ]]); then if($0 ~ /\[remote\]/){output="off"; next} if($0 ~ /\[/){output="on"; print; next} if(output == "on"){print} - }' "${CFG}" >"${CFG}-new" && mv "${CFG}-new" "${CFG}" - CFG_CLEANED=1 + }' "${CFG}">"${CFG}-new" && mv "${CFG}-new" "${CFG}" CFG_CLEANED=1 echo "⚠️ Automatically signed out of Unraid.net" fi # if there wasn't an email or the CFG was cleaned @@ -736,18 +712,14 @@ FILE=/etc/nginx/nginx.conf # brings older versions of Unraid in sync with 6.12.0 if grep -q "SAMEORIGIN" "${FILE}"; then CHANGED=yes - cp "$FILE" "$FILE-" - OLD="add_header X-Frame-Options 'SAMEORIGIN';" - NEW="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect.myunraid.net/\";" + cp "$FILE" "$FILE-" 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}" fi if [ "${PLGTYPE}" = "staging" ]; then # staging plugin allows an additional origin if ! grep -q "dev-my.myunraid.net:4000" "${FILE}"; then CHANGED=yes - [[ ! -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/\";" + [[ ! -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/\";" sed -i "s#${OLD}#${NEW}#" "${FILE}" fi fi @@ -755,8 +727,7 @@ FILE=/etc/rc.d/rc.nginx # brings older versions of Unraid in sync with 6.12.0 if ! grep -q "#robots.txt any origin" "${FILE}"; then CHANGED=yes - cp "$FILE" "$FILE-" - FIND="location = \/robots.txt {" + cp "$FILE" "$FILE-" FIND="location = \/robots.txt {" # escape tabs and spaces ADD="\ \ \ \ \ add_header Access-Control-Allow-Origin *; #robots.txt any origin" sed -i "/${FIND}/a ${ADD}" "${FILE}" @@ -802,10 +773,9 @@ preventDowngradeAction() { } # Extract "ts" values from both files -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") + 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") webguiManifestTs=$(extract_ts "$backupWebComponentPath/manifest.json") # Compare the "ts" values and return the file path of the higher value @@ -837,12 +807,12 @@ echo exit 0 ]]> - - + + - - - + + - - + + \ No newline at end of file diff --git a/plugin/source/dynamix.unraid.net/pkg_build.sh b/plugin/source/dynamix.unraid.net/pkg_build.sh index 1191f6d7ac..da0372916a 100755 --- a/plugin/source/dynamix.unraid.net/pkg_build.sh +++ b/plugin/source/dynamix.unraid.net/pkg_build.sh @@ -51,17 +51,25 @@ cd "${DIR}" || exit 1 PLUGIN_URL="https://stable.dl.unraid.net/unraid-api/\&name;.plg" MAIN_TXZ="https://stable.dl.unraid.net/unraid-api/${plugin}-${version}.txz" API_TGZ="https://stable.dl.unraid.net/unraid-api/unraid-api-${API_VERSION}.tgz" +NGHTTP3_TXZ="https://stable.dl.unraid.net/unraid-api/${NGHTTP3_FILENAME}" # Check if PR is set, use a different path if so if [[ -n "${PR}" ]]; then MAIN_TXZ="https://preview.dl.unraid.net/unraid-api/pr/${PR}/${plugin}-${version}.txz" API_TGZ="https://preview.dl.unraid.net/unraid-api/pr/${PR}/unraid-api-${API_VERSION}.tgz" PLUGIN_URL="https://preview.dl.unraid.net/unraid-api/pr/${PR}/${plugin}.plg" + NGHTTP3_TXZ="https://preview.dl.unraid.net/unraid-api/pr/${PR}/${NGHTTP3_FILENAME}" elif [[ "${env}" == "staging" ]]; then PLUGIN_URL="https://preview.dl.unraid.net/unraid-api/\&name;.plg" MAIN_TXZ="https://preview.dl.unraid.net/unraid-api/${plugin}-${version}.txz" API_TGZ="https://preview.dl.unraid.net/unraid-api/unraid-api-${API_VERSION}.tgz" + NGHTTP3_TXZ="https://preview.dl.unraid.net/unraid-api/${NGHTTP3_FILENAME}" fi +# Hardcoded to deal with the new -2 release breaking legacy Unraid versions +NODEJS_FILENAME="nodejs-20.18.0-x86_64-1.txz" +NODEJS_TXZ="https://stable.dl.unraid.net/unraid-api/dependencies/${NODEJS_FILENAME}" +NODEJS_SHA256="332f22a2a6722e9fad92b8d1eeaded228a6499b7335b2b54ee99c55b4fe49742" + # update plg file sed -i -E "s#(ENTITY name\s*)\".*\"#\1\"${plugin}\"#g" "${plgfile}" sed -i -E "s#(ENTITY env\s*)\".*\"#\1\"${env}\"#g" "${plgfile}" @@ -71,10 +79,42 @@ 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 API_TGZ\s*)\".*\"#\1\"${API_TGZ}\"#g" "${plgfile}" +# update node versions +sed -i -E "s#(ENTITY NODEJS_FILENAME\s*)\".*\"#\1\"${NODEJS_FILENAME}\"#g" "${plgfile}" +sed -i -E "s#(ENTITY NODEJS_SHA256\s*)\".*\"#\1\"${NODEJS_SHA256}\"#g" "${plgfile}" +sed -i -E "s#(ENTITY NODEJS_TXZ\s*)\".*\"#\1\"${NODEJS_TXZ}\"#g" "${plgfile}" + +# update nghttp3 versions +sed -i -E "s#(ENTITY NGHTTP3_FILENAME\s*)\".*\"#\1\"${NGHTTP3_FILENAME}\"#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_TXZ}\"#g" "${plgfile}" + # set from environment vars 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}" +# validate that all ENTITY values were replaced +required_entities=("name" "env" "version" "pluginURL" "SHA256" "MAIN_TXZ" "API_TGZ" "NODEJS_FILENAME" "NODEJS_SHA256" "NODEJS_TXZ" "NGHTTP3_FILENAME" "NGHTTP3_SHA256" "NGHTTP3_TXZ" "API_version" "API_SHA256") +validation_failed=false +for entity in "${required_entities[@]}"; do + entity_value=$(grep -oP "ENTITY ${entity} \"\K[^\"]*" "${plgfile}" || echo "") + if [[ -z "${entity_value}" ]]; then + echo "Error: ENTITY ${entity} was not replaced correctly in ${plgfile}" + validation_failed=true + elif [[ "${entity_value}" =~ ^[[:space:]]*$ ]]; then + echo "Error: ENTITY ${entity} has an empty value in ${plgfile}" + validation_failed=true + fi +done + +if [[ "${validation_failed}" == "true" ]]; then + if [[ -f "${plgfile}.bak" ]]; then + echo "Restoring backup due to validation failure" + mv "${plgfile}.bak" "${plgfile}" + fi + exit 1 +fi + # add changelog for major versions # sed -i "//a ###${version}\n" ${plgfile}