-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·56 lines (42 loc) · 1.6 KB
/
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
#!/bin/bash
# Install `lb`
function main {
local p="install: error:"
local ARCH=""
local OS=""
local VERSION=""
# check that required one of the commands are installed before doing anything.
if command -v curl &> /dev/null; then
cmd="curl -sSL"
elif command -v wget &> /dev/null; then
cmd="wget -qO -"
else
echo "${p} neither curl nor wget was found, please install of them and try again!"
exit 1
fi
# Get the latest version
VERSION=$(${cmd} "https://api.github.com/repos/faabiosr/lb/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
if [ -z "${VERSION}" ]; then
echo "${p} failed to get the latest version, please check your network connection and try again!"
exit 1
fi
echo "installing lb v${VERSION} ..."
# Check if the OS is supported
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [ "${OS}" = "darwin" ]; then
OS="macos"
fi
ARCH=$(uname -m)
if [ "${ARCH}" = "arm64" ]; then
ARCH="aarch64"
fi
local FILENAME="lb_${VERSION}_${OS}_${ARCH}"
local INSTALL_PATH="${INSTALL_PATH:-${HOME}/.local/bin}"
echo "https://github.com/faabiosr/lb/releases/download/v${VERSION}/${TAR_FILE}"
echo "installation path: ${INSTALL_PATH}"
mkdir -p "${INSTALL_PATH}" >/dev/null 2>&1 || { >&2 echo "${p} failed to create ${INSTALL_PATH} directory, please check your sudo permissions and try again!"; exit 1; }
${cmd} "https://github.com/faabiosr/lb/releases/download/v${VERSION}/${FILENAME}.tar.gz" \
| tar -xzvf - -C "${INSTALL_PATH}" "${FILENAME}/lb" --strip-components=1
echo "lb installed successfully!"
}
main "$@"