aboutsummaryrefslogtreecommitdiff
path: root/roles/git/files/gitolite-cgit/entrypoint.sh
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-12-14 23:04:46 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-12-14 23:04:46 +0100
commit7f375b8097e7a44cc5924bf1cee5159593cbe0eb (patch)
treecc1be9bcbd64aa4f7f2d6b2cd1c04949b9c8c9a8 /roles/git/files/gitolite-cgit/entrypoint.sh
parent5262aab814e41005562f44d76e6de8be125199a4 (diff)
downloadansible-memzero-7f375b8097e7a44cc5924bf1cee5159593cbe0eb.tar.gz
ansible-memzero-7f375b8097e7a44cc5924bf1cee5159593cbe0eb.zip
git: add role to build and start gitolite-cgit
This contains a role to build and start a gitolite-cgit container. Additionally this installed a firewall rule to open the gitolite sshd port.
Diffstat (limited to 'roles/git/files/gitolite-cgit/entrypoint.sh')
-rwxr-xr-xroles/git/files/gitolite-cgit/entrypoint.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/roles/git/files/gitolite-cgit/entrypoint.sh b/roles/git/files/gitolite-cgit/entrypoint.sh
new file mode 100755
index 0000000..905bf97
--- /dev/null
+++ b/roles/git/files/gitolite-cgit/entrypoint.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Fixup permissions.
+chown git:git -R /var/lib/git
+# Ensure password is set for git user (required for gitolite).
+echo "git:$(head -c 16 /dev/urandom | base64)" | chpasswd
+
+# -- SETUP: gitolite -----------------------------------------------------------
+
+if [ ! -f /var/lib/git/.gitolite.rc ]; then
+ cp /etc/gitolite.rc /var/lib/git/.gitolite.rc
+ chown git:git /var/lib/git/.gitolite.rc
+fi
+
+if [ ! -f /var/lib/git/.ssh/authorized_keys ]; then
+ if [ -z ${SSH_KEY} ]; then
+ echo "ERROR: Must pass admin key ass SSH_KEY!"
+ exit 1
+ fi
+
+ echo "${SSH_KEY}" > /tmp/admin.pub
+ su - git -c 'gitolite setup --pubkey /tmp/admin.pub'
+ rm -f /tmp/admin.pub
+else
+ su - git -c 'gitolite setup'
+fi
+
+# -- SETUP: sshd ---------------------------------------------------------------
+
+# Generate ssh host keys (nop if keys already exist).
+ssh-keygen -A
+
+# -- SETUP: nginx --------------------------------------------------------------
+
+rm -f /etc/nginx/http.d/default.conf
+
+# -- Launch processes ----------------------------------------------------------
+
+spawn-fcgi -s /run/fcgiwrap.sock -U nginx -- /usr/bin/fcgiwrap
+nginx
+
+# Start sshd non-detached.
+/usr/sbin/sshd -D