fix: 修复安装脚本通过 pipe 执行时 root 权限检查失效的问题

使用 `id -u` 替代 `$EUID` 进行 root 权限检查。
`$EUID` 是 bash 内置变量,在通过 pipe 执行脚本时可能不可靠。
This commit is contained in:
shaw
2025-12-28 12:25:55 +08:00
parent fbdff4f34f
commit 9bbe468c91

View File

@@ -404,7 +404,9 @@ configure_server() {
# Check if running as root # Check if running as root
check_root() { check_root() {
if [ "$EUID" -ne 0 ]; then # Use 'id -u' instead of $EUID for better compatibility
# $EUID may not work reliably when script is piped to bash
if [ "$(id -u)" -ne 0 ]; then
print_error "$(msg 'run_as_root')" print_error "$(msg 'run_as_root')"
exit 1 exit 1
fi fi