#!/bin/bash
# Every boot (agent-boot.service), and after the setup: sets the hostname asked at setup (/etc is
# read-only, so it is set on every boot), makes the ssh host key the first time, and wipes
# Claude's config except its login, so Claude starts fresh but logged in.
set -euo pipefail
cd /var/lib/agent
hostnamectl hostname --transient "$(cat hostname)"
[[ -f ssh_host_ed25519_key ]] || ssh-keygen -q -t ed25519 -N '' -f ssh_host_ed25519_key
find claude -mindepth 1 -maxdepth 1 ! -name .credentials.json ! -name .claude.json -exec rm -rf {} +
