/
install.sh
executable file
·54 lines (48 loc) · 1.75 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
#!/bin/bash
# This script is just a wrapper to start the Dart executable from the GitHub releases page
DIR="$HOME/.nexustools"
OS=$(uname)
ARCH=$(uname -m)
BASEURL="https://github.com/corbindavenport/nexus-tools"
DOWNLOAD=''
PARAMS="$@"
_run_executable() {
cd $DIR
curl -Lfs --progress-bar -o ./temp.zip $DOWNLOAD|| { echo "[EROR] Download failed."; exit; }
unzip -q -o ./temp.zip
rm ./temp.zip
chmod +x ./nexustools*
# Run Nexus Tools and pass parameters to the executable
./nexustools* -i -w "$PARAMS"
}
# Check that required applications are installed
if ! [ -x "$(command -v curl)" ]; then
echo "[EROR] The 'curl' command is not installed. Please install it and run Nexus Tools again."
exit
fi
if ! [ -x "$(command -v unzip)" ]; then
echo "[EROR] The 'unzip' command is not installed. Please install it and run Nexus Tools again."
exit
fi
# Make the new directory
mkdir -p $DIR
# Start Dart executable
if [ "$OS" = "Darwin" ]; then # macOS
# Install Rosetta x86 emulation layer if needed
if [ "$ARCH" = "arm64" ]; then
echo "[WARN] Rosetta 2 compatibility layer is required. If installation fails, run Nexus Tools again after running this command: /usr/sbin/softwareupdate --install-rosetta"
fi
DOWNLOAD="$BASEURL/releases/latest/download/nexustools-macos-x64.zip"
_run_executable
elif [ "$OS" = "Linux" ] && [ "$ARCH" = "x86_64" ]; then # Generic Linux
DOWNLOAD="$BASEURL/releases/latest/download/nexustools-linux-x64.zip"
_run_executable
elif [ "$OS" = "Linux" ] && [ "$ARCH" = "amd64" ]; then # Generic Linux
DOWNLOAD="$BASEURL/releases/latest/download/nexustools-linux-x64.zip"
_run_executable
else
echo "[EROR] Your OS or CPU architecture doesn't seem to be supported."
echo "[EROR] Detected OS: $OS"
echo "[EROR] Detected arch: $ARCH"
exit
fi