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

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

LPCNTL=`pathof lpcntl /sbin:/etc:/bin:/usr/etc:/usr/bin:/usr/local/bin`

# Set up parallel ports. If an /etc/default/parallel file exists we read
# the details and apply them.
parallel_done=
if [ -f /etc/default/parallel ]; then
	echo $use_escapes "Configuring parallel interfaces:\c"
	awk '/^[ \t]*[^#]/' /etc/default/parallel | while read i
	do
		set -- $i
		if [ -n "$1" ]; then
			if [ -c "$1" ]; then
				echo $use_escapes " `basename $1`\c"
				$LPCNTL $*
				parallel_done=yes
			else
				echo "WARNING: Invalid line in /etc/default/parallel."
				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.parallel script and run it if we find one.
if [ -z "$parallel_done" -a -r "/etc/rc.parallel" ]; then
	sh /etc/rc.parallel
fi
