#! /bin/bash
# ************************************************
# creation of tty and cua devices for VScom cards
# ************************************************
i=0
if [ $# -eq 0 ]; then
	BIS=31;
elif [ $# -eq 1 ]; then
	BIS=$1
else
	echo usage: $0 '[max port number]'
	echo Default max port number is 31
	exit  10
fi
w=`which mknod`
if ! [ -e "$w" ]; then
	echo "mknod must be in path"
	exit 10
fi

FILENAME=""
MAJOR=4;
MINOR=64;
do_mknod()
{
	if ! [ -c $FILENAME ]; then
		mknod -m 660 $FILENAME c $MAJOR $MINOR
		chown root.uucp $FILENAME
	fi 	
}
while [ $i -le $BIS ]; do
	MAJOR=4;
	MINOR=$(($i+64))
	FILENAME=/dev/ttyS$i
	do_mknod
	MAJOR=5;
	FILENAME=/dev/cua$i
	do_mknod
	i=$(($i+1))
done
exit 0

