From e5f8b789303d2d7521cfc02685cc75ec2174e0e7 Mon Sep 17 00:00:00 2001 From: Bohan Yang Date: Sun, 12 May 2019 18:04:51 +0800 Subject: [PATCH] Update --- netboot.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/netboot.sh b/netboot.sh index 85176b5..a029c2f 100644 --- a/netboot.sh +++ b/netboot.sh @@ -18,6 +18,10 @@ set -e +echo_stderr() { + echo "$@" 1>&2 +} + command_exists() { _PATH="$PATH" PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" @@ -145,7 +149,7 @@ while [ $# -gt 0 ]; do DEBI_POWEROFF=true ;; *) - echo "Illegal option $1" + echo_stderr "Illegal option $1" exit 1 esac shift @@ -380,7 +384,15 @@ fi echo2='cat' if [ "$DEBI_DRY_RUN" != true ]; then - $sudo wget "$DEBI_BASE_URL/linux" "$DEBI_BASE_URL/initrd.gz" + if command_exists wget; then + $sudo wget "$DEBI_BASE_URL/linux" "$DEBI_BASE_URL/initrd.gz" + elif command_exists curl; then + $sudo curl -O "$DEBI_BASE_URL/linux" -O "$DEBI_BASE_URL/initrd.gz" + else + echo_stderr 'wget/curl not found' + exit 1 + fi + $sudo gunzip initrd.gz echo preseed.cfg | $sudo cpio -H newc -o -A -F initrd $sudo gzip initrd