Subject: Re: Problem with the 3/7 sources.
To: Mark P. Gooderum <mark@aggregate.com>
From: Jan-Hinrich Fessel <oskar@zappa.Ruhr.DE>
List: current-users
Date: 03/14/1994 07:06:49
> My alternative is to edit /etc/tty, HUP init, do my dialing, 
> finish, edit /etc/tty, HUP init again, okay.  Now I maybe try to make
> this automatic.  Hmm, a script wrapper around tip, cu, or kermit.
> Hmm, sed? awk? perl?  Oh, yeah, hope things run to completion and clean up
> properly.  This is less ugly than cua ??

Yeah, it sure is ugly, but kind of this woks for me quite nice.  Not 
very elaborate, but you get the basic idea how stinky com is at the moment.

---------
#!/bin/sh
PATH=/bin:/usr/bin:
export PATH

# switch getty off for dialout. turn getty on after call done.

usage() {
	echo "$0: usage: $0 line"
	exit 1
}

[ $# -lt 1 ] && {
	usage
}

LINE=$1
DEVICE=/dev/$1
LOCKFILE=/var/spool/lock/LCK..$LINE

[ -f $LOCKFILE ] && {
	echo "$DEVICE is already in use by `cat $LOCKFILE`"
	exit 1
}

#
# lock the line (temporary)
#
echo "$$" > $LOCKFILE

cat /etc/ttys | sed -e "/^$LINE/s/on /off /" > /tmp/ttytmp
cp /etc/ttys /etc/ttys.old
mv -f /tmp/ttytmp /etc/ttys

#
# wait for the line to become free
#
while true
do
	ps auxww | grep $LINE | grep getty > /dev/null 2>&1
	[ $? = 0 ] && break
	sleep 1
done

#
# OK, getty is running on a free line,
# now kill init
#
kill -1 1
/usr/sbin/chown uucp:dialer $DEVICE

cat > /tmp/$$ << __EOF__
#!/bin/sh
sleep 60

while [ -f $LOCKFILE ]
do
	sleep 8
done

cat /etc/ttys | sed -e "/^$LINE/s/off /on /" > /tmp/ttytmp
mv -f /tmp/ttytmp /etc/ttys

kill -1 1

rm /tmp/$$
__EOF__

chmod 700 /tmp/$$
rm -f $LOCKFILE
exec /tmp/$$ &

------------------------------------------------------------------------------