#!/bin/sh
#
# (C) Copyright 1993, 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
#
#
# Configure the serial interfaces according to the descriptions in
# /etc/default/serial.

# Load the library and find various programs.
. /etc/init.d/LIB

SETSERIAL=`pathof setserial /sbin:/etc:/bin:/usr/etc:/usr/bin:/usr/local/bin`

# Set up serial ports. If an /etc/default/serial file exists we read
# the details and apply them. If not you're going to be stuck with
# the defaults which should be ok for COM1-4.
serial_done=
if [ -f /etc/default/serial ]; then
	echo $use_escapes "Configuring serial interfaces:\c"
	awk '/^[ \t]*[^#]/' /etc/default/serial | while read i
	do
		set -- $i
		if [ -n "$1" ]; then
			if [ -c "$1" ]; then
				echo $use_escapes " `basename $1`\c"
				$SETSERIAL $*
				serial_done=yes
			else
				echo "WARNING: Invalid line in /etc/default/serial."
				echo "WARNING: $1 is not a character device."
			fi
		fi
	done
	echo
fi

# If we didn't actually do anything we have an example defaults file or
# we may not have a defaults file at all. In either case we look for a
# non-bootsys style /etc/rc.serial script and run it if we find one.
if [ -z "$serial_done" -a -r "/etc/rc.serial" ]; then
	sh /etc/rc.serial
fi
