aboutsummaryrefslogtreecommitdiff
path: root/nix/per-host/git/git-shell-commands/create
diff options
context:
space:
mode:
authorKumar Damani <me@kumardamani.net>2026-08-02 01:43:25 +0000
committerKumar Damani <me@kumardamani.net>2026-08-02 01:43:25 +0000
commit43930cb8c22bc28ed64362845c5f4ebf54faabf2 (patch)
tree7351357bd38139b0267f1a4cdeff4b5143f5e89a /nix/per-host/git/git-shell-commands/create
parent3e139a0e702513f6e1145158b2695b43c8251b92 (diff)
added git with cgit
Diffstat (limited to 'nix/per-host/git/git-shell-commands/create')
-rwxr-xr-xnix/per-host/git/git-shell-commands/create49
1 files changed, 49 insertions, 0 deletions
diff --git a/nix/per-host/git/git-shell-commands/create b/nix/per-host/git/git-shell-commands/create
new file mode 100755
index 0000000..459f428
--- /dev/null
+++ b/nix/per-host/git/git-shell-commands/create
@@ -0,0 +1,49 @@
+#!/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 </dev/null to accept
+# the defaults (empty description, owner kdam0, private).
+# Run: ssh git@git.kumardamani.net create [name]
+
+name="${1:-}"
+
+if [ -z "$name" ]; then
+ printf 'repo name: '
+ read -r name
+fi
+case "$name" in
+ ""|*[!a-zA-Z0-9._-]*|*..*)
+ echo "error: invalid name '$name' (allowed: a-z 0-9 . _ -)" >&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