Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit f84a337

Browse files
committed
Add wget support to install.sh
1 parent dde9619 commit f84a337

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

install.sh

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,55 @@
22

33
set -euo pipefail || exit 1
44

5+
log() {
6+
echo "$@" >&2
7+
}
8+
59
if [[ $HOSTTYPE != "x86_64" ]]; then
610
log "arch $HOSTTYPE is not supported"
711
log "please see https://sail.dev/docs/installation"
812
exit 1
913
fi
1014

11-
downloadURL() {
15+
if ! command -v curl > /dev/null && ! command -v wget > /dev/null; then
16+
log "please install curl or wget to use this script"
17+
exit 1
18+
fi
19+
20+
download() {
21+
if command -v curl > /dev/null; then
22+
curl --progress-bar -L "$1"
23+
elif command -v wget > /dev/null; then
24+
wget "$1" -O -
25+
fi
26+
}
27+
28+
latestReleaseURL() {
1229
log "finding latest release"
1330
local os=$1
14-
curl --progress-bar https://api.github.com/repos/cdr/sail/releases/latest |
31+
download https://api.github.com/repos/cdr/sail/releases/latest |
1532
jq -r ".assets[]
1633
| select(.name | test(\"sail-${os}-amd64.tar\"))
1734
| .browser_download_url"
1835
}
1936

20-
log() {
21-
echo "$@" >&2
22-
}
23-
2437
downloadArchive() {
2538
local os=$1
2639
local downloadURL
2740

28-
downloadURL="$(downloadURL "$os")"
41+
downloadURL="$(latestReleaseURL "$os")"
2942

3043
log "downloading archive"
3144

32-
if command -v curl > /dev/null; then
33-
curl --progress-bar -L "$downloadURL"
34-
elif command -v wget > /dev/null; then
35-
log "wget is not supported atm"
36-
else
37-
log "please install curl or wget to use this script"
38-
exit 1
39-
fi
45+
download "$downloadURL"
4046
}
4147

4248
install() {
4349
local os=$1
4450
local archive
4551
archive=$(mktemp)
4652

53+
log "ensuring /usr/local/bin"
4754
sudo mkdir -p /usr/local/bin
4855

4956
downloadArchive "$os" > "$archive"

0 commit comments

Comments
 (0)