From 8667f8615da479a8e9c4e8d5bb5987632d75bfaf Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Fri, 5 Dec 2025 21:43:18 -0800 Subject: Add ssh server --- init-repo | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 init-repo (limited to 'init-repo') diff --git a/init-repo b/init-repo new file mode 100644 index 0000000..5749866 --- /dev/null +++ b/init-repo @@ -0,0 +1,38 @@ +#!/bin/sh +# Helper script for git-shell to initialize bare repositories +# Usage: ssh code@host init-repo [description] + +if [ $# -lt 1 ] || [ $# -gt 2 ]; then + echo "Usage: init-repo [description]" + echo "Example: init-repo myproject.git" + echo "Example: init-repo myproject.git 'A repo with foo'" + exit 1 +fi + +REPO_NAME="$1" +DESCRIPTION="$2" + +# Ensure it ends with .git +case "$REPO_NAME" in + *.git) ;; + *) REPO_NAME="${REPO_NAME}.git" ;; +esac + +REPO_DIR="$HOME/$REPO_NAME" + +if [ -e "$REPO_DIR" ]; then + echo "Error: Repository '$REPO_NAME' already exists" + exit 1 +fi + +echo "Initializing bare repository: $REPO_NAME" +git init --bare "$REPO_DIR" + +# Add description if provided +if [ -n "$DESCRIPTION" ]; then + echo "$DESCRIPTION" > "$REPO_DIR/description" + echo "Description set: $DESCRIPTION" +fi + +echo "Repository initialized at: $REPO_DIR" +echo "You can now push to it with: git remote add origin ssh://code@host/$REPO_NAME" -- cgit v1.2.3-70-g09d2