Files
karuo-ai/01_卡资(金)/金仓_存储备份/脚本/karuo_sudo.sh
2026-07-19 00:21:46 +08:00

17 lines
603 B
Bash
Executable File
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/bash
# 卡若AI · 静默 sudo从登录钥匙串取 Mac 管理员密码,不弹 osascript 授权窗)
# 用法: karuo_sudo.sh <command> [args...]
# 一次性配置: bash …/karuo_sudo_setup.sh
set -euo pipefail
SERVICE="karuo-mac-admin"
ACCOUNT="${USER}"
if ! security find-generic-password -a "$ACCOUNT" -s "$SERVICE" >/dev/null 2>&1; then
echo "❌ 钥匙串未配置 karuo-mac-admin。Agent 应自动执行: bash $(dirname "$0")/karuo_sudo_setup.sh" >&2
exit 64
fi
PASS="$(security find-generic-password -a "$ACCOUNT" -s "$SERVICE" -w)"
printf '%s\n' "$PASS" | sudo -S -p '' "$@"