From 3bd921b8e25dd09af4b4b443a1c6cb3f9e132ee4 Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Fri, 10 Apr 2020 16:02:12 -0500 Subject: [PATCH] Initial commit --- .gitignore | 1 + Makefile | 10 ++++++++++ README.md | 7 +++++++ sockgit-listen.socket | 10 ++++++++++ sockgit-listen@.service | 21 +++++++++++++++++++++ sockgit.sh | 12 ++++++++++++ templates/description | 1 + templates/info/description | 1 + templates/info/exclude | 6 ++++++ 9 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 sockgit-listen.socket create mode 100644 sockgit-listen@.service create mode 100755 sockgit.sh create mode 100644 templates/description create mode 100644 templates/info/description create mode 100644 templates/info/exclude diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d874ad6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.tar diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c712bc8 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +.PHONY: install uninstall +install: + mkdir -p /usr/share/sockgit/templates && cp -r templates/* + cp sockgit-listen* /etc/systemd/system/ + ln -s $(shell pwd)/sockgit.sh /usr/bin/sockgit + +uninstall: + rm -f /etc/systemd/system/sockgit-listen* + rm -rf /usr/share/sockgit + rm -f /usr/bin/sockgit diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c59cd9 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Sockgit + +A simple service that allows creation of a new git repository without all of the trouble of having to actually ssh in and remember what to do as your stripped down `git` user. + +## Requirements + +- `netcat` diff --git a/sockgit-listen.socket b/sockgit-listen.socket new file mode 100644 index 0000000..bc2a611 --- /dev/null +++ b/sockgit-listen.socket @@ -0,0 +1,10 @@ +[Unit] +Description=Sockgit Listening Socket +PartOf=sockgit-listen@.service + +[Socket] +ListenStream=9119 +Accept=yes + +[Install] +WantedBy=sockets.target diff --git a/sockgit-listen@.service b/sockgit-listen@.service new file mode 100644 index 0000000..1674d50 --- /dev/null +++ b/sockgit-listen@.service @@ -0,0 +1,21 @@ +[Unit] +Description=Sockgit Listen Server +After=network.target sockgit-listen.socket +Requires=sockgit-listen.socket + +[Service] +Type=oneshot +User=git +Group=git +WorkingDirectory=/srv/git +ExecStart=/bin/bash -c 'while read REPO; do /usr/bin/git init --bare --shared $REPO.git && cd $REPO.git && /usr/bin/git remote add public $USER@$PUBLIC:$PATH/$REPO.git; done;' +StandardInput=socket +StandardOutput=syslog +StandardError=syslog +Environment="USER=git" +Environment="PUBLIC=add your url" +Environment="PATH=/srv/git" +Environment="GIT_TEMPLATE_DIR=/usr/share/sockgit/templates" + +[Install] +WantedBy=multi-user.target diff --git a/sockgit.sh b/sockgit.sh new file mode 100755 index 0000000..b6f4c58 --- /dev/null +++ b/sockgit.sh @@ -0,0 +1,12 @@ +#!/bin/bash +if [ $# -lt 2 ] +then + echo $# + echo "Usage: sockgit " + exit 1 +fi +if [ -z $PORT ] +then + PORT=9119 +fi +echo $2 | timeout 1 netcat $1 $PORT diff --git a/templates/description b/templates/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/templates/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/templates/info/description b/templates/info/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/templates/info/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/templates/info/exclude b/templates/info/exclude new file mode 100644 index 0000000..a5196d1 --- /dev/null +++ b/templates/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ -- 2.20.1