Update optimize/optimize-server.sh
This commit is contained in:
parent
4539691c05
commit
f86f7d09d5
1 changed files with 17 additions and 9 deletions
|
@ -4,13 +4,13 @@
|
|||
# VARIABLES #
|
||||
#-----------------------------------#
|
||||
|
||||
this_script_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/optimize/optimize-server.sh"
|
||||
this_script_url="https://example.com/optimize-server.sh"
|
||||
this_script_name="Server Optimization Script"
|
||||
formatter_url="https://git.hhf.technology/hhf/TaskFormatter/raw/branch/main/bash_task_formatter/task_formatter.sh"
|
||||
scriptname=$0
|
||||
|
||||
# Configuration URLs
|
||||
NGINX_CONF_URL="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/optimize/nginx.conf"
|
||||
NGINX_CONF_URL="https://git.hhf.technology/hhf/script-management-cloudpanel/src/branch/main/optimize/nginx.conf"
|
||||
MARIADB_CONF_URL="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/optimize/100-cloudpanel.cnf"
|
||||
|
||||
# Configuration paths
|
||||
|
@ -37,6 +37,7 @@ download_formatter() {
|
|||
source ./task_formatter.sh || { echo "Error: Failed to source task_formatter.sh"; exit 1; }
|
||||
}
|
||||
|
||||
# Call the download_formatter function
|
||||
download_formatter
|
||||
|
||||
#-----------------------------------#
|
||||
|
@ -59,6 +60,7 @@ check_os_compatibility() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo "OS compatibility check passed"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -74,6 +76,7 @@ check_nginx_version() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo "Nginx version check passed"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -88,6 +91,7 @@ check_mariadb() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo "MariaDB check passed"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -115,6 +119,7 @@ optimize_nginx() {
|
|||
# Replace the configuration
|
||||
mv "$NGINX_CONF.new" "$NGINX_CONF"
|
||||
|
||||
echo "Nginx optimization completed"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -126,18 +131,19 @@ optimize_mariadb() {
|
|||
if ! wget --no-check-certificate "$MARIADB_CONF_URL" -O "$MARIADB_CONF.new"; then
|
||||
echo "Error: Failed to download MariaDB configuration"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Verify the downloaded configuration
|
||||
if ! mysqld --validate-config --defaults-file="$MARIADB_CONF.new"; then
|
||||
echo "Error: Invalid MariaDB configuration"
|
||||
rm "$MARIADB_CONF.new"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Replace the configuration
|
||||
mv "$MARIADB_CONF.new" "$MARIADB_CONF"
|
||||
|
||||
echo "MariaDB optimization completed"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -150,19 +156,20 @@ restart_nginx() {
|
|||
if ! nginx -t; then
|
||||
echo "Error: Invalid Nginx configuration detected before restart"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
if ! systemctl restart nginx; then
|
||||
echo "Error: Failed to restart Nginx"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Verify service is running
|
||||
if ! systemctl is-active --quiet nginx; then
|
||||
echo "Error: Nginx failed to start"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Nginx restarted successfully"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -170,14 +177,15 @@ restart_mariadb() {
|
|||
if ! systemctl restart mariadb; then
|
||||
echo "Error: Failed to restart MariaDB"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Verify service is running
|
||||
if ! systemctl is-active --quiet mariadb; then
|
||||
echo "Error: MariaDB failed to start"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "MariaDB restarted successfully"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue