fix: 修复安装脚本通过 pipe 执行时 root 权限检查失效的问题
使用 `id -u` 替代 `$EUID` 进行 root 权限检查。 `$EUID` 是 bash 内置变量,在通过 pipe 执行脚本时可能不可靠。
This commit is contained in:
@@ -404,7 +404,9 @@ configure_server() {
|
||||
|
||||
# Check if running as 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')"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user