From 964f047c1d572070f834a9cab533198f3a3aa541 Mon Sep 17 00:00:00 2001 From: Max Weiss Date: Mon, 26 Apr 2021 22:58:37 -0700 Subject: [PATCH] Use Gitea latest release for IPXE download --- ipxe.inc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ipxe.inc b/ipxe.inc index a1c5940..7f6744e 100644 --- a/ipxe.inc +++ b/ipxe.inc @@ -7,14 +7,27 @@ function download_and_verify_ipxe() local ipxeshasum1='a' local ipxeshasum2='b' - which wget || /bin/false + which wget && which jq && which curl || /bin/false if [ $? -ne 0 ]; then - apt update -yq && apt -yq install wget + apt update -yq && apt -yq install wget jq curl fi - # This will actually be a Gitea release download for the lastest master - wget https://images.sysdeploy.org/path/to/buildbot/latest/ipxe.lkrn -O "$ipxe_path" || echo "download failed" > "$ipxe_path" - wget https://images.sysdeploy.org/path/to/buildbot/latest/SHA256SUMS -O "${ipxe_path}.sha256sums" || echo "z ipxe.lkrn" > "${ipxe_path}.sha256sums" + # This gets the info for the most current release, in JSON format + release_info=$(curl "https://git.bitmessage.org/api/v1/repos/maxweiss/ipxe_scripts/releases?per_page=1&page=1&limit=1") + + lkrn_url=$(echo ${release_info} | jq '.[0].assets[] | select(.name=="ipxe.lkrn")' | jq -r .browser_download_url | tr -d '\n') + shasums_url=$(echo ${release_info} | jq '.[0].assets[] | select(.name=="SHA256SUMS")' | jq -r .browser_download_url | tr -d '\n') + + if [[ -z $lkrn_url ]] || [[ $lkrn_url = *[^[:space:]]* ]]; then + echo "download failed" > "$ipxe_path" + else + wget "${lkrn_url}" -O "$ipxe_path" || echo "download failed" > "$ipxe_path" + fi + if [[ -z $shasums_url ]] || [[ $shasums_url = *[^[:space:]]* ]]; then + echo "z ipxe.lkrn" > "${ipxe_path}.sha256sums" + else + wget "${shasums_url}" -O "${ipxe_path}.sha256sums" || echo "z ipxe.lkrn" > "${ipxe_path}.sha256sums" + fi ipxeshasum1=$(cat "${ipxe_path}.sha256sums" | grep "ipxe.lkrn" | awk '{print $1}' | tr -d '\n') ipxeshasum2=$(sha256sum "$ipxe_path" | awk '{print $1}' | tr -d '\n')