-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_unix.sh
More file actions
executable file
·94 lines (80 loc) · 2.2 KB
/
install_unix.sh
File metadata and controls
executable file
·94 lines (80 loc) · 2.2 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
set -e
echo "Installing sucata..."
if ! command -v unzip >/dev/null && ! command -v 7z >/dev/null; then
echo "Error: Needs unzip or 7z to install Sucata"
exit 1
fi
OS=$(uname -s)
ARCH=$(uname -m)
if [[ "$OS" == "Darwin" ]]; then
if [[ "$ARCH" == "arm64" ]]; then
TARGET="sucata-osx-arm64"
elif [[ "$ARCH" == "x86_64" ]]; then
# TARGET="sucata-osx-amd64"
echo "ERROR: Unsupported macOS architecture: $ARCH"
exit 1
else
echo "ERROR: Unsupported macOS architecture: $ARCH"
exit 1
fi
elif [[ "$OS" == "Linux" ]]; then
if [[ "$ARCH" == "x86_64" ]]; then
TARGET="sucata-linux-amd64"
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
#TARGET="sucata-linux-arm64"
echo "ERROR: Unsupported Linux architecture: $ARCH"
exit 1
else
echo "ERROR: Unsupported Linux architecture: $ARCH"
exit 1
fi
else
echo "ERROR: Unsupported operating system: $OS"
exit 1
fi
SUCATA_VERSION="0.1.2"
SUCATA_BIN="sucata"
SUCATA_URL="https://github.com/gumpdev/sucata/releases/download/$SUCATA_VERSION/$TARGET.zip"
SUCATA_DIR="$HOME/sucata"
SUCATA_TEMP_ZIP="$SUCATA_DIR/temp.zip"
SUCATA_BIN="$SUCATA_DIR/$SUCATA_BIN"
SUCATA_BIN_LINK="$HOME/.local/bin/sucata"
mkdir -p "$SUCATA_DIR"
curl --fail --location --progress-bar --output "$SUCATA_TEMP_ZIP" "$SUCATA_URL"
if command -v unzip >/dev/null; then
unzip -d "$SUCATA_DIR" -o "$SUCATA_TEMP_ZIP" >/dev/null
else
7z x -o"$SUCATA_DIR" -y "$SUCATA_TEMP_ZIP" >/dev/null
fi
chmod +x "$SUCATA_BIN"
ln -sf "$SUCATA_BIN" "$SUCATA_BIN_LINK"
echo "Sucata installed on $SUCATA_BIN"
rm -f $SUCATA_TEMP_ZIP
LINE='export PATH="$SUCATA_DIR:$PATH"'
SHELL_NAME="$(basename "$SHELL")"
add_to_file() {
local file="$1"
local line="$2"
if [ -f "$file" ]; then
if ! grep -qxF "$line" "$file"; then
echo "$line" >> "$file"
fi
else
echo "$line" >> "$file"
fi
}
case "$SHELL_NAME" in
bash)
add_to_file "$HOME/.bashrc" "$LINE"
echo "Added PATH to $HOME/.bashrc"
;;
zsh)
add_to_file "$HOME/.zshrc" "$LINE"
echo "Added PATH to $HOME/.zshrc"
;;
*)
echo "Shell not supported: $SHELL_NAME"
echo "Please add manually to PATH."
;;
esac