Files
cool/apk-untrusted-toggle.sh
2026-06-07 21:55:28 +08:00

20 lines
612 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
PKG_SCRIPT="/usr/libexec/package-manager-call"
# 检查文件是否存在
if [ ! -f "$PKG_SCRIPT" ]; then
echo "错误:目标脚本 $PKG_SCRIPT 不存在!"
echo "请修改脚本里的 PKG_SCRIPT 变量为真实路径"
exit 1
fi
# 自动替换add → add --allow-untrusted
sed -i 's/install) action="add" ;;$/install) action="add --allow-untrusted" ;;/' "$PKG_SCRIPT"
# 验证是否成功
if grep -q 'add --allow-untrusted' "$PKG_SCRIPT"; then
echo "✅ 成功!已自动在 apk add 后添加 --allow-untrusted 参数"
else
echo "❌ 失败!请检查原脚本格式"
fi