guanghu-ice-heart/skills/codex/guanghu-os-server/scripts/authorize.sh

24 lines
623 B
Shell
Executable file

#!/bin/sh
set -eu
if [ "$#" -ne 1 ]; then
echo "usage: authorize.sh <registered-action>" >&2
exit 2
fi
if [ "${GH_OS_TARGET:-BS-SH-005}" != "BS-SH-005" ]; then
echo "STANDING_AUTHORIZATION_NOT_VALID_FOR_TARGET target=${GH_OS_TARGET}" >&2
exit 65
fi
target_alias="${GH_OS_SSH_ALIAS:-guanghu-os-bs-sh-005}"
ssh_config="${GH_OS_SSH_CONFIG:-/Users/bingshuolingdianyuanhe/.ssh/guanghu-os-bs-sh-005.conf}"
action="$1"
exec ssh \
-F "$ssh_config" \
-o BatchMode=yes \
-o ConnectTimeout=10 \
-o StrictHostKeyChecking=yes \
"$target_alias" \
"sudo -n /guanghu/bin/ghctl authorize /guanghu/current '$action'"