Skip to content

Commit

Permalink
fix: make install.sh also work with wget if curl is not available (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Jan 10, 2024
1 parent c9d097c commit 411baa9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ fi

printf "This script will automatically download and install Pixi (${VERSION}) for you.\nGetting it from this url: $DOWNLOAD_URL\nThe binary will be installed into '$INSTALL_DIR'\n"

if ! hash curl 2> /dev/null; then
echo "error: you do not have 'curl' installed which is required for this script."
if ! hash curl 2> /dev/null && ! hash wget 2> /dev/null; then
echo "error: you need either 'curl' or 'wget' installed for this script."
exit 1
fi

Expand All @@ -50,10 +50,17 @@ cleanup() {

trap cleanup EXIT

HTTP_CODE=$(curl -SL --progress-bar "$DOWNLOAD_URL" --output "$TEMP_FILE" --write-out "%{http_code}")
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]]; then
echo "error: '${DOWNLOAD_URL}' is not available"
exit 1
if hash curl 2> /dev/null; then
HTTP_CODE=$(curl -SL --progress-bar "$DOWNLOAD_URL" --output "$TEMP_FILE" --write-out "%{http_code}")
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]]; then
echo "error: '${DOWNLOAD_URL}' is not available"
exit 1
fi
elif hash wget 2> /dev/null; then
if ! wget -q --show-progress --output-document="$TEMP_FILE" "$DOWNLOAD_URL"; then
echo "error: '${DOWNLOAD_URL}' is not available"
exit 1
fi
fi

# Check that file was correctly created (https://github.com/prefix-dev/pixi/issues/446)
Expand Down

0 comments on commit 411baa9

Please sign in to comment.