OpenSolaris_b135/pkgdefs/common_files/i.dialers

#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#ident	"%Z%%M%	%I%	%E% SMI"
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

while read src dest
do
	if [ ! -f $dest ] ; then
		cp $src $dest
	else
		# add USR Courier entry
		grep '^usrv32-ec[ 	]' $dest > /dev/null 2>&1
		if [ $? != 0 ] ; then
			echo "" > /tmp/x.$$
			sed -n '/#.*USR Courier/,/^usrv32-nec/p' $src >> \
			   /tmp/x.$$

			#
			# add it after the hayes entry if it exists,
			# otherwise add it at the end.
			#
			grep '^hayes[ 	]' $dest > /dev/null 2>&1
			if [ $? = 0 ] ; then
				sed "/^hayes[ 	]/r /tmp/x.$$" $dest > \
				    /tmp/ex.$$
				mv /tmp/ex.$$ $dest
			else
				cat /tmp/x.$$ >> $dest
			fi
		fi

		# add Telebit T1600 entry
		grep '^tb9600-ec[ 	]' $dest > /dev/null 2>&1
		if [ $? != 0 ] ; then
			echo "" > /tmp/x.$$
			sed -n '/#.*Telebit T1600/,/^tb9600-nec/p' $src >> \
			    /tmp/x.$$
			grep '^tbfast[ 	]' $dest > /dev/null 2>&1

			#
			# add it after the tbfast entry if it exists,
			# otherwise add it at the end.
			#
			if [ $? = 0 ] ; then
				sed "/^tbfast/r /tmp/x.$$" $dest > \
				    /tmp/ex.$$
				mv /tmp/ex.$$ $dest
			else
				cat /tmp/x.$$ >> $dest
			fi
		fi

		# update STTY of usrv32-ec
		grep '^usrv32-ec[ 	]' $dest | grep 'STTY=' |
			grep -v 'crtsxoff' > /dev/null 2>&1
		if [ $? = 0 ] ; then
			sed "/^usrv32-ec[ 	]/s/crtscts/crtscts,crtsxoff/" \
				$dest > /tmp/x.$$
			mv /tmp/x.$$ $dest
		fi

		# update STTY of usrv32-nec
		grep '^usrv32-nec[ ]' $dest | grep 'STTY=' |
			grep -v 'crtsxoff' > /dev/null 2>&1
		if [ $? = 0 ] ; then
			sed "/^usrv32-nec[ 	]/s/crtscts/crtscts,crtsxoff/" \
				$dest > /tmp/x.$$
			mv /tmp/x.$$ $dest
		fi

		# update STTY of tb9600-ec
		grep '^tb9600-ec[ 	]' $dest | grep 'STTY=' |
			grep -v 'crtsxoff' > /dev/null 2>&1
		if [ $? = 0 ] ; then
			sed "/^tb9600-ec[ 	]/s/crtscts/crtscts,crtsxoff/" \
				 $dest > /tmp/x.$$
			mv /tmp/x.$$ $dest
		fi

		# update STTY of tb9600-nec
		grep '^tb9600-nec[ 	]' $dest | grep 'STTY=' |
			grep -v 'crtsxoff' > /dev/null 2>&1
		if [ $? = 0 ] ; then
			sed "/^tb9600-nec[ 	]/s/crtscts/crtscts,crtsxoff/" \
				 $dest > /tmp/x.$$
			mv /tmp/x.$$ $dest
		fi


		rm -f /tmp/*.$$
	fi
done

exit 0