mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
fix: show actual systemctl error when MariaDB restart fails
restart_mariadb_service() and start_mariadb_service() suppressed stderr with 2>/dev/null, hiding the real failure reason. Now captures and displays the systemctl error output and service status on failure for diagnostics.
This commit is contained in:
parent
df20cc7e0b
commit
27c2430d4f
2 changed files with 33 additions and 10 deletions
22
install.sh
22
install.sh
|
|
@ -188,6 +188,7 @@ install_local_mariadb_server() {
|
|||
|
||||
start_mariadb_service() {
|
||||
local svc_name=""
|
||||
local output=""
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
if systemctl list-unit-files 2>/dev/null | grep -q "^mariadb.service"; then
|
||||
svc_name="mariadb"
|
||||
|
|
@ -197,8 +198,8 @@ start_mariadb_service() {
|
|||
fi
|
||||
|
||||
if [ -n "$svc_name" ]; then
|
||||
systemctl start "$svc_name" 2>/dev/null
|
||||
systemctl enable "$svc_name" 2>/dev/null
|
||||
systemctl start "$svc_name" 2>/dev/null || true
|
||||
systemctl enable "$svc_name" 2>/dev/null || true
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
|
@ -383,6 +384,7 @@ disable_mariadb_skip_networking() {
|
|||
|
||||
restart_mariadb_service() {
|
||||
local svc_name=""
|
||||
local output=""
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
if systemctl list-unit-files 2>/dev/null | grep -q "^mariadb.service"; then
|
||||
svc_name="mariadb"
|
||||
|
|
@ -392,11 +394,21 @@ restart_mariadb_service() {
|
|||
fi
|
||||
|
||||
if [ -n "$svc_name" ]; then
|
||||
systemctl restart "$svc_name" 2>/dev/null
|
||||
return $?
|
||||
output=$(systemctl restart "$svc_name" 2>&1) || {
|
||||
echo -e "${red}systemctl restart $svc_name 失败:${plain}" >&2
|
||||
echo "$output" >&2
|
||||
echo -e "${yellow}systemctl status $svc_name:${plain}" >&2
|
||||
systemctl status "$svc_name" --no-pager -l 2>&1 | head -20 >&2
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
fi
|
||||
if [[ $release == "alpine" ]]; then
|
||||
rc-service mariadb restart 2>/dev/null
|
||||
output=$(rc-service mariadb restart 2>&1) || {
|
||||
echo -e "${red}rc-service mariadb restart 失败:${plain}" >&2
|
||||
echo "$output" >&2
|
||||
return 1
|
||||
}
|
||||
return $?
|
||||
fi
|
||||
|
||||
|
|
|
|||
21
x-ui.sh
21
x-ui.sh
|
|
@ -2833,6 +2833,7 @@ read_mariadb_server_option() {
|
|||
|
||||
restart_mariadb_service() {
|
||||
local svc_name=""
|
||||
local output=""
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
if systemctl list-unit-files 2>/dev/null | grep -q "^mariadb.service"; then
|
||||
svc_name="mariadb"
|
||||
|
|
@ -2842,11 +2843,21 @@ restart_mariadb_service() {
|
|||
fi
|
||||
|
||||
if [ -n "$svc_name" ]; then
|
||||
systemctl restart "$svc_name" 2>/dev/null
|
||||
return $?
|
||||
output=$(systemctl restart "$svc_name" 2>&1) || {
|
||||
echo -e "${red}systemctl restart $svc_name 失败:${plain}" >&2
|
||||
echo "$output" >&2
|
||||
echo -e "${yellow}systemctl status $svc_name:${plain}" >&2
|
||||
systemctl status "$svc_name" --no-pager -l 2>&1 | head -20 >&2
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
fi
|
||||
if [[ $release == "alpine" ]]; then
|
||||
rc-service mariadb restart 2>/dev/null
|
||||
output=$(rc-service mariadb restart 2>&1) || {
|
||||
echo -e "${red}rc-service mariadb restart 失败:${plain}" >&2
|
||||
echo "$output" >&2
|
||||
return 1
|
||||
}
|
||||
return $?
|
||||
fi
|
||||
|
||||
|
|
@ -2985,8 +2996,8 @@ start_mariadb_service() {
|
|||
fi
|
||||
fi
|
||||
if [ -n "$svc_name" ]; then
|
||||
systemctl start "$svc_name" 2>/dev/null
|
||||
systemctl enable "$svc_name" 2>/dev/null
|
||||
systemctl start "$svc_name" 2>/dev/null || true
|
||||
systemctl enable "$svc_name" 2>/dev/null || true
|
||||
return 0
|
||||
fi
|
||||
if [[ $release == "alpine" ]]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue