Initial commit
authorJacob Casper <dev@jacobcasper.com>
Fri, 10 Apr 2020 21:02:12 +0000 (16:02 -0500)
committerJacob Casper <dev@jacobcasper.com>
Fri, 10 Apr 2020 21:02:12 +0000 (16:02 -0500)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
README.md [new file with mode: 0644]
sockgit-listen.socket [new file with mode: 0644]
sockgit-listen@.service [new file with mode: 0644]
sockgit.sh [new file with mode: 0755]
templates/description [new file with mode: 0644]
templates/info/description [new file with mode: 0644]
templates/info/exclude [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..d874ad6
--- /dev/null
@@ -0,0 +1 @@
+*.tar
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
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 (file)
index 0000000..bc2a611
--- /dev/null
@@ -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 (file)
index 0000000..1674d50
--- /dev/null
@@ -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 (executable)
index 0000000..b6f4c58
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+if [ $# -lt 2 ]
+then
+  echo $#
+  echo "Usage: sockgit <host> <repo-name>"
+  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 (file)
index 0000000..498b267
--- /dev/null
@@ -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 (file)
index 0000000..498b267
--- /dev/null
@@ -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 (file)
index 0000000..a5196d1
--- /dev/null
@@ -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]
+# *~