-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathcli_install.sh
79 lines (69 loc) · 2.17 KB
/
cli_install.sh
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
73
74
75
76
77
78
79
#!/bin/bash
################################################
# Welcome to DBLab 🖖
# This script downloads DBLab CLI (`dblab`).
#
# To install it on macOS/Linux/Windows:
# curl -sSL dblab.sh | bash
#
# ⭐️ Contribute to DBLab: https://dblab.dev
# 📚 DBLab Docs: https://docs.dblab.dev
# 💻 CLI reference: https://cli-docs.dblab.dev/
# 👨💻 API reference: https://api.dblab.dev
################################################
cli_version=${DBLAB_CLI_VERSION:-"master"}
cli_version=${cli_version#v}
mkdir -p ~/.dblab
# Detect OS
os=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$os" in
cygwin_nt*|mingw*|msys_nt*|nt*|win*) os="windows" ;;
darwin*) os="darwin" ;;
linux*) os="linux" ;;
freebsd*) os="freebsd" ;;
*) echo "Unsupported OS: $os"; exit 1 ;;
esac
# Detect architecture
arch=$(uname -m)
case "$arch" in
x86_64*) arch="amd64" ;;
arm64*) arch="arm64" ;;
*) echo "Unsupported architecture: $arch"; exit 1 ;;
esac
echo "Detected OS: $os, architecture: $arch"
url="https://storage.googleapis.com/database-lab-cli/${cli_version}/dblab-${os}-${arch}"
curl --fail -Ss --output ~/.dblab/dblab $url \
&& chmod a+x ~/.dblab/dblab
if [ $? -eq 0 ]; then
echo '
888 888 888 888
888 888 888 888
888 888 888 888
.d88888 88888b. 888 8888b. 88888b.
d88" 888 888 "88b 888 "88b 888 "88b
888 888 888 888 888 .d888888 888 888
Y88b 888 888 d88P 888 888 888 888 d88P
"Y88888 88888P" 888 "Y888888 88888P"
'
echo "::::::::::::::::::::::::::::::::::::::::"
~/.dblab/dblab --version
echo "::::::::::::::::::::::::::::::::::::::::"
echo "Installed to:"
{
rm -f /usr/local/bin/dblab 2> /dev/null \
&& mv ~/.dblab/dblab /usr/local/bin/dblab 2> /dev/null \
&& echo ' /usr/local/bin/dblab'
} || {
echo ' ~/.dblab/dblab'
echo 'Add it to $PATH:'
echo ' export PATH=$PATH:~/.dblab/dblab'
echo 'or move:'
echo ' sudo mv ~/.dblab/dblab /usr/local/bin/dblab'
}
echo "::::::::::::::::::::::::::::::::::::::::"
echo 'To start, run:'
echo ' dblab init'
echo
else
>&2 echo "dblab setup failure – cannot download binaries from $url"
fi