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 dde9619

Browse files
committed
Add install script for macOS and linux
1 parent ac1dfa9 commit dde9619

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

install.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail || exit 1
4+
5+
if [[ $HOSTTYPE != "x86_64" ]]; then
6+
log "arch $HOSTTYPE is not supported"
7+
log "please see https://sail.dev/docs/installation"
8+
exit 1
9+
fi
10+
11+
downloadURL() {
12+
log "finding latest release"
13+
local os=$1
14+
curl --progress-bar https://api.github.com/repos/cdr/sail/releases/latest |
15+
jq -r ".assets[]
16+
| select(.name | test(\"sail-${os}-amd64.tar\"))
17+
| .browser_download_url"
18+
}
19+
20+
log() {
21+
echo "$@" >&2
22+
}
23+
24+
downloadArchive() {
25+
local os=$1
26+
local downloadURL
27+
28+
downloadURL="$(downloadURL "$os")"
29+
30+
log "downloading archive"
31+
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
40+
}
41+
42+
install() {
43+
local os=$1
44+
local archive
45+
archive=$(mktemp)
46+
47+
sudo mkdir -p /usr/local/bin
48+
49+
downloadArchive "$os" > "$archive"
50+
51+
log "extracting archive into /usr/local/bin"
52+
sudo tar -xf "$archive" -C /usr/local/bin
53+
}
54+
55+
case $OSTYPE in
56+
linux-gnu*)
57+
install linux
58+
;;
59+
darwin*)
60+
install darwin
61+
;;
62+
*)
63+
log "$OSTYPE is not supported at the moment for automatic installation"
64+
log "please see https://sail.dev/docs/installation"
65+
exit 1
66+
;;
67+
esac
68+
69+
log "sail has been installed into /usr/local/bin/sail"
70+
log "please ensure /usr/local/bin is in your \$PATH"

0 commit comments

Comments
 (0)