- add /pw (alias /password): reveal this room's password locally (never broadcast); surfaced in the F1 help overlay and the join hint - direnv-autostart/: cd-to-launch a single real-user session via direnv; password is minted in memory at launch (never written to disk, matching the RAM-only model) and scoped to the child process. setup.sh installs direnv, hooks bash/zsh, and `direnv allow`s the dir - lets-hack.sh: boot a FRESH server by default (replacing any live one) with a --reuse opt-out; add -h/--help/-help; guard against killing the tmux session you're attached to; switch-client into the coven when run inside tmux - rename coven→clergy across rust/python/scripts; tests/test_coven.py→test_clergy.py - snapshots in-progress hack-house client work (sandbox, themes, net, ui) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
2.6 KiB
Bash
Executable File
70 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# setup.sh — one-time setup for the hack-house direnv autostart ⛧
|
|
#
|
|
# Installs direnv (if missing), hooks your shell, and allows the .envrc in this
|
|
# directory so that simply `cd`-ing here launches your hack-house session.
|
|
#
|
|
# usage:
|
|
# ./setup.sh # set up autostart for THIS directory
|
|
# ./setup.sh --help
|
|
#
|
|
# After it finishes: open a new shell (or `source ~/.bashrc`), then `cd` into
|
|
# this directory — your single-user clergy boots automatically.
|
|
set -uo pipefail
|
|
|
|
HERE="$(cd "$(dirname "$0")" && pwd)" # the autostart dir (holds .envrc)
|
|
|
|
case "${1:-}" in
|
|
-h|--help|-help)
|
|
sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//'
|
|
exit 0 ;;
|
|
"") : ;;
|
|
*) echo "✖ unknown argument: $1 (try --help)" >&2; exit 2 ;;
|
|
esac
|
|
|
|
# 1. ensure direnv is installed
|
|
if command -v direnv >/dev/null 2>&1; then
|
|
echo "⛧ direnv already installed ($(direnv version 2>/dev/null))"
|
|
elif command -v apt-get >/dev/null 2>&1; then
|
|
echo "⛧ installing direnv via apt…"
|
|
sudo apt-get update -qq && sudo apt-get install -y direnv
|
|
elif command -v brew >/dev/null 2>&1; then
|
|
echo "⛧ installing direnv via brew…"
|
|
brew install direnv
|
|
else
|
|
echo "⛧ installing direnv via the official script (→ ~/.local/bin)…"
|
|
mkdir -p "$HOME/.local/bin"
|
|
export bin_path="$HOME/.local/bin"
|
|
curl -sfL https://direnv.net/install.sh | bash
|
|
fi
|
|
command -v direnv >/dev/null 2>&1 || { echo "✖ direnv install failed — see https://direnv.net/docs/installation.html" >&2; exit 1; }
|
|
|
|
# 2. hook direnv into the shell rc (idempotent). Covers bash and zsh.
|
|
hook_line_bash='eval "$(direnv hook bash)"'
|
|
hook_line_zsh='eval "$(direnv hook zsh)"'
|
|
add_hook() { # $1 = rc file, $2 = hook line
|
|
local rc="$1" line="$2"
|
|
[[ -f "$rc" ]] || return 0
|
|
if grep -qF 'direnv hook' "$rc"; then
|
|
echo "⛧ shell hook already present in $rc"
|
|
else
|
|
printf '\n# direnv (hack-house autostart)\n%s\n' "$line" >> "$rc"
|
|
echo "⛧ added direnv hook to $rc"
|
|
fi
|
|
}
|
|
add_hook "$HOME/.bashrc" "$hook_line_bash"
|
|
[[ -n "${ZDOTDIR:-}" && -f "$ZDOTDIR/.zshrc" ]] && add_hook "$ZDOTDIR/.zshrc" "$hook_line_zsh"
|
|
[[ -f "$HOME/.zshrc" ]] && add_hook "$HOME/.zshrc" "$hook_line_zsh"
|
|
|
|
# 3. allow this directory's .envrc
|
|
if [[ ! -f "$HERE/.envrc" ]]; then
|
|
echo "✖ no .envrc in $HERE — is this the autostart directory?" >&2
|
|
exit 1
|
|
fi
|
|
direnv allow "$HERE"
|
|
echo "⛧ allowed $HERE/.envrc"
|
|
|
|
echo
|
|
echo "⛧ done. open a new shell (or: source ~/.bashrc), then: cd $HERE"
|
|
echo " your single-user hack-house boots automatically (fresh server, generated password)."
|