78 lines
3.1 KiB
Bash
78 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
echo "Starting up Aria's Creations tools installer"
|
|
|
|
# Check if the script is running as root
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
echo "Running as root. No need for sudo or password."
|
|
SUDO_CMD=""
|
|
else
|
|
echo "Not running as root. Sudo and password required."
|
|
PASS=$(zenity --password --title="SHT Installer" --timeout=120)
|
|
|
|
# Check if the password input was canceled or failed
|
|
if [ -z "$PASS" ]; then
|
|
echo "No password entered. Exiting installer."
|
|
exit 1
|
|
fi
|
|
|
|
# Test password to check if it's correct
|
|
echo "$PASS" | sudo -S echo "Escalation successful" &>/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "Password incorrect. Exiting installer."
|
|
exit 1
|
|
fi
|
|
|
|
SUDO_CMD="echo $PASS | sudo -S"
|
|
fi
|
|
|
|
# Function to download a file with retry logic
|
|
download_with_retry() {
|
|
local url=$1
|
|
local output=$2
|
|
local max_retries=5
|
|
local attempt=1
|
|
|
|
while [ $attempt -le $max_retries ]; do
|
|
$SUDO_CMD wget "$url" -O "$output"
|
|
|
|
# Check if the download was successful and the file is not empty
|
|
if [ -s "$output" ]; then
|
|
echo "Downloaded $output successfully."
|
|
return 0
|
|
else
|
|
echo "Failed to download $output or file is empty. Retrying... ($attempt/$max_retries)"
|
|
|
|
# Delete the incomplete or zero-byte file if the download fails
|
|
$SUDO_CMD rm -f "$output"
|
|
|
|
attempt=$((attempt + 1))
|
|
fi
|
|
done
|
|
|
|
echo "Failed to download $output after $max_retries attempts. Exiting."
|
|
exit 1
|
|
}
|
|
|
|
# Download the tools and put them in place
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/nbt2snbt-linux-x64" "/usr/bin/nbt2snbt"
|
|
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/pause-linux-x64" "/usr/bin/pause"
|
|
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/snbt2nbt-linux-x64" "/usr/bin/snbt2nbt"
|
|
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/dbikc-linux-x64" "/usr/bin/dbikc"
|
|
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/uuidgen-linux-x64" "/usr/bin/uuidgen"
|
|
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/sleep-linux-x64" "/usr/bin/vsleep"
|
|
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/mkfsreport-linux-x64" "/usr/bin/mkfsreport"
|
|
|
|
download_with_retry "https://ci.zontreck.com/job/Projects/job/Dart/job/SimpleHelperTools/job/main/lastSuccessfulBuild/artifact/dart/out/regedit-linux-x64" "/usr/bin/regedit"
|
|
|
|
# Set executable permissions
|
|
$SUDO_CMD chmod +x /usr/bin/{nbt2snbt,snbt2nbt,pause,mkfsreport,dbikc,vsleep,uuidgen,regedit}
|
|
|
|
echo "Installation Completed"
|
|
vsleep 5
|