This commit is contained in:
hhftechnologies 2024-11-25 15:56:12 +05:30
parent 9f4812f139
commit a0a80b8365

View file

@ -5,19 +5,44 @@
# Variables for URLs and script info
this_script_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/master.sh"
this_script_name="Cloudpanel Script Management Tool"
formatter_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/task_formatter.sh"
this_script_name="Forgejo Script Management Tool"
BRANCH="main"
forgejo_url="git.hhf.technology"
repo_owner="hhf"
repo_name="script-management-cloudpanel"
scriptname=$0
wget $formatter_url --no-check-certificate -O task_formatter.sh > /dev/null 2>&1
# Colors for output formatting
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
COLOR_BLUE='\033[0;34m'
COLOR_RESET='\033[0m'
# Source the formatter script
source ./task_formatter.sh
# Formatting functions
print_header() {
local script_name=$1
local script_url=$2
printf "\n${COLOR_GREEN}=== %s ===${COLOR_RESET}\n" "$script_name"
printf "${COLOR_BLUE}Script URL: %s${COLOR_RESET}\n\n" "$script_url"
}
format_output() {
local func=$1
local message=$2
printf "${COLOR_BLUE}%s...${COLOR_RESET}\n" "$message"
$func
printf "${COLOR_GREEN}Done!${COLOR_RESET}\n"
}
final_message() {
local script_name=$1
local success=$2
if [ $success -eq 0 ]; then
printf "\n${COLOR_GREEN}=== %s completed successfully ===${COLOR_RESET}\n" "$script_name"
else
printf "\n${COLOR_RED}=== %s failed with errors ===${COLOR_RESET}\n" "$script_name"
fi
}
# Check if the script is being run with sudo
if [ "$EUID" -eq 0 ]; then
@ -79,13 +104,7 @@ cleanup_tmp_files() {
}
remove_script() {
if [ -f "task_formatter.sh" ]; then
rm -- "$0"
echo "Deleted master script..."
fi
if [ -f "task_formatter.sh" ]; then
rm task_formatter.sh
fi
rm -- "$0" 2>/dev/null
}
# Function to fetch the list of scripts from the repository
@ -180,7 +199,7 @@ run_scripts
# Cleanup created files
cleanup_tmp_files
# Clean up the master script and formatter
# Clean up the master script
format_output remove_script "Cleaning up"
# Print final message