Upload files to "/" #2
+70
-13
@@ -1,13 +1,67 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
#set -e
|
||||
trap 'echo -e "\n${RED}❌ Setup cancelled by user. Exiting...${NC}"; exit 1' INT
|
||||
|
||||
|
||||
function print_gradient_progress_bar() {
|
||||
# Function to print a gradient progress bar based on a given percentage
|
||||
local percent=$1
|
||||
local total_steps=50
|
||||
local filled_steps=$((percent * total_steps / 100))
|
||||
local character="🮆"
|
||||
progress_bar=""
|
||||
|
||||
for ((j=0; j<filled_steps; j++)); do # Calculate the color transition for each filled character
|
||||
r=$((35 + (75 * j / total_steps)))
|
||||
g=$((206 - (206 * j / total_steps)))
|
||||
b=255 # Keep blue constant
|
||||
progress_bar+="\033[38;2;${r};${g};${b}m${character}\033[0m" # Append the colored character to the progress bar
|
||||
done
|
||||
for ((j=filled_steps; j<total_steps; j++)); do progress_bar+=" "; done # Fill the remaining characters with spaces
|
||||
printf "\r${progress_bar} ${percent}%%"
|
||||
}
|
||||
|
||||
function print_gradient_text() {
|
||||
local text="$1"
|
||||
local start_r="$2" # Starting red color
|
||||
local start_g="$3" # Starting green color
|
||||
local start_b="$4" # Starting blue color
|
||||
local end_r="$5" # Ending red color
|
||||
local end_g="$6" # Ending green color
|
||||
local end_b="$7" # Ending blue color
|
||||
local length=${#text}
|
||||
for ((i=0; i<length; i++)); do
|
||||
# Calculate the color transition
|
||||
r=$((start_r + (end_r - start_r) * i / length))
|
||||
g=$((start_g + (end_g - start_g) * i / length))
|
||||
b=$((start_b + (end_b - start_b) * i / length))
|
||||
# Print the character with the calculated color
|
||||
printf "\033[38;2;${r};${g};${b}m${text:i:1}\033[0m"
|
||||
done
|
||||
echo # Move to the next line after printing the text
|
||||
}
|
||||
|
||||
|
||||
function wget_dl_with_progressbar() {
|
||||
# The argument needs to be an URL (link), example: wget_dl_with_progressbar "https://www.some.com/file.txt"
|
||||
wget "$1" 2>&1 | while read -r line; do
|
||||
if [[ $line =~ ([0-9]+)% ]]; then
|
||||
percent=${BASH_REMATCH[1]}
|
||||
pline=$(echo $line | grep -E "% " | awk -F ' ' '{print $7}' | grep -E -o '[0-9]+')
|
||||
print_gradient_progress_bar $pline
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Color Codes
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
CYAN='\033[0;36m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
start_color=(35 206 255) # Sky blue
|
||||
end_color=(100 112 240) # Lilac
|
||||
|
||||
intro_block='
|
||||
----------------------------------------
|
||||
@@ -76,18 +130,18 @@ echo -e "${YELLOW}📋 Detected distro:${NC} ${GREEN}${DISTRO}${NC} ${CYAN}${VER
|
||||
# Install Required Packages
|
||||
echo -e "${CYAN}🔧 Installing dependencies...${NC}"
|
||||
case "$DISTRO" in
|
||||
ubuntu|debian)
|
||||
ubuntu|debian|linuxmint)
|
||||
sudo apt update
|
||||
sudo apt install -y openjdk-17-jre curl unzip libfuse2 jq zlib1g-dev imagemagick
|
||||
sudo apt install -y openjdk-17-jre curl unzip libfuse2 jq zlib1g-dev imagemagick wget
|
||||
;;
|
||||
fedora)
|
||||
sudo dnf install -y java-17-openjdk curl unzip fuse jq zlib-devel ImageMagick
|
||||
sudo dnf install -y java-17-openjdk curl unzip fuse jq zlib-devel ImageMagick wget
|
||||
;;
|
||||
arch)
|
||||
sudo pacman -Sy --noconfirm jre17-openjdk curl unzip fuse2 jq zlib imagemagick
|
||||
sudo pacman -Sy --noconfirm jre17-openjdk curl unzip fuse2 jq zlib imagemagick wget
|
||||
;;
|
||||
alpine)
|
||||
sudo apk add --no-cache openjdk17 curl unzip fuse jq zlib-dev imagemagick
|
||||
sudo apk add --no-cache openjdk17 curl unzip fuse jq zlib-dev imagemagick wget
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}⚠️ Unsupported distro: ${DISTRO}. Please install openjdk-17, curl, unzip, jq, zlib1g-dev and fuse manually.${NC}"
|
||||
@@ -123,7 +177,7 @@ if [ -d "$HOME/qortal" ]; then
|
||||
BACKUP_EXECUTED=false
|
||||
QORTAL_CORE_GOOD=true
|
||||
else
|
||||
echo "${RED}⚠️ Qortal Core is not fully synced.${NC} ${CYAN}Proceeding...Will stop Qortal, backup existing data, and continue...${NC}"
|
||||
echo -e "${RED}⚠️ Qortal Core is not fully synced.${NC} ${CYAN}Proceeding...Will stop Qortal, backup existing data, and continue...${NC}"
|
||||
|
||||
if pgrep -f "qortal.jar" > /dev/null && curl -s "http://localhost:12391/admin/status" | grep -q "height"; then
|
||||
if [ -f "${HOME}/qortal/stop.sh" ]; then
|
||||
@@ -144,14 +198,15 @@ if [ -d "$HOME/qortal" ]; then
|
||||
fi
|
||||
|
||||
if [ "$QORTAL_CORE_GOOD" == "false" ]; then
|
||||
echo "${GREEN}Downloading Qortal Core...${NC}"
|
||||
curl -LO https://github.com/Qortal/qortal/releases/latest/download/qortal.zip
|
||||
print_gradient_text "Downloading Qortal Core, please wait." "${start_color[0]}" "${start_color[1]}" "${start_color[2]}" "${end_color[0]}" "${end_color[1]}" "${end_color[2]}"
|
||||
wget_dl_with_progressbar "https://github.com/Qortal/qortal/releases/latest/download/qortal.zip"
|
||||
unzip qortal.zip
|
||||
rm qortal.zip
|
||||
chmod +x "$HOME/qortal/"*.sh
|
||||
chmod +x "$HOME/qortal/qort"
|
||||
fi
|
||||
|
||||
|
||||
# Download Architecture-specific Qortal Hub
|
||||
echo -e "\n ${CYAN}Checking for Desktop Environment..."
|
||||
if [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ] || [ -n "$XDG_CURRENT_DESKTOP" ]; then
|
||||
@@ -171,8 +226,9 @@ if [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ] || [ -n "$XDG_CURRENT_DESKTOP"
|
||||
HUB_URL="https://github.com/Qortal/Qortal-Hub/releases/latest/download/Qortal-Hub.AppImage"
|
||||
fi
|
||||
|
||||
echo -e "\n ${CYAN}⬇️ Downloading Qortal Hub...${NC}"
|
||||
curl -LO "$HUB_URL"
|
||||
echo -e "\n"
|
||||
print_gradient_text "⬇️ Downloading Qortal Hub..." "${start_color[0]}" "${start_color[1]}" "${start_color[2]}" "${end_color[0]}" "${end_color[1]}" "${end_color[2]}"
|
||||
wget_dl_with_progressbar "$HUB_URL"
|
||||
if [ -f "${HOME}/qortal/Qortal-Hub" ]; then
|
||||
echo -e "\n ${GREEN} Existing Hub config found, re-configuring..."
|
||||
rm -rf Qortal-Hub
|
||||
@@ -205,7 +261,7 @@ if [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ] || [ -n "$XDG_CURRENT_DESKTOP"
|
||||
[Desktop Entry]
|
||||
Name=Qortal
|
||||
Comment=Qortal Applications
|
||||
Icon=qortal-logo
|
||||
Icon=${HOME}/Pictures/icons/qortal-hub-app-logo.png
|
||||
Type=Directory
|
||||
EOL
|
||||
|
||||
@@ -216,7 +272,7 @@ EOL
|
||||
Name=Qortal Hub
|
||||
Comment=Launch Qortal Hub
|
||||
Exec=$HOME/qortal/Qortal-Hub$SANDBOX_FLAG
|
||||
Icon=qortal-hub
|
||||
Icon=${HOME}/Pictures/icons/qortal-hub-app-logo.png
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Qortal;
|
||||
@@ -321,3 +377,4 @@ else
|
||||
echo -e "\n ${GREEN}curl -L -o ~/auto-fix-qortal.sh https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh && chmod +x ~/auto-fix-qortal.sh && cd && ./auto-fix-qortal.sh${NC}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user