#!/bin/sh

# Sample login wrapper -- name as /.../menulogin or /.../menuloginsh
# and it'll allow shell or not as it ends with ...sh.  Could also be
# modified to enable -r for some naming scheme.
# This junk is pretty Nyx specific, and outdated, but the idea's the thing.

echo "Configuring..."

set `du -s .`
echo "FYI, your disk usage is: $1 K."
if [ "$1" -gt 100 ]; then
	echo "Reminder, please keep your home dirs small (under 100 K)."
	echo "There's plenty of temp space elsewhere."

	free=`/u1/bin/pdf`
	if [ "$free" -lt 20000 ]; then
		echo "Note that free space (for EVERYONE) is tight: only $free K."
		echo "(And you are using more than 100 K -- hint hint.)"
		echo "Use the 'du2' option on the status menu for more info."
		if [ "$free" -lt 5000 ]; then
			echo "***Indeed, with so little space, consider it imperative -- clean up immediately!"
		fi
	fi
fi

mendir=/u5/lib/menus
dldir=/u3/lib/download
if [ -r $HOME/.termtype ]; then
	. $HOME/.termtype
else
#	TERM=dw1
	TERM=vt100
	TERMCAP=/etc/termcap
fi
PATH=/u1/bin:/u5/bin:/usr/ucb:/bin:/usr/bin:.
if [ -r $HOME/.editor ]; then
	EDITOR=$HOME/.editor
else
	EDITOR=/u5/bin/smile
fi
if [ -f $HOME/.biffy ]; then
	biff y
fi
if [ -f $HOME/.mesgn ]; then
	mesg n
fi
if [ -f $HOME/.environment ]; then
	. $HOME/.environment
fi
case $0 in
	*sh)
		# shell is ok
		SHELL=/bin/csh
		opt=""
		;;
	*)
		# shell is not allowed
		SHELL=/u1/bin/noshell
		opt="-s"
		;;
esac

export PATH
export SHELL
export mendir
export dldir
export EDITOR
export TERMCAP
export TERM

if [ -r $HOME/.rninit ]; then
	RNINIT=$HOME/.rninit
	export RNINIT
fi
stty -tabs crt susp undef dsusp undef -nohang erase '^h' kill '^u' intr '^c'
echo "Hit ENTER to continue...\c"
read xxx
exec /u5/bin/mshell $opt main
