Listing 1 Shell script to switch between Solaris OS versions
mysys 5.10# more /usr/local/sbin/swithsol
#! /bin/ksh
# Determine which version of Solaris is currently booted and set
# variables for the version we are switching to.
currver=`uname -r`
if [[ $currver = "5.8" ]]; then
tover=10
tover_root_slice="c0t0d0s4"
else
tover=8
tover_root_slice="c0t0d0s0"
fi
# List of system files to be copied to "other" Solaris version
rootsysfiles="/etc/passwd /etc/group /etc/shadow /etc/profile \
/usr/local/sbin/switchsol"
print "Do you wish to copy common system files to the"
print -n "Solaris $tover environment? (y/n): "
read ANS
ANS=${ANS:-n}
if [[ $ANS = "y" ]]; then
# Mount root partition of "other" Solaris version
mount | grep root.sol${tover} > /dev/null
if [[ $? != 0 ]]; then
if [[ ! -d /root.sol${tover} ]]; then mkdir /root.sol${tover}; fi
mount /dev/dsk/${tover_root_slice} /root.sol${tover}
fi
# Copy each shared file to "other" Solaris version
for i in $rootsysfiles
do
/bin/cp -p $i /root.sol${tover}${i}
done
fi
# Reboot the system, passing the argument to be used by the OBP 'boot'
# command. This requires that appropriate NVRAM aliases have been
# created ('sol8' and 'sol10').
reboot -- sol${tover}
|