sysdeploy/ipxe.inc

59 lines
1.7 KiB
Bash

#!/bin/bash
function download_and_verify_ipxe()
{
local ipxe_path="$1"
local ipxeshasum1='a'
local ipxeshasum2='b'
which wget || /bin/false
if [ $? -ne 0 ]; then
apt update -yq && apt -yq install wget
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"
ipxeshasum1=$(cat "${ipxe_path}.sha256sums" | grep "ipxe.lkrn" | awk '{print $1}' | tr -d '\n')
ipxeshasum2=$(sha256sum "$ipxe_path" | awk '{print $1}' | tr -d '\n')
rm -f "${ipxe_path}.sha256sums"
if [ "${ipxeshasum1}" != "${ipxeshasum1}" ]; then
ipxe_dl_verify=1
fi
}
function install_ipxe()
{
local ipxe_install_path="$1"
local temp_dir="$(mktemp -d)"
local ipxe_path="${temp_dir}/ipxe.lkrn"
ipxe_dl_verify=0
download_and_verify_ipxe "$ipxe_path"
if (( ipxe_dl_verify > 0 )); then
>&2 echo ""
>&2 echo "Failed to download and verify IPXE kernel binary."
>&2 echo "In order to avoid disk partition issues, the syslinux install process"
>&2 echo "will continue. But you must manually download and copy the ipxe x86"
>&2 echo "lkrn file to ${ipxe_install_path}. If a file currently exists at that"
>&2 echo "path, it has not been touched."
>&2 echo ""
else
rm -f "${ipxe_install_path}"
cp "${ipxe_path}" "${ipxe_install_path}"
fi
unset ipxe_dl_verify
rm -f "$ipxe_path"
rm -rf "$temp_dir"
}
# vim: set ft=sh: