-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·33 lines (25 loc) · 916 Bytes
/
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
#!/bin/bash
BINARIES_URL="https://github.com/mazezen/command-fanyi/releases/download/v1.0.2/command-fanyi-darwin-arm64"
INSTALL_DIR="$HOME/command-fanyi"
TARGET_DIR="/usr/local/bin"
BIN_NAME="fanyi"
if [ ! -d "$INSTALL_DIR" ]; then
echo "Creating directory $INSTALL_DIR..."
mkdir -p "$INSTALL_DIR"
fi
if [ -e "$TARGET_DIR/$BIN_NAME" ] || [ -L "$TARGET_DIR/$BIN_NAME" ]; then
echo "$BIN_NAME already exists in $TARGET_DIR. Removing existing file/link..."
sudo rm -f "$TARGET_DIR/$BIN_NAME"
fi
echo "Downloading binary from GitHub..."
curl -L -o "$INSTALL_DIR/$BIN_NAME" "$BINARIES_URL"
if [ $? -eq 0 ]; then
chmod +x "$INSTALL_DIR/$BIN_NAME"
echo "Binary downloaded and made executable."
else
echo "Failed to download the binary."
exit 1
fi
echo "Creating symbolic link in /usr/local/bin..."
sudo ln -sf "$INSTALL_DIR/$BIN_NAME" "$TARGET_DIR/$BIN_NAME"
echo "Setup completed!"