forked from babashka/babashka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·72 lines (58 loc) · 1.65 KB
/
install
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -euo pipefail
version=""
default_install_dir="/usr/local/bin"
install_dir=$default_install_dir
print_help() {
echo "Installs latest (or specific) version of babashka. Installation directory defaults to /usr/local/bin."
echo -e
echo "Usage:"
echo "install [--dir <dir>] [--version <version>]"
exit 1
}
if [[ $# -eq 1 ]]; then
install_dir=${1:-}
fi
while [[ $# -gt 1 ]]
do
key="$1"
if [[ -z "${2:-}" ]]; then
print_help
fi
case $key in
--dir)
install_dir="$2"
shift
shift
;;
--version)
version="$2"
shift
shift
;;
*) # unknown option
print_help
shift
;;
esac
done
download_dir=/tmp
if [[ "$version" == "" ]]; then
version="$(curl -sL https://raw.githubusercontent.com/borkdude/babashka/master/resources/BABASHKA_RELEASED_VERSION)"
fi
case "$(uname -s)" in
Linux*) platform=linux;;
Darwin*) platform=macos;;
esac
download_url="https://github.com/borkdude/babashka/releases/download/v$version/babashka-$version-$platform-amd64.zip"
cd "$download_dir"
echo -e "Downloading $download_url."
curl -o "babashka-$version-$platform-amd64.zip" -sL "https://github.com/borkdude/babashka/releases/download/v$version/babashka-$version-$platform-amd64.zip"
unzip -qqo "babashka-$version-$platform-amd64.zip"
rm "babashka-$version-$platform-amd64.zip"
cd "$install_dir"
if [ -f babashka ]; then
echo "Moving $install_dir/bb to $install_dir/bb.old"
fi
mv -f "$download_dir/bb" "$PWD/bb"
echo "Successfully installed bb in $install_dir."