#!/bin/sh

if [ -f /etc/tux/config/dropbear/hostkey ]
then
	echo "--Found existing dss_host_key"
	cp /etc/tux/config/dropbear/hostkey /etc/dropbear_dss_host_key
else
	echo "--Generating dss_host_key"
	dropbearkey -t dss -f /etc/dropbear_dss_host_key
	echo "Remember to save to boot device using 'save-config'"
fi

cat /etc/passwd | grep -v root > /etc/passwd
echo "root:x:0:0:Trinux Root:/:/bin/sh" >> /etc/passwd

[ -d /.ssh ] || mkdir /.ssh
[ -f /etc/tux/config/dropbear/sshkeys ] && cp /etc/tux/config/dropbear/sshkeys /.ssh/authorized_keys


if [ -f /etc/tux/config/dropbear/keyserver ]
then 
	KEYSERVER=`cat /etc/tux/config/dropbear/keyserver`
	echo "--Retrieving sshkeys from $KEYSERVER"
	snarf $KEYSERVER /tmp/dropkeys
	cat /tmp/dropkeys >> /.ssh/authorized_keys
fi

dropbear
