docs/demo/env.sh

ba0a7d33f3a65ce53aafb074fda1682cf1cecfdf
gitbay/docs/demo/env.sh history · blame · raw

25 lines · 1477 bytes

 1# Sourced by the tapes. Gives the recording a home of its own so the
 2# demo account's key, known_hosts, git identity and CLI profile never
 3# touch the operator's. OpenSSH reads ~ from the password database, not
 4# $HOME, so ssh is wrapped to pass -F explicitly. The home stays short:
 5# the CLI's ControlPath lives under it and a Unix socket path caps at 104.
 6DEMO_HOME=${DEMO_HOME:-$HOME/.gitbay-demo}
 7mkdir -p "$DEMO_HOME/.ssh" "$DEMO_HOME/bin" "$DEMO_HOME/.config/gitbay" "$DEMO_HOME/work"
 8chmod 700 "$DEMO_HOME/.ssh"
 9[ -f "$DEMO_HOME/.ssh/id_ed25519" ] ||
10	ssh-keygen -q -t ed25519 -f "$DEMO_HOME/.ssh/id_ed25519" -N '' -C zerocool
11[ -s "$DEMO_HOME/.ssh/known_hosts" ] ||
12	ssh-keygen -F gitbay.org | grep -v '^#' > "$DEMO_HOME/.ssh/known_hosts"
13printf 'Host *\n  IdentityFile %s\n  IdentitiesOnly yes\n  IdentityAgent none\n  UserKnownHostsFile %s\n' \
14	"$DEMO_HOME/.ssh/id_ed25519" "$DEMO_HOME/.ssh/known_hosts" > "$DEMO_HOME/.ssh/config"
15printf '#!/bin/sh\nexec /usr/bin/ssh -F "%s" "$@"\n' "$DEMO_HOME/.ssh/config" > "$DEMO_HOME/bin/ssh"
16chmod +x "$DEMO_HOME/bin/ssh"
17printf '[user]\n\tname = Zero Cool\n\temail = zerocool@gitbay.org\n[init]\n\tdefaultBranch = main\n' \
18	> "$DEMO_HOME/.gitconfig"
19printf 'default = "gitbay"\n\n[instances.gitbay]\nhost = "gitbay.org"\n' \
20	> "$DEMO_HOME/.config/gitbay/config.toml"
21
22export HOME=$DEMO_HOME PATH=$DEMO_HOME/bin:$PATH EDITOR=true
23unset SSH_AUTH_SOCK XDG_CONFIG_HOME
24PS1='\[\e[38;5;208m\]\W\[\e[0m\] $ '
25cd "$DEMO_HOME/work"