From: AJ ONeal Date: Thu, 7 May 2020 18:36:12 +0000 (+0000) Subject: better feedback on error X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=77428aa44cea88ef3faa11d384b6fbb44716a496;p=webi-installers%2F.git better feedback on error --- diff --git a/webi/bootstrap.bash b/webi/bootstrap.bash index a962085..61e196b 100644 --- a/webi/bootstrap.bash +++ b/webi/bootstrap.bash @@ -4,6 +4,7 @@ #WEBI_PKG= #WEBI_HOST=https://webinstall.dev +export WEBI_HOST mkdir -p "$HOME/.local/bin" @@ -59,6 +60,7 @@ export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}" export WEBI_UA="\$(uname -a)" my_installer_url="\$WEBI_HOST/api/installers/\$my_package.bash?formats=\$my_ext" +set +e if [ -n "\$WEBI_CURL" ]; then curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\ -o "\$WEBI_BOOT/\$my_package-bootstrap.sh" @@ -66,6 +68,11 @@ else wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\ -O "\$WEBI_BOOT/\$my_package-bootstrap.sh" fi +if ! [ \$? -eq 0 ]; then + echo "error fetching '\$my_installer_url'" + exit 1 +fi +set -e pushd "\$WEBI_BOOT" 2>&1 > /dev/null bash "\$my_package-bootstrap.sh" diff --git a/webi/template.bash b/webi/template.bash index 651d5bd..0c6f506 100644 --- a/webi/template.bash +++ b/webi/template.bash @@ -22,6 +22,7 @@ set -u #WEBI_EXT= #WEBI_PKG_URL= #WEBI_PKG_FILE= +export WEBI_HOST ## ## Set up tmp, download, and install directories @@ -61,7 +62,13 @@ webi_download() { if [ -n "$WEBI_WGET" ]; then # wget has resumable downloads # TODO wget -c --content-disposition "$my_url" + set +e wget -q --show-progress -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl" + if ! [ $? -eq 0 ]; then + echo "failed to download from $WEBI_PKG_URL" + exit 1 + fi + set -e else # BSD curl is non-resumable, hence we don't bother # TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"