#! /bin/sh
#  Copyright (c) 1993 by Sun Microsystems, Inc.
#
#	@(#)posix_state_setup.sh	1.1	93/10/22 (c) Sun Microsystems, Inc.
#
#  posix.state.setup - This root shell script will set the system
#              environment to be in a POSIX conformance state.
#              The script will create a new /etc/saf/zsmon/_pmtab
#              and /kernel/drv/options.conf file with the correct
#              software default settings of the ttya and ttyb ports
#              for POSIX conformance. 
#
#              This script should be executed before any runs
#              of the POSIX conformance test suite PCTS FIPS 151-2.
#                
#
# 
# Verify if the script has already been 
# previously executed
#
if [  -f  /etc/saf/zsmon/_pmtab.save ] && [ -f  /kernel/drv/options.conf.save ]
    then
ANS="n"
     echo "The posix.state.setup script has already been executed."
     echo "Do you wish to restore your _pmtab and options.conf files: (y/n): \c"
     read ANS
     if [ "$ANS" = y ]
        then
          mv /etc/saf/zsmon/_pmtab.save /etc/saf/zsmon/_pmtab
          mv /kernel/drv/options.conf.save /kernel/drv/options.conf
          echo "Reboot the system to reset the environment back to original state" 
          exit 0
     else
          exit 0
     fi
elif  [ ! -f  /etc/saf/zsmon/_pmtab.save ] && [ ! -f  /kernel/drv/options.conf.save ]
    then
ANS="n"
     echo "The posix.state.setup script will set the ttya and ttyb ports"
     echo "into a POSIX conforming mode by first saving off"
     echo "/etc/saf/zsmon/_pmtab into /etc/saf/zsmon/_pmtab.save"
     echo "/kernel/drv/options.conf into /kernel/drv/options.conf.save"
     echo "A new _pmtab and options.conf file will be installed"
     echo "Do you wish to proceed with installation: (y/n): \c"
     read ANS
     if [ "$ANS" = n ]
        then
          exit 0
     fi
fi
#
# Save the current _pmtab file before
# creating the POSIX conformance one.
#
mv /etc/saf/zsmon/_pmtab /etc/saf/zsmon/_pmtab.save 
cat - << END_OF_PMTAB > /etc/saf/zsmon/_pmtab
# VERSION=1
ttya:u:root:reserved:reserved:reserved:/dev/term/a:I::/usr/bin/login::9600:ldterm,ttcompat:ttya login\: ::tvi925:n:# 
ttyb:u:root:reserved:reserved:reserved:/dev/term/b:I::/usr/bin/login::9600:ldterm,ttcompat:ttyb login\: ::tvi925:n:# 
END_OF_PMTAB
#
# Save the current options.conf file before
# creating the POSIX conformance one.
#
mv /kernel/drv/options.conf /kernel/drv/options.conf.save
cat - << END_OF_CONF > /kernel/drv/options.conf
#
# Copyright (c) 1992, by Sun Microsystems, Inc.
#
#ident	"@(#)options.conf	1.4	92/07/21 SMI"
#
# The property "ttymodes" defines the default termios modes
#  (upon driver open) for ttys.
#
# ttymodes=<string>
#
# The format of <string> is the same format as the output of
# the "-g" option to /usr/bin/stty.  Some standard termios modes
# have been included for reference:
#
# For SVID compliance, use these modes,
#     "522:1805:4b7:2b:7f:1c:23:40:4:0:0:0:11:13:1a:19:12:f:17:16"
#
# For SunOS 4.x defaults (7-bit/evenp/istrip), use these modes,
#     "2522:1805:1ad:8a3b:3:1c:7f:15:4:0:0:0:11:13:1a:19:12:f:17:16"
#
# For SunOS 4.x defaults that are 8-bit clean for
# internationalization, use these modes,
#     "2502:1805:bd:8a3b:3:1c:7f:15:4:0:0:0:11:13:1a:19:12:f:17:16"
#

name="options" class="root"
ttymodes="2502:1805:cbd:8a3b:3:1c:7f:15:4:0:0:0:11:13:1a:19:12:f:17:16";
END_OF_CONF
#
echo "Reboot the system to reset the environment into a POSIX conformance mode" 
#
