From 7b427dda4dd9b7f08e88574bc4f9562c25502349 Mon Sep 17 00:00:00 2001 From: James Swineson Date: Thu, 10 Sep 2020 18:12:22 +0800 Subject: [PATCH] do not hard code arch while downloading images (#3) --- menhera.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/menhera.sh b/menhera.sh index 1c5c2e7..eac82fc 100755 --- a/menhera.sh +++ b/menhera.sh @@ -7,11 +7,18 @@ set +h WORKDIR="/tmp/menhera" ROOTFS="" +declare -A ARCH_MAP=( + ["x86_64"]="amd64" +) + # internal global variables OLDROOT="/" NEWROOT="" -# fix possible PATH problems +MACHINE_TYPE=$(uname -m) +ARCH_ID=${ARCH_MAP[$MACHINE_TYPE]:-$MACHINE_TYPE} + +# fix possible PATH pMYMAP[missing]+_roblems export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" menhera::reset_sshd_config() { @@ -81,9 +88,9 @@ menhera::get_rootfs() { # forgive me for parsing HTML with these shit # and hope it works - ROOTFS_TIME=$(wget -qO- --show-progress "https://images.linuxcontainers.org/images/debian/buster/amd64/default/?C=M;O=D" | grep -oP '(\d{8}_\d{2}:\d{2})' | head -n 1) + ROOTFS_TIME=$(wget -qO- --show-progress "https://images.linuxcontainers.org/images/debian/buster/${ARCH_ID}/default/?C=M;O=D" | grep -oP '(\d{8}_\d{2}:\d{2})' | head -n 1) - ROOTFS="https://images.linuxcontainers.org/images/debian/buster/amd64/default/${ROOTFS_TIME}/rootfs.squashfs" + ROOTFS="https://images.linuxcontainers.org/images/debian/buster/${ARCH_ID}/default/${ROOTFS_TIME}/rootfs.squashfs" else echo "\$ROOTFS is set to '$ROOTFS'" fi