#!/usr/bin/env bash # git-shell-commands(5) subcommand: create a new bare repo. # Prompts for each configurable setting: name (if not given as an # argument), description, owner and visibility. Pipe &2 exit 1 ;; esac repo="/srv/git/$name.git" if [ -e "$repo" ]; then echo "error: repo '$name' already exists" >&2 exit 1 fi printf 'description (optional): ' read -r desc printf 'owner [kdam0]: ' read -r owner owner="${owner:-kdam0}" printf 'publish now? [y/N]: ' read -r pub git init --bare --quiet "$repo" git -C "$repo" config gitweb.owner "$owner" [ -n "$desc" ] && printf '%s\n' "$desc" > "$repo/description" case "$pub" in y|Y|yes) touch "$repo/git-daemon-export-ok" echo "created public repo '$name': https://git.kumardamani.net/$name" ;; *) echo "created private repo '$name'" echo "publish it with: ssh git@git.kumardamani.net publish $name" ;; esac