#!/bin/sh printf "\033[1;31m" set -e set -x SSHD_PORT="${SSHD_PORT:-8022}" NGINX_LISTEN="${NGINX_LISTEN:-8080}" # This is shown on the cgit user interface by default, you may # wish to change it FULL_NAME="${FULL_NAME:-Default Cgit User}" # Bash is installed by default, feel free to change this CGIT_SHELL="${CGIT_SHELL:-/bin/ash}" # UID and GID used by the `git` user inside of the container CGIT_UID="${CGIT_UID:-3500}" CGIT_GID="${CGIT_GID:-3500}" # Threads for fcgiwrap CGIT_THREADS="${CGIT_THREADS:-1}" # Where the SSH host keys will be stored, SSH_HOST_KEY_DIR="${SSH_HOST_KEY_DIR:-/var/hostkeys/}" NGINX_WORKER_PROCESSES="${NGINX_WORKER_PROCESSES:-1}" NGINX_WORKER_CONNECTIONS="${NGINX_WORKER_CONNECTIONS:-1024}" printf "\033[0m" # This is only run once in the container's lifetime unless /setup is removed setup() { if [ -e /setup ] ; then return ; fi if [ "$(find /var/git -type f | wc -l)" -eq 0 ] ; then cp -r /var/default/git/* /var/git/ fi addgroup -g "${CGIT_GID}" git adduser -h /var/git --gecos "$FULL_NAME" -D -s "${CGIT_SHELL}" -u "${CGIT_UID}" -G git git passwd -u git addgroup nginx git if [ -n "$AUTHORIZED_KEYS" ] ; then mkdir -p /etc/ssh/keys echo "$AUTHORIZED_KEYS" | tee /etc/ssh/keys/git fi touch /setup } run_nginx() { cat > /etc/nginx/nginx.conf <\\n'; # content="\$host\$uri git \$scheme://\$host/cgi-bin/cgit.cgi\$uri.git">\\n'; } } } NGINX mkdir -p /run/nginx nginx -g 'daemon off;' & } run_cgit() { #!/bin/sh sockdir=/tmp/cgit if ! [ -d "$sockdir" ] ; then mkdir "$sockdir" fi chown -R git:git /tmp/cgit socket="/tmp/cgit/cgit.sock" if [ -e "$socket" ] ; then rm "$socket" fi umask 007 # su git -c "fcgiwrap -c$CGIT_THREADS -s \"unix:$socket\" &" su git -c "fcgiwrap -f -c$CGIT_THREADS -s \"unix:$socket\" &" } run_sshd() { if [ -d "$SSH_HOST_KEY_DIR" ] ; then cp -v "$SSH_HOST_KEY_DIR"/* /etc/ssh/ || echo "" fi ssh-keygen -A if [ -d "$SSH_HOST_KEY_DIR" ] ; then cp -v /etc/ssh/ssh_host* "$SSH_HOST_KEY_DIR"/ fi cat > /etc/ssh/sshd_config </dev/null ; then echo "Service $service has stopped... quitting!" exit 1 fi done sleep "$interval" done } setup chown -R git:git /var/git run_nginx run_cgit run_sshd set +x # Bail out if a service stops, poll it every 30 seconds watchServices 30 # or if you comment out the above, drop into a shell # exec /bin/ash "$@"