diff --git a/tool/ssaudit b/tool/ssaudit index c6f0a58..2afffe6 100755 --- a/tool/ssaudit +++ b/tool/ssaudit @@ -200,19 +200,41 @@ function ensure_aptss_exist() { } export -f ensure_aptss_exist +# 确保ACE环境存在 # 确保ACE环境存在 function ensure_ace_env() { local ace_env_pkg="${1}" - + local ace_cmd="" - echo "ACE环境$ace_env_pkg正在尝试安装..." - zenity --info --text="首次使用$ace_env_pkg环境,重启或注销桌面后才能在启动器中展示,不影响应用启动。安装将在后台继续。" --title="ACE环境安装" & - if ! aptss install -y "$ace_env_pkg"; then - echo "安装$ace_env_pkg失败" - return 1 + # 根据配置找到对应命令 + for ace_entry in "${ACE_ENVIRONMENTS[@]}"; do + if [ "${ace_entry#*:}" = "$ace_env_pkg" ]; then + ace_cmd="${ace_entry%%:*}" + break fi - return 0 + done + + # 如果命令存在,则说明环境已可用 + if command -v "$ace_cmd" &>/dev/null; then + return 0 + fi + + echo "ACE环境 $ace_env_pkg 未安装,正在尝试安装..." + zenity --info --text="首次使用 $ace_env_pkg 环境,重启或注销桌面后才能在启动器中展示,不影响应用启动。安装将在后台继续。" --title="ACE环境安装" & + if ! aptss install -y "$ace_env_pkg"; then + echo "安装 $ace_env_pkg 失败" + return 1 + fi + + # 再次确认命令 + if command -v "$ace_cmd" &>/dev/null; then + return 0 + else + echo "ACE环境 $ace_env_pkg 安装后未检测到命令 $ace_cmd" + return 1 + fi } + export user=$(who | awk '{print $1}' | head -n 1) # 在桌面创建快捷方式 function create_desktop_file() { diff --git a/tool/ssinstall b/tool/ssinstall index 1617d9f..e7be005 100755 --- a/tool/ssinstall +++ b/tool/ssinstall @@ -200,18 +200,41 @@ function ensure_aptss_exist() { } export -f ensure_aptss_exist +# 确保ACE环境存在 # 确保ACE环境存在 function ensure_ace_env() { local ace_env_pkg="${1}" - - echo "ACE环境$ace_env_pkg正在尝试安装..." - zenity --info --text="首次使用$ace_env_pkg环境,重启或注销桌面后才能在启动器中展示,不影响应用启动。安装将在后台继续。" --title="ACE环境安装" & - if ! aptss install -y "$ace_env_pkg"; then - echo "安装$ace_env_pkg失败" - return 1 + local ace_cmd="" + + # 根据配置找到对应命令 + for ace_entry in "${ACE_ENVIRONMENTS[@]}"; do + if [ "${ace_entry#*:}" = "$ace_env_pkg" ]; then + ace_cmd="${ace_entry%%:*}" + break fi - return 0 + done + + # 如果命令存在,则说明环境已可用 + if command -v "$ace_cmd" &>/dev/null; then + return 0 + fi + + echo "ACE环境 $ace_env_pkg 未安装,正在尝试安装..." + zenity --info --text="首次使用 $ace_env_pkg 环境,重启或注销桌面后才能在启动器中展示,不影响应用启动。安装将在后台继续。" --title="ACE环境安装" & + if ! aptss install -y "$ace_env_pkg"; then + echo "安装 $ace_env_pkg 失败" + return 1 + fi + + # 再次确认命令 + if command -v "$ace_cmd" &>/dev/null; then + return 0 + else + echo "ACE环境 $ace_env_pkg 安装后未检测到命令 $ace_cmd" + return 1 + fi } + export user=$(who | awk '{print $1}' | head -n 1) # 在桌面创建快捷方式 function create_desktop_file() {