e17a0b8f951af062eac19c12c5c59fe429d959b5 / scripts/local-uat.sh · 1191 bytes · raw
#!/usr/bin/env bash
# Local UAT: build simplegit, set up a throwaway instance, and serve it.
#
# scripts/local-uat.sh [port] # default 8090
#
# Env overrides: UAT_DIR (default ./.uat), UAT_USER (josie), UAT_PASS (hunter2).
# Data and the built binary live in UAT_DIR; delete that dir to reset state.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PORT="${1:-8090}"
HOST="127.0.0.1"
DIR="${UAT_DIR:-$ROOT/.uat}"
USERNAME="${UAT_USER:-josie}"
PASSWORD="${UAT_PASS:-hunter2}"
mkdir -p "$DIR"
echo "building simplegit…"
go build -o "$DIR/simplegit" "$ROOT/cmd/simplegit"
cat > "$DIR/sg.toml" <<EOF
data_dir = "$DIR/data"
listen_addr = "$HOST:$PORT"
base_url = "http://$HOST:$PORT"
EOF
if [ ! -f "$DIR/data/simplegit.db" ]; then
printf '%s\n' "$PASSWORD" | "$DIR/simplegit" adduser -config "$DIR/sg.toml" "$USERNAME"
fi
cat <<EOF
simplegit UAT is up:
web: http://$HOST:$PORT
user: $USERNAME
pass: $PASSWORD
data: $DIR/data (delete this dir to reset)
In the UI, create a repo, then push to:
http://$USERNAME:$PASSWORD@$HOST:$PORT/$USERNAME/<repo>.git
Press Ctrl-C to stop.
EOF
exec "$DIR/simplegit" serve -config "$DIR/sg.toml"