From 26dcf96d87cc282fdd6bbd7b30530ffd08453bd9 Mon Sep 17 00:00:00 2001 From: shenmo <jifengshenmo@outlook.com> Date: Fri, 18 Apr 2025 15:01:44 +0000 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=20Ubuntu=2025=20=E7=AD=89=20?= =?UTF-8?q?systemd=20=E4=B8=8D=E5=86=8D=E6=8F=90=E4=BE=9B=20utmp=20?= =?UTF-8?q?=E7=9A=84=E6=83=85=E6=99=AF=E4=B8=8B=E8=8E=B7=E5=8F=96=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenmo <jifengshenmo@outlook.com> --- debian/changelog | 3 ++- src/opt/apps/@PKG_NAME@/files/bin/ace-init | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index bd29fbb..eb176ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,8 @@ -amber-ce-bookworm (12.7.6) UNRELEASED; urgency=low +amber-ce-bookworm (12.8.0) UNRELEASED; urgency=low * 通用 ACE 构建,现不再需要单独使用构建脚本 * 更方便地更改成其他ACE * 现可在容器内使用 dpkg-buildpackage + * 支持 Ubuntu 25 等 systemd 不再提供 utmp 的情景下获取当前用户名 -- shenmo <shenmo@spark-app.store> Wed, 25 Sep 2024 23:15:49 +0800 diff --git a/src/opt/apps/@PKG_NAME@/files/bin/ace-init b/src/opt/apps/@PKG_NAME@/files/bin/ace-init index 2c2f23e..893ae7c 100755 --- a/src/opt/apps/@PKG_NAME@/files/bin/ace-init +++ b/src/opt/apps/@PKG_NAME@/files/bin/ace-init @@ -22,8 +22,20 @@ fi HERE="$(dirname $(realpath $0))" +function get_current_user() { + # 优先通过 who 命令获取用户 + local user + user=$(who | awk '{print $1}' | head -n 1 2>/dev/null) -non_root_user=$(who | awk '{print $1}' | head -n 1) + # 如果 who 无输出,则通过 loginctl 获取 + if [[ -z "$user" ]]; then + user=$(loginctl list-sessions --no-legend 2>/dev/null | awk '{print $3}' | head -n 1) + fi + + # 返回最终结果(可能为空) + echo "${user}" +} +non_root_user=$(get_current_user) uid=$(id -u $non_root_user) function bookworm-run(){