#!/bin/sh
set -e
HOME=~hg
export HOME
cd
rm -rf temporary-breakin-repo
mkdir temporary-breakin-repo
cd temporary-breakin-repo
hg clone ~/repos/hgadmin .
if [ $(echo *) != "" ] ; then
DIRNAME=retry
while [ $DIRNAME = retry ] ; do
DIRNAME=$(date -u +"%F_%T.%N")
mkdir $DIRNAME || DIRNAME=retry
done
hg mv * $DIRNAME
hg mv -f $DIRNAME old
fi
hg echo "init user=initkey" > hg-ssh-access.conf
mkdir keys
cat > keys/initkey
hg add hg-ssh-access.conf keys/initkey
hg commit -m "Reset access to a single key via break-in script"
SSH_ORIGINAL_COMMAND= /etc/mercurial-server/hg-ssh-wrapper root