Repository navigation
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·39 lines (34 loc) · 1.66 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·39 lines (34 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# Prepare this host for one or more AgentOps roles, then run the doctor.
#
# ./bootstrap.sh coordinator|executor|workstation [...]
#
# Idempotent. It installs nothing system-wide and never fetches credentials:
# the owner places keys and logs in to model providers by hand (docs/new-host.md).
set -euo pipefail
[ $# -gt 0 ] || { sed -n '2,7p' "$0"; exit 1; }
root="$(cd "$(dirname "$0")" && pwd)"
cfgdir="$HOME/.config/agentops"; cfg="${AGENTOPS_CONFIG:-$cfgdir/config}"
for r in "$@"; do case "$r" in coordinator|executor|workstation) ;; *) echo "unknown role: $r" >&2; exit 1;; esac; done
missing=""
for t in git jq curl openssl; do command -v "$t" >/dev/null || missing="$missing $t"; done
case " $* " in *" coordinator "*) command -v gh >/dev/null || missing="$missing gh";; esac
[ -z "$missing" ] || { echo "install first:$missing" >&2; exit 1; }
install -d -m 700 "$cfgdir"
if [ ! -e "$cfg" ]; then
sed "s/^AGENTOPS_ROLES=.*/AGENTOPS_ROLES=\"$*\"/" "$root/config.example" > "$cfg"
chmod 600 "$cfg"
echo "created $cfg; fill in the placeholders, then run this again"
exit 0
fi
case " $* " in *" coordinator "*|*" workstation "*) install -d -m 700 "$HOME/.config/agent-apps";; esac
install -d "$HOME/.local/bin"
ln -sf "$root/bin/agentops" "$HOME/.local/bin/agentops"
for b in agentops-token agentops-pr agentops-executor agentops-tasks; do ln -sf "$root/bin/$b" "$HOME/.local/bin/$b"; done
# shellcheck source=/dev/null
. "$cfg"
case " $* " in
*" coordinator "*) "$root/bin/agentops" git-setup builder ;;
*" workstation "*) "$root/bin/agentops" git-setup builder --dir "${AGENTOPS_AGENT_DIR:?set AGENTOPS_AGENT_DIR}" ;;
esac
"$root/bin/agentops" doctor