#!/bin/sh

# On startup of the gitolite container, force a receive of the gitolite-admin
# files from the persistent volume, to cause the user's real pubkeys and config
# files to take effect.
main() {
    sleep 5
    ssh -o StrictHostKeyChecking=accept-new git@localhost info # cache hostkey
    git clone --bare git@localhost:gitolite-admin.git /tmp/gladmin.git
    git --git-dir=/tmp/gladmin.git push origin :master # remove rmt master
    git --git-dir=/tmp/gladmin.git push origin master  # replace rmt master
}

main &
/usr/sbin/sshd -D