#!/bin/sh
## $1 = User = Group ; $2 = rootdir
REPOSITORY="$2/repository"
SETTIGNS="$2/settings.cfg"
SECRET_KEY=${SECRET_KEY:-$(python3 -c 'import secrets; print(secrets.token_hex())')}

mkdir -p "$REPOSITORY" ||:
git init -b main "$REPOSITORY" ||:
test -r "$SETTIGNS" || cat > "$SETTIGNS" <<@@@
REPOSITORY='$REPOSITORY'
SQLALCHEMY_DATABASE_URI='sqlite:///$2/db.sqlite'
SECRET_KEY='$SECRET_KEY'
@@@
