Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a fallback to wget if curl is not available #1913

Merged
merged 3 commits into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions www/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ need() {
fi
}

download() {
url="$1"
output="$2"

if command -v curl > /dev/null; then
curl --proto =https --tlsv1.2 -sSfL "$url" "-o$output"
else
wget --https-only --secure-protocol=TLSv1_2 --quiet "$url" "-O$output"
fi
}

force=false
while test $# -gt 0; do
case $1 in
Expand All @@ -74,12 +85,18 @@ while test $# -gt 0; do
shift
;;
*)
say "error: unrecognized argument '$1'. Usage:"
help
exit 1
;;
esac
shift
done

need curl
command -v curl > /dev/null 2>&1 ||
command -v wget > /dev/null 2>&1 ||
err "need wget or curl (command not found)"

need install
need mkdir
need mktemp
Expand All @@ -100,8 +117,7 @@ fi

if [ -z "${tag-}" ]; then
tag=$(
curl --proto =https --tlsv1.2 -sSf \
https://api.github.com/repos/casey/just/releases/latest |
download https://api.github.com/repos/casey/just/releases/latest - |
grep tag_name |
cut -d'"' -f4
)
Expand Down Expand Up @@ -145,10 +161,10 @@ say "Archive: $archive"
td=$(mktemp -d || mktemp -d -t tmp)

if [ "$extension" = "zip" ]; then
curl --proto =https --tlsv1.2 -sSfL "$archive" > "$td/just.zip"
download "$archive" "$td/just.zip"
unzip -d "$td" "$td/just.zip"
else
curl --proto =https --tlsv1.2 -sSfL "$archive" | tar -C "$td" -xz
download "$archive" - | tar -C "$td" -xz
fi

if [ -e "$dest/just" ] && [ "$force" = false ]; then
Expand Down