From ac89b3c715fd3eddca7898e069ee04498c1a1ba2 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Fri, 24 Apr 2026 23:36:52 +0200 Subject: INITIAL COMMIT --- entrypoint.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 entrypoint.sh (limited to 'entrypoint.sh') diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..3737a7e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,50 @@ +#!/bin/sh +set -Eeuo pipefail + +# Copy over the secrets to fix permissions +mkdir -p /run/git-host/secrets +cp /etc/git-host/secrets/authorized_keys /run/git-host/secrets/authorized_keys +cp /etc/git-host/secrets/htpasswd /run/git-host/secrets/htpasswd +cp /etc/git-host/secrets/ssh_host_ed25519_key /run/git-host/secrets/ssh_host_ed25519_key +cp /etc/git-host/secrets/ssh_host_ed25519_key.pub /run/git-host/secrets/ssh_host_ed25519_key.pub +cp /etc/git-host/secrets/ssh_host_rsa_key /run/git-host/secrets/ssh_host_rsa_key +cp /etc/git-host/secrets/ssh_host_rsa_key.pub /run/git-host/secrets/ssh_host_rsa_key.pub +chown -R root:root /run/git-host/secrets +chown root:git /run/git-host/secrets/authorized_keys +chown root:git /run/git-host/secrets/htpasswd +chown root:root /run/git-host/secrets/ssh_host_ed25519_key +chown root:root /run/git-host/secrets/ssh_host_ed25519_key.pub +chown root:root /run/git-host/secrets/ssh_host_rsa_key +chown root:root /run/git-host/secrets/ssh_host_rsa_key.pub +chmod 0755 /run/git-host /run/git-host/secrets +chmod 0640 /run/git-host/secrets/authorized_keys +chmod 0640 /run/git-host/secrets/htpasswd +chmod 0600 /run/git-host/secrets/ssh_host_ed25519_key +chmod 0644 /run/git-host/secrets/ssh_host_ed25519_key.pub +chmod 0600 /run/git-host/secrets/ssh_host_rsa_key +chmod 0644 /run/git-host/secrets/ssh_host_rsa_key.pub + +# Validate +/usr/sbin/sshd -t -f /etc/ssh/sshd_config +lighttpd -tt -f /etc/lighttpd/lighttpd.conf + +# Start servers +/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config & +sshd_pid=$! + +lighttpd -D -f /etc/lighttpd/lighttpd.conf & +lighttpd_pid=$! + +# Wait for them to end, kill if either does +terminate() { + kill "${sshd_pid}" "${lighttpd_pid}" 2>/dev/null || true +} + +trap terminate INT TERM + +status=0 +wait -n "${sshd_pid}" "${lighttpd_pid}" || status=$? +terminate +wait "${sshd_pid}" 2>/dev/null || true +wait "${lighttpd_pid}" 2>/dev/null || true +exit "${status}" -- cgit v1.2.3