update
This commit is contained in:
parent
9f4812f139
commit
a0a80b8365
1 changed files with 33 additions and 14 deletions
|
@ -5,19 +5,44 @@
|
||||||
|
|
||||||
# Variables for URLs and script info
|
# Variables for URLs and script info
|
||||||
this_script_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/master.sh"
|
this_script_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/master.sh"
|
||||||
this_script_name="Cloudpanel Script Management Tool"
|
this_script_name="Forgejo Script Management Tool"
|
||||||
formatter_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/task_formatter.sh"
|
|
||||||
BRANCH="main"
|
BRANCH="main"
|
||||||
|
|
||||||
forgejo_url="git.hhf.technology"
|
forgejo_url="git.hhf.technology"
|
||||||
repo_owner="hhf"
|
repo_owner="hhf"
|
||||||
repo_name="script-management-cloudpanel"
|
repo_name="script-management-cloudpanel"
|
||||||
|
|
||||||
scriptname=$0
|
# Colors for output formatting
|
||||||
wget $formatter_url --no-check-certificate -O task_formatter.sh > /dev/null 2>&1
|
COLOR_RED='\033[0;31m'
|
||||||
|
COLOR_GREEN='\033[0;32m'
|
||||||
|
COLOR_BLUE='\033[0;34m'
|
||||||
|
COLOR_RESET='\033[0m'
|
||||||
|
|
||||||
# Source the formatter script
|
# Formatting functions
|
||||||
source ./task_formatter.sh
|
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
|
# Check if the script is being run with sudo
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
|
@ -79,13 +104,7 @@ cleanup_tmp_files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_script() {
|
remove_script() {
|
||||||
if [ -f "task_formatter.sh" ]; then
|
rm -- "$0" 2>/dev/null
|
||||||
rm -- "$0"
|
|
||||||
echo "Deleted master script..."
|
|
||||||
fi
|
|
||||||
if [ -f "task_formatter.sh" ]; then
|
|
||||||
rm task_formatter.sh
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to fetch the list of scripts from the repository
|
# Function to fetch the list of scripts from the repository
|
||||||
|
@ -180,7 +199,7 @@ run_scripts
|
||||||
# Cleanup created files
|
# Cleanup created files
|
||||||
cleanup_tmp_files
|
cleanup_tmp_files
|
||||||
|
|
||||||
# Clean up the master script and formatter
|
# Clean up the master script
|
||||||
format_output remove_script "Cleaning up"
|
format_output remove_script "Cleaning up"
|
||||||
|
|
||||||
# Print final message
|
# Print final message
|
||||||
|
|
Loading…
Reference in a new issue