Files
multi-agent-mux/deploy/generate-env.sh
T
Godopu eb733cf7c1 refactor(deploy): consolidate install scripts and INSTALL.md into deploy/
- Move scripts/install_mam.sh → deploy/install_mam.sh (local-clone installer)
- Move scripts/generate-env.sh → deploy/generate-env.sh (env helper)
- Move .agents/INSTALL.md → deploy/INSTALL.md (user manual)
- Update install_mam.sh to copy INSTALL.md + generate-env.sh from new paths
- Ship INSTALL.md via deploy/install.sh remote path too (manifest-tracked)
- Update README/BOOTSTRAP generate-env.sh references & repository ASCII layout
- Extend deploy/README.md structure section; extend gitea-ci.yml lint list
- Remove now-empty scripts/ directory
- Fix duplicate ### 2. subsection headers in deploy/README.md (address B-2)
- Correct deploy/INSTALL.md dependency description to match actual checks (address M-1)
- Add local-clone lifecycle caveat (no update.sh/remove.sh) (address M-2)

Closes the deploy consolidation plan and addresses Planner / Reviewer feedback.
2026-07-12 16:30:15 +09:00

46 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# generate-env.sh — create a local .env from the committed .env.example template.
#
# Behaviour:
# - .env absent → copy .env.example to .env, print the path.
# - .env present → no-op (leaves your edits intact), exit 0.
# - .env present --force → overwrite .env from .env.example (backs up to .env.bak).
#
# Paths are resolved relative to this script (repo root = parent of deploy/),
# so it works regardless of the caller's cwd.
#
# Usage: deploy/generate-env.sh [--force] [-h|--help]
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SRC="$REPO_ROOT/.env.example"
DST="$REPO_ROOT/.env"
FORCE=0
while [ $# -gt 0 ]; do
case "$1" in
--force) FORCE=1; shift ;;
-h|--help)
echo "Usage: $0 [--force]"
echo " Create .env from .env.example. --force overwrites an existing .env."
exit 0 ;;
*) echo "ERROR: unknown arg: $1" >&2; echo "Usage: $0 [--force]" >&2; exit 2 ;;
esac
done
[ -f "$SRC" ] || { echo "ERROR: template not found: $SRC" >&2; exit 1; }
if [ -f "$DST" ] && [ "$FORCE" != "1" ]; then
echo "no-op: $DST already exists (use --force to overwrite)"
exit 0
fi
if [ -f "$DST" ] && [ "$FORCE" = "1" ]; then
cp -p "$DST" "$DST.bak"
echo "backed up existing .env -> $DST.bak"
fi
cp "$SRC" "$DST"
echo "created: $DST"
echo "Next: edit $DST and fill in any secrets (look for 'replace_me')."