#!/bin/bash
# Purpose : Script to update /etc/issue giving advice on how to configure
#           the appliance
#	Copyright (C) 2004 Networks Associates Technology Inc.
#	All rights reserved.

# Pull in the config
if [ -f $NETAWSS/.profile.vars ]; then 
 . $NETAWSS/.profile.vars 
else 
 . /var/NAIENV/.profile.vars 
fi 

shopt -s extglob
shopt -s nullglob

HEADING="To configure this appliance, connect a Web Browser to the following addresses:"

# Generate the standard linux /etc/issue file
if /bin/grep -q "${HEADING}" /etc/issue
then
    /bin/cp /etc/issue.org /etc/issue 
else
    /bin/cp /etc/issue /etc/issue.org
fi

/bin/cat <<-END >>/etc/issue

${HEADING}

END

cfgbase='/etc/sysconfig/network-scripts/ifcfg-'
for f in "$cfgbase"!(lo)
do (
    # check that the network interface exists
    SUBNET=
    . $f
    [[ "${ONBOOT}" == @(NO|no) || $IPADDR == @(|0.0.0.0) ]] && exit
    case ${DEVICE:-${f#$cfgbase}} in
	(eth0*) NIC='Lan 1';;
	(eth1*) NIC='Lan 2';;
	(ibr*) NIC='Any';;
	(*) NIC='some';;
    esac
    [[ -z $NETMASK ]] && eval $(ipcalc --netmask $IPADDR)
    case $NETMASK in
	(255.255.255.0) SUBNET="using a class C subnet";;
	(255.255.0.0) SUBNET="using a class B subnet";;
	(255.0.0.0) SUBNET="using a class A subnet";;
	(*) SUBNET="using netmask $NETMASK";;
    esac
    /bin/echo "     https://${IPADDR} on ${NIC} Interface ${SUBNET}" >> /etc/issue
)
done

/bin/echo >> /etc/issue
