#!/bin/ash
# /bin/login wrapper+diversion
# by M. Andreoli

#set -x

# rustic authentication

auth()
{
while [ 1 ]; do
[ "`which stty`" ] && stty -echo
read -p "password: " password
[ "`which stty`" ] && stty echo
/sbin/chkpasswd "$USER" "$password" && break
done

}

# Main



if [ -x /usr/srv/bin/login ] ; then
	LOGIN=/usr/srv/bin/login
elif [ -x /usr/local/bin/login ] ; then
	LOGIN=/usr/local/bin/login
else
	LOGIN="-ash -si"
	#auth
fi


if [ -x /usr/bin/ile ] &&  [ -r /etc/history.conf ]; then
	HISTORY="/usr/bin/ile -/etc/ilerc"
else
	HISTORY=
fi


export TERM=linux
eval exec $HISTORY $LOGIN $@
