#!/bin/bash

# We need to reexecute these commands
# because Kubernetes doesn't use the
# VOLUME commands in the Dockerfiles
# when using volumes. So this makes
# things work on Kubernetes, but the
# Dockerfile makes things work when
# running locally.
mkdir -p /mounted/repos
chgrp -R committers /mounted
chmod -R 0770 /mounted

RUN mkdir -p /data/ssh

/bin/bash /usr/local/bin/helpers/pull.sh
/bin/bash /usr/local/bin/helpers/pullkeys.sh

KEYS=/data/ssh/*
for k in "${KEYS[@]}"
do
	base=${k##*/}
	echo "Linking ${k} to /etc/ssh/${base}"
	ln -s $k /etc/ssh/$base
done

cp /tmp/sshpubkeys/* /etc/ssh/

/usr/sbin/sshd -D
