This repository was archived by the owner on Apr 28, 2020. It is now read-only.
File tree 1 file changed +22
-15
lines changed 1 file changed +22
-15
lines changed Original file line number Diff line number Diff line change 2
2
3
3
set -euo pipefail || exit 1
4
4
5
+ log () {
6
+ echo " $@ " >&2
7
+ }
8
+
5
9
if [[ $HOSTTYPE != " x86_64" ]]; then
6
10
log " arch $HOSTTYPE is not supported"
7
11
log " please see https://sail.dev/docs/installation"
8
12
exit 1
9
13
fi
10
14
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 () {
12
29
log " finding latest release"
13
30
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 |
15
32
jq -r " .assets[]
16
33
| select(.name | test(\" sail-${os} -amd64.tar\" ))
17
34
| .browser_download_url"
18
35
}
19
36
20
- log () {
21
- echo " $@ " >&2
22
- }
23
-
24
37
downloadArchive () {
25
38
local os=$1
26
39
local downloadURL
27
40
28
- downloadURL=" $( downloadURL " $os " ) "
41
+ downloadURL=" $( latestReleaseURL " $os " ) "
29
42
30
43
log " downloading archive"
31
44
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 "
40
46
}
41
47
42
48
install () {
43
49
local os=$1
44
50
local archive
45
51
archive=$( mktemp)
46
52
53
+ log " ensuring /usr/local/bin"
47
54
sudo mkdir -p /usr/local/bin
48
55
49
56
downloadArchive " $os " > " $archive "
You can’t perform that action at this time.
0 commit comments