summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Abbott <george@gabbott.dev>2023-11-01 20:49:32 +0000
committerGeorge Abbott <george@gabbott.dev>2023-11-01 20:49:32 +0000
commit6fff36ec2876beea17ab6d2e878c798906b3c10b (patch)
tree5dae0141521136c96a7061b6925157f01d703a0a
parent4d00f8bf6b22f31be628a9a43f3d6535481b6e2f (diff)
Added init_cgit
l---------all/init-cgit1
-rwxr-xr-xweb/init-cgit34
2 files changed, 35 insertions, 0 deletions
diff --git a/all/init-cgit b/all/init-cgit
new file mode 120000
index 0000000..98f43bf
--- /dev/null
+++ b/all/init-cgit
@@ -0,0 +1 @@
+../web/init-cgit \ No newline at end of file
diff --git a/web/init-cgit b/web/init-cgit
new file mode 100755
index 0000000..8e730c1
--- /dev/null
+++ b/web/init-cgit
@@ -0,0 +1,34 @@
+#!/bin/sh
+# init-cgit: initialize a repo on cgit.
+# Requires ssh access to the git user.
+# To do, run this in the directory of the repo you would like to init on cgit.
+# It will add a remote `cgit` pointing to `git@example.com:/srv/git/repo.git.
+# $1 = name of repo - I guess we could get this from the cwd maybe?.
+# $2 = description to override repo/description with.
+
+if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
+ echo "init-cgit NAME DESCRIPTION"
+ echo "Example:"
+ echo ' init-cgit dotfiles "All of my dotfiles."'
+ exit 0
+fi
+
+
+GIT_USER="git"
+SRV_GIT_PATH="/srv/git"
+
+if [ -z "$BARE_WEBSITE_URL" ] ; then
+ echo "BARE_WEBSITE_URL must be set"
+ exit 1
+fi
+
+# First, create bare repo on remote.
+ssh "$GIT_USER@$BARE_WEBSITE_URL" "cd; git init --bare $1"
+
+if [ ! -z "$2" ] ; then
+ ssh "$GIT_USER@$BARE_WEBSITE_URL" "cd; echo \"$2\" > $1/description"
+fi
+
+# Now create `cgit` remote in local repo.
+git remote add cgit "$GIT_USER@$BARE_WEBSITE_URL:$SRV_GIT_PATH/$1"
+git push cgit master