#!/bin/sh
#
# sioan-'96 pvs leme athens'04
# updated by dtzoumpa

HOSTNAME=`/bin/hostname`
LOGINMSG="$HOSTNAME login: "
LOGINPROG="/usr/local/bin/tlogin"
TERM="vt100"
PORT="a"
BPS=38400
TTYSPEED="modem"

if [ `whoami` != "root" ] ; then
 echo "You must be root"
 exit
fi

echo ""
echo "Found following entry for modems in /etc/ttydefs:"
grep modem /etc/ttydefs
echo""
/bin/echo  "Re-add a modem entry in /etc/ttydefs ? (y/N)\c"
read a
if [ "$a" = "y" ] ; then
 cat >>/etc/ttydefs <<EOT
# Spiros: for modem access
modem:$BPS -parity opost onlcr:$BPS sane -parity crtscts hupcl::modem
EOT
fi

echo "Found following entry for modem in /etc/remote:"
grep modem /etc/remote|grep -v PCMCIA
echo""
/bin/echo  "Re-add a modem entry in /etc/remote ? (y/N)\c"
read a
if [ "$a" = "y" ] ; then
cat >>/etc/remote <<EOT
modem:dv=/dev/cua/a:br#$BPS
EOT
fi

echo "sacadm -l reports:"
sacadm -l
echo""
/bin/echo  "start zsmon? (choose y if status reports FAILED )(y/N)\c"
read a
if [ "$a" = "y" ] ; then
sacadm -s -p zsmon
fi

chown root /dev/term/$PORT; chgrp tty /dev/term/$PORT
chown uucp /dev/cua/$PORT; chgrp tty /dev/cua/$PORT

# Remove any existing port monitor on this port.
/usr/sbin/pmadm -r -p zsmon -s tty$PORT

# Create the new port monitor
/usr/sbin/pmadm -a -p zsmon -s tty$PORT -i root \
-v `/usr/sbin/ttyadm -V` -fu -m "`/usr/sbin/ttyadm \
-p "$LOGINMSG" -d /dev/term/$PORT -s "$LOGINPROG" -l $TTYSPEED -T $TERM -b \
-h -S n -m ldterm,ttcompat`" -y "dial in/out on serial port"

echo "Fixing eeprom.."
eeprom ttya-rts-dtr-off=true
eeprom ttya-ignore-cd=true
eeprom ttya-mode=$BPS,8,n,1,h
echo ""
echo "Changing ownership of /dev/cua/$PORT for tip to work"
chown uucp /dev/cua/$PORT
echo "Changing ownership of /usr/bin/tip "
chgrp staff /usr/bin/tip
chmod o-x /usr/bin/tip
echo ""
echo "Done."
