- 论坛徽章:
- 0
|
#!/bin/sh
#
# Script to set up numerous "EIS Standard actions" on SUN servers.
#
# Latest modification: 27-OCT-07
# 17-May-07 BDP amendments to all pre first boot patching (ALTROOT)
#
SFSLIST="
SUNWsan
SUNWcfpl
SUNWcfplx
SUNWfchba
SUNWcfclr
SUNWfchbr
SUNWfchbx
SUNWfcsm
SUNWfcsmx
SUNWcfcl
SUNWcfclx
SUNWmdiu"
BASE=""
if [ ! -f ../.release ]
then
echo ""
echo "You are not running this script from .../sun/install - aborting!"
echo ""
exit 1
fi
if [ ! -f profile-root ]
then
echo ""
echo "Please change directory to .../sun/install & try again"
echo ""
exit 1
fi
Usage()
{
echo "usage: setup-standard.sh [-q] [-nosfk]"
echo " [-act] - Skip over installation of ACT."
echo " [-exp] - Skip over installation of explorer."
echo " [-sneep] - Skip over installation of sneep."
echo " [-init] - Exit after initialisation (change no settings)."
echo " [-keeppm] - Do not change anything around power management."
echo " [-q] - Quiet option - asks no questions & skips ACT & explorer."
echo " Always installs SAN Foundation Suite unless -nosfk used."
echo " [-nosfk] - Do NOT install of SAN Foundation Suite."
}
#
# Sub-Script to ask if option required or not
# Return 0 = no; 1 = yes; 2 = ENABLE; 3 = CHANGE
#
yesno()
{
#echo "QUIET is $QUIET"
if [ $QUIET = "NO" ]
then
while .
do
echo ""
echo $1
read reply
case $reply
in
C) return 3;;
E) return 2;;
y) return 1;;
n) return 0;;
*) echo "Invalid response, please try again" ;;
esac
done
echo "ANSWER = $answer"
else
return 1
fi
}
#
# Sub-Script to display banner if JASS package is installed.
#
isjassinstalled()
{
$PKGINFO -q SUNWjass
if [ $? = 0 ]
then
echo ""
echo " *************************************************************"
echo " * Package SUNWjass is installed. Be prepared to audit your *"
echo " * JASS settings after patching and possibly re-apply JASS. *"
echo " * *"
echo " * Refer to the SST 4.2 Administration Guide, Chapter 2, *"
echo " * pp. 32-33, \"Maintaining System Security\" *"
echo " *************************************************************"
echo ""
fi
}
#
# If possible, get serial number from explorer, otherwise get from eeprom or elsewhere.
# Use sneep to put that serial into eeprom, explorer, etc.
#
sneep_explorer_serial()
{
HAVE_SNEEP=${HAVE_SNEEP:-false} # default HAVE_SNEEP if not set already
${HAVE_SNEEP} || return 1
expserial=`${SNEEP} -P explorer `
if test "${expserial}" != unknown ; then
# trust the updated explorer defaults file, update eeprom
${SNEEP} -s "${expserial}" # update serial from explorer
else
# if we have some other serial data, update the explorer serial
otherserial=`${SNEEP}`
if test "${otherserial}" != unknown ; then
# update explorer serial from wherever we can get it
${SNEEP} -s "${otherserial}"
fi
fi
return 0
}
#
# Initialisation
#
TEMP=/tmp/EIS-$$
INIT="NO"
QUIET="NO"
KEEPPM=${KEEPM:-"NO"}
ACT="YES"
STAG="YES"
EXP="YES"
NC3="YES"
ADDSFK="YES"
ADDSNEEP="YES"
PKGRM="pkgrm"
PKGADD="pkgadd"
PKGINFO="pkginfo"
ALTROOT=""
ZONE="NO"
#
# Analyse parameters
#
#echo "all ARGS=$*"
while [ X$1 != "X" ]
do
case $1 in
-act) ACT='NO';;
-exp) EXP='NO';;
-nc) NC3='NO';;
-sneep | -sne) ADDSNEEP='NO' ;;
-init) INIT='YES';;
-keeppm) KEEPPM='YES';;
-nosfk) ADDSFK='NO';;
-nosfs) ADDSFK='NO';;
-q) QUIET='YES'; ACT='NO'; EXP='NO'
echo "Quiet mode selected";;
-R) BASE=$2
if [ "X${BASE}" = "X" ]
then
echo ""
echo "Option -R requires parameter: Client_Root_Path"
echo ""
Usage; exit 2
fi
if [ ! -d ${BASE} ]
then
echo ""
echo "Client_Root_Path \"${BASE}\" does not exist!"
echo ""
Usage; exit 2
fi
PKGRM="pkgrm -R ${BASE}"
PKGADD="pkgadd -R ${BASE}"
PKGINFO="pkginfo -R ${BASE}"
ALTROOT="-R ${BASE}"
shift;;
-*) Usage; exit 2;;
*) ;;
esac
shift
done
#
# Prepare file for silent package removal
#
sed 's/action=ask/action=nocheck/' ${BASE}/var/sadm/install/admin/default > /tmp/noask
echo ""
echo "Running setup-standard with EIS-DVD Vn `head -1 ../.release`"
echo "================================================"
echo ""
isjassinstalled
#
# Special Actions if on Intel Platform
#
LOCALBIN="local-bin"
CTEACT="CTEact"
if [ `uname -p` = i386 ]
then
LOCALBIN="local-bin_x86"
CTEACT="CTEactx"
ADDSFK='NO'
NC3='NO'
echo ""
fi
if $LOCALBIN/aged ../.release 50
then
echo ""
echo "******************************************************"
echo "* You are using a EIS-DVD that is > 50 days old! *"
echo "* Please ensure that you use the most recent version *"
echo "******************************************************"
echo ""
fi
#
# Special Actions if in non-local zone
#
if [ -f /usr/bin/zonename ]
then
if [ `zonename` != "global" ]
then
ZONE="non-global"
echo ""
echo "Non-Global zone detected."
echo ""
fi
fi
#
# Determine if this is a starcat System Controller - from D.C.
#
is_15k_sc="true"
dev_count=`prtconf -p | grep -c \'gchip\'`
if [ "${dev_count}" -eq 0 ] ; then
is_15k_sc="false"
fi
dev_count=`prtconf -p | grep -c \'echip\'`
if [ "${dev_count}" -eq 0 ] ; then
is_15k_sc="false"
fi
dev_count=`prtconf -p | grep -c \'consbus\'`
if [ "${dev_count}" -eq 0 ] ; then
is_15k_sc="false"
fi
#
# Determine root's HOME directory
#
if [ ! -f ${BASE}/etc/passwd ]
then
echo ""
echo "Cannot find ${BASE}/etc/passwd - bailing out!"
exit 1
fi
ROOTHOME=${BASE}/`grep "^root:" /${BASE}/etc/passwd | awk -F: '{print $6}'`
if [ ! -d $ROOTHOME ]
then
echo ""
echo "Cannot find root's HOME directory ($ROOTHOME) - bailing out!"
exit 1
fi
if [ "$ROOTHOME" = "/" ]
then
ROOTHOME=""
fi
#
# Create /var/sun and save initial information
# Dont do prtvotc if disk already under SDS.
#
if [ ! -d ${BASE}/var/sun/install-ORIG ]
then
echo "Creating ${BASE}/var/sun for scripts, log files etc..."
mkdir -p ${BASE}/var/sun/install-ORIG
if [ $ZONE != "non-global" ]
then
cp -p ${BASE}/etc/system ${BASE}/etc/system-INSTALL
cp -p ${BASE}/etc/system ${BASE}/var/sun/install-ORIG
cp -p ${BASE}/etc/path_to_inst ${BASE}/etc/path_to_inst-INSTALL
cp -p ${BASE}/etc/path_to_inst ${BASE}/var/sun/install-ORIG
fi
cp -p ${BASE}/etc/vfstab ${BASE}/etc/vfstab-INSTALL
cp -p ${BASE}/etc/vfstab ${BASE}/var/sun/install-ORIG
DISK=`df -k | head -2 | tail -1 | awk '{ print $1 }'`
echo $DISK | grep md > /dev/null 2>&1
if [ $? = 1 -a $ZONE != "non-global" ]
then
prtvtoc $DISK > ${BASE}/var/sun/install-ORIG/prtvtoc-systemdisk-INSTALL
fi
/usr/bin/showrev -p > ${BASE}/var/sun/install-ORIG/showrev-p.out
fi
#
# Create log file & make initial entry.
#
if [ -f ${BASE}/var/sun/GOLD-CD.log ]
then
if [ -f ${BASE}/var/sun/EIS-CD.log ]
then
echo ""
echo "INFO: In ${BASE}/var/sun both GOLD-CD.log and EIS-CD.log exist!!!!"
echo " Please merge into EIS-CD.log & remove GOLD-CD.log"
echo ""
else
echo ""
echo "INFO: Renaming ${BASE}/var/sun/GOLD-CD.log to EIS-CD.log"
echo ""
mv ${BASE}/var/sun/GOLD-CD.log ${BASE}/var/sun/EIS-CD.log
fi
fi
echo "`date`: Ran setup-standard with EIS-DVD Vn `head -1 ../.release`" >>${BASE}/var/sun/EIS-CD.log
rm -f ${BASE}/var/sun/.release-GOLD-CD
cp -p ../.release ${BASE}/var/sun/.release-EIS-CD
#
# Copy scripts etc across to /opt/sun/bin
#
if [ ! -d ${BASE}/opt/sun ]
then
mkdir -p ${BASE}/opt/sun
fi
echo "Loading /opt/sun/bin..."
tar cf - bin | (cd ${BASE}/opt/sun; tar xBpf -)
for file in gzcat gunzip unzip
do
if [ ! -f ${BASE}/usr/bin/${file} -a ! -f ${BASE}/opt/sun/bin/${file} ]
then
echo "${BASE}/usr/bin/${file} not found - copying ${file} from EIS-DVD into ${BASE}/opt/sun/bin"
cp -p $LOCALBIN/${file} ${BASE}/opt/sun/bin
fi
done
# Just in case someone uses SCCS on this file, protect the date format string
# from %-keyword expansion by converting @ to % at runtime
datefmt=`echo +@Y@m@d | tr @ % `
#
# Set up PROFILEs for user ROOT
#
NEWPROFILE="NO"
NEWEISPROFILE="NO"
if [ ! -f ${ROOTHOME}/.profile ]
then
echo "Setting up ${ROOTHOME}/.profile..."
cp -p profile-root ${ROOTHOME}/.profile
cp -p profile-EIS ${ROOTHOME}/.profile-EIS
echo "`date`: Installed new .profile & .profile-EIS" >>${BASE}/var/sun/EIS-CD.log
NEWPROFILE="YES"
NEWEISPROFILE="YES"
else
if [ ! -f ${ROOTHOME}/.profile-EIS ]
then
echo "Setting up ${ROOTHOME}/.profile-EIS..."
cp -p profile-EIS ${ROOTHOME}/.profile-EIS
echo "`date`: Installed new .profile-EIS" >>${BASE}/var/sun/EIS-CD.log
NEWEISPROFILE="YES"
else
diff profile-EIS ${ROOTHOME}/.profile-EIS > /dev/null 2>&1
if [ $? != 0 ]
then
cp -p ${ROOTHOME}/.profile-EIS ${BASE}/var/sun/.profile-EIS-`date \
${datefmt}`
echo "Setting up new ${ROOTHOME}/.profile-EIS..."
cp -p profile-EIS ${ROOTHOME}/.profile-EIS
echo "`date`: Updated .profile-EIS" >>${BASE}/var/sun/EIS-CD.log
NEWEISPROFILE="YES"
fi
fi
fi
#
# Search ROOT's PROFILE for sourcing of EIS profile
#
SOURCED="YES"
grep '^ . $HOME/.profile-EIS' ${ROOTHOME}/.profile > /dev/null 2>&1
if [ $? = 1 ]
then
echo ""
echo "BEWARE: ${ROOTHOME}/.profile does NOT source ${ROOTHOME}/.profile-EIS"
echo "PLEASE: examine why this is not sourced!"
SOURCED="NO"
echo ""
sleep 4
fi
#
# Bail out if init flag was set
#
if [ $INIT = "YES" ]
then
echo ""
echo "INIT-mode: terminating after initialisation."
echo "`date`: Exited setup-standard after initialisation" >>${BASE}/var/sun/EIS-CD.log
exit 0
fi
#
# Power Saving Daemon - correct possible old format
#
if [ -f ${BASE}/etc/rc2.d/noS85power ]
then
mv ${BASE}/etc/rc2.d/noS85power ${BASE}/etc/rc2.d/S85power
grep "^autoshutdown.*noshutdown" ${BASE}/etc/power.conf >/dev/null
if [ $? = 1 ]
then
echo ""
echo "Changing power saving daemon disabling to correct method!..."
cp -p ${BASE}/etc/power.conf ${BASE}/etc/power.conf.fcs
rm -f ${BASE}/etc/power.conf
# We change the FIFTH parameter in the line beginning on
# "autoshutdown" from whatever to "noshutdown";
cat ${BASE}/etc/power.conf.fcs \
| nawk '{
if ( $1 == "autoshutdown" ) {
# all this effort is to keep the line format (all tabs etc.)...
line=$0 ;
fifth=$5 ;
rest=substr(line,13,length(line)-12) ; # everything except "autoshutdown"
i=index(rest,fifth); # fifth word starts here
printf("%s%s%s\n",$1,substr(rest,1,i-1),"noshutdown") ;
}
else { print $0 }
}' > ${BASE}/etc/power.conf
chown root:root ${BASE}/etc/power.conf
chmod 664 ${BASE}/etc/power.conf
/usr/bin/diff ${BASE}/etc/power.conf ${BASE}/etc/power.conf.fcs > /dev/null
if [ $? = 1 ]
then
echo "${BASE}/etc/power.conf has been modified."
else
echo "UNABLE TO CHANGE ${BASE}/etc/power.conf !"
fi
fi
fi
#
# Power Saving Daemon - Disable first time
#
if [ $KEEPPM = "YES" ]
then
echo "KEEPPM-mode: Power Management settings will not be touched."
echo ""
else
if [ -f ${BASE}/etc/power.conf ]
then
grep "noshutdown" ${BASE}/etc/power.conf >/dev/null
if [ $? = 1 ]
then
yesno "Is the power saving daemon to be disabled? [y/n]: \c"
if [ $? = 1 ]
then
cp -p ${BASE}/etc/power.conf ${BASE}/etc/power.conf.fcs
rm -f ${BASE}/etc/power.conf
cat ${BASE}/etc/power.conf.fcs \
| nawk '{
if ( $1 == "autoshutdown" ) {
# all this effort is to keep the line format (all tabs etc.)...
line=$0 ;
fifth=$5;
rest=substr(line,13,length(line)-12) ;
i=index(rest,fifth);
printf("%s%s%s\n",$1,substr(rest,1,i-1),"noshutdown") ;
}
else { print $0 }
}' > ${BASE}/etc/power.conf
chown root:root ${BASE}/etc/power.conf
chmod 664 ${BASE}/etc/power.conf
/usr/bin/diff ${BASE}/etc/power.conf ${BASE}/etc/power.conf.fcs > /dev/null
if [ $? = 1 ]
then
echo "${BASE}/etc/power.conf has been modified."
echo "`date`: Disabled power saving daemon" >>${BASE}/var/sun/EIS-CD.log
else
echo 'UNABLE TO CHANGE ${BASE}/etc/power.conf !'
echo "`date`: UNABLE TO disable power saving daemon" >>${BASE}/var/sun/EIS-CD.log
fi
fi
else
echo ""
echo "The power daemon start-up has probably already been disabled...."
fi
else
echo ""
echo "File ${BASE}/etc/power.conf is not present...."
echo "Probably power management is not installed - no problem!"
fi
.................... |
|