From eadd74b71c89b8dfc3abfa2ec44ade3b943aa32a Mon Sep 17 00:00:00 2001 From: shenmo Date: Fri, 25 Oct 2024 13:11:14 +0800 Subject: [PATCH] fix: In ACE can't use updater --- tool/store-helper/pass-auth.sh | 45 ++++++++++++++++++++++++++++ tool/update-upgrade/ss-do-upgrade.sh | 8 +++-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100755 tool/store-helper/pass-auth.sh diff --git a/tool/store-helper/pass-auth.sh b/tool/store-helper/pass-auth.sh new file mode 100755 index 0000000..f858cea --- /dev/null +++ b/tool/store-helper/pass-auth.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# We use sudo twice to avoid ACE bug here +# https://gitee.com/amber-ce/amber-ce-bookworm/commit/43e1a1599ede474b37e41aa10c53fd8afc4d35a1 + +function zenity() { + if [[ -e /usr/bin/garma ]]; then + garma "$@" + else + $(command -v zenity) "$@" + fi +} + + + +# 检查sudo是否需要密码 +if sudo sudo -n true 2>/dev/null; then + echo "sudo 无需密码,继续执行" + +else + +# 循环输入密码直到成功或用户取消 +while true; do + # 使用zenity弹出密码输入框 + PASSWORD=$(zenity --password --title="需要sudo权限" ) + + # 检查用户是否取消输入 + if [ -z "$PASSWORD" ]; then + zenity --error --text="操作已取消" + exit 1 + fi + + # 尝试使用输入的密码执行sudo命令 + echo "$PASSWORD" | sudo sudo -S true 2>/dev/null + + # 检查sudo是否成功 + if [ $? -eq 0 ]; then + echo "密码正确,继续执行" + break + else + zenity --error --text="密码错误,请重新输入" + fi +done +fi + +echo "$PASSWORD" | sudo sudo -S "$@" diff --git a/tool/update-upgrade/ss-do-upgrade.sh b/tool/update-upgrade/ss-do-upgrade.sh index 2b72ba4..191198d 100755 --- a/tool/update-upgrade/ss-do-upgrade.sh +++ b/tool/update-upgrade/ss-do-upgrade.sh @@ -1,7 +1,11 @@ #!/bin/bash if [ "$(id -u)" != "0" ] ; then - pkexec "$0" "$@" - exit + if [[ IS_ACE_ENV="1" ]];then + /opt/durapps/spark-store/bin/store-helper/pass-auth.sh "$0" "$@" + else + pkexec "$0" "$@" + exit + fi fi trap "rm -f /tmp/spark-store/upgradeStatus.txt" EXIT source /opt/durapps/spark-store/bin/bashimport/transhell.amber