Update optimize/optimize-server.sh

This commit is contained in:
HHF Technology 2024-11-27 14:35:01 +05:30
parent e4a813121b
commit 70e73d2e85

View file

@ -5,7 +5,7 @@
#-----------------------------------#
this_script_url="https://git.hhf.technology/hhf/script-management-cloudpanel/raw/branch/main/optimize/optimize-server.sh"
this_script_name="Server Optimization Script"
this_script_name="Server Optimization Script Nginx and MariaDB Only on 24.04 and Bookworm"
formatter_url="https://git.hhf.technology/hhf/TaskFormatter/raw/branch/main/bash_task_formatter/task_formatter.sh"
scriptname=$0
@ -133,14 +133,7 @@ optimize_mariadb() {
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
# Replace the configuration directly
mv "$MARIADB_CONF.new" "$MARIADB_CONF"
echo "MariaDB optimization completed"
@ -174,18 +167,8 @@ restart_nginx() {
}
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"
systemctl restart mariadb
echo "MariaDB restart initiated"
return 0
}
@ -223,9 +206,7 @@ main() {
return 1
fi
if ! format_output restart_mariadb "Restarting MariaDB service"; then
return 1
fi
format_output restart_mariadb "Restarting MariaDB service"
return 0
}