Files
cool/apk-untrusted-toggle.sh

20 lines
612 B
Bash
Raw Normal View History

2026-06-07 21:18:36 +08:00
#!/bin/sh
2026-06-07 21:55:28 +08:00
PKG_SCRIPT="/usr/libexec/package-manager-call"
2026-06-07 21:18:36 +08:00
2026-06-07 21:55:28 +08:00
# 检查文件是否存在
if [ ! -f "$PKG_SCRIPT" ]; then
echo "错误:目标脚本 $PKG_SCRIPT 不存在!"
echo "请修改脚本里的 PKG_SCRIPT 变量为真实路径"
exit 1
2026-06-07 21:28:16 +08:00
fi
2026-06-07 21:55:28 +08:00
# 自动替换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