#!/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}"