-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.lib.sh
More file actions
37 lines (32 loc) · 853 Bytes
/
.lib.sh
File metadata and controls
37 lines (32 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
set -eu
# shellcheck disable=1090
. "${0%/*}/.version"
assure_exists() {
exe=${1:?}
[ -f "$exe" ] && return 0
dir="${exe%/*}"
mkdir -p "$dir"
# shellcheck disable=2064
trap "rm -Rf '$dir'" INT
(
cd "$dir"
{
url="https://github.com/share-secrets-safely/cli/releases/download/$VERSION/sy-cli-$(uname -s)-x86_64.tar.gz"
echo 1>&2 "Downloading $url..."
if which wget > /dev/null 2>&1; then
if readlink "$(which wget)" | grep -q busybox; then
wget -q -O - "$url"
else
wget --show-progress -q -O - "$url"
fi
elif which curl > /dev/null 2>&1; then
curl -L --progress "$url"
else
echo 1>&2 "Cannot find a program suitable to download '$url'"
echo 1>&2 "Tried 'curl' and 'wget'"
exit 2
fi
} | tar xzf -
)
}