wesher-wireguard: only request install of raspberrypi-kernel-headers if we're both raspbian AND the right CPU arch
Some checks are pending
continuous-integration/laminar-eldarion Build failed with exit code 123 after 2 seconds

This commit is contained in:
Starbeamrainbowlabs 2022-08-06 21:26:30 +01:00
parent b35acbdb0b
commit 8a5c83488f
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 47 additions and 1 deletions

39
src/lib/normalise-arch.sh Normal file
View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
__na_log_msg() {
echo "[normalise-arch] $*" >&2;
}
normalise-arch() {
arch="$1";
if [[ -z "${arch}" ]]; then
read -r arch;
fi
new_arch="${arch}";
if [[ "${arch}" == "help" ]]; then
__na_log_msg "normalise-arch";
__na_log_msg " Normalises architecture names to match the official Debian architecture names used by apt.";
__na_log_msg "Usage:";
__na_log_msg " normalise-arch {architecture}";
exit 0;
fi
case "${arch}" in
"x64" ) new_arch="amd64" ;; # Node.js tarball downloads
"armv7" ) new_arch="armhf" ;; # Source: Traefik
"armv7l" ) new_arch="armhf" ;;
"armhfv6" ) new_arch="armhf" ;; # Source: Consul
"armelv5" ) new_arch="armv5" ;; # Source: Consul
"arm" ) new_arch="armhf" ;;
"aarch64" ) new_arch="arm64" ;;
"armv8" ) new_arch="arm64" ;;
esac
__na_log_msg "${arch}${new_arch}";
echo "${new_arch}";
}

View file

@ -27,6 +27,7 @@ if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${la
#shellcheck disable=SC1090
source "${lantern_path}/lantern.sh";
source "lib/normalise-arch.sh";
#shellcheck disable=SC1090
source "/etc/os-release";

View file

@ -6,8 +6,14 @@ wesher_secret="$(ask_password "wesher configuration" "Enter the wesher shared se
#shellcheck disable=SC2034
wesher_join_ip="$(ask_text "wesher configuration" "Enter an IP of a host in the cluster to join:")";
queue_apt_install "raspberrypi-kernel-headers" "wireguard" "wesher" "wesher-systemd";
queue_apt_install "wireguard" "wesher" "wesher-systemd";
cpu_arch="$(arch | normalise-arch)";
if [[ "${ID}" == "raspbian" ]]; then
if [[ "${cpu_arch}" == "armhf" ]] || [[ "${cpu_arch}" == "arm64" ]]; then
queue_apt_install "raspberrypi-kernel-headers";
fi
fi
queue_postinstall_step "10-wesher.sh";