-
Notifications
You must be signed in to change notification settings - Fork 17
/
install.sh
59 lines (47 loc) · 2.04 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
57
58
59
#!/usr/bin/env sh
set -e
REPO="DiceDB/dicedb-cli"
LATEST_RELEASE=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
# Detect the operating system and architecture
OS=$(uname -s)
ARCH=$(uname -m)
# Convert OS/ARCH to the naming convention used in releases
case $OS in
Linux) OS="linux" ;;
Darwin) OS="darwin" ;;
CYGWIN*|MINGW32*|MSYS*|MINGW*) OS="windows" ;;
*) echo "OS not supported"; exit 1 ;;
esac
case $ARCH in
x86_64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "Architecture not supported"; exit 1 ;;
esac
BINARY="dicedb-cli_${LATEST_RELEASE}_${OS}_${ARCH}.tar.gz"
URL="https://github.com/$REPO/releases/download/$LATEST_RELEASE/$BINARY"
echo "Downloading $BINARY..."
curl -L $URL -o /tmp/$BINARY
# Extract and move to /usr/local/bin
tar -xzf /tmp/$BINARY -C /tmp
chmod 777 /tmp/dicedb-cli
DICEDB_DIR=/usr/local/dicedb
DICEDB_BIN_DIR=$DICEDB_DIR/bin
if [ ! -d "$DICEDB_DIR" ]; then
sudo mkdir -p $DICEDB_DIR
fi
if [ ! -d "$DICEDB_BIN_DIR" ]; then
sudo mkdir -p $DICEDB_BIN_DIR
sudo chmod 777 $DICEDB_BIN_DIR
fi
mv /tmp/dicedb-cli $DICEDB_BIN_DIR
sudo ln -sf $DICEDB_BIN_DIR/dicedb-cli /usr/local/bin/dicedb-cli
echo "\n
██████╗ ██╗ ██████╗███████╗██████╗ ██████╗
██╔══██╗██║██╔════╝██╔════╝██╔══██╗██╔══██╗
██║ ██║██║██║ █████╗ ██║ ██║██████╔╝
██║ ██║██║██║ ██╔══╝ ██║ ██║██╔══██╗
██████╔╝██║╚██████╗███████╗██████╔╝██████╔╝
╚═════╝ ╚═╝ ╚═════╝╚══════╝╚═════╝ ╚═════╝
"
echo "> if you get 'command not found' error, add '/usr/local/bin' to your 'PATH' variable."
echo "\nDiceDB CLI installation complete ✓"