Home | History | Annotate | Download | only in scripts
      1 #!/bin/ksh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 
     23 #
     24 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 # Upgrade a machine from a cpio archive area in about 5 minutes.
     28 # By Roger Faulkner and Jeff Bonwick, April 1993.
     29 # (bfu == Bonwick/Faulkner Upgrade, a.k.a. Blindingly Fast Upgrade)
     30 #
     31 # Usage: bfu    [-f] <archive_dir> [root-dir]	# for normal machines
     32 #        bfu -c [-f] <archive_dir> <exec-dir>	# for diskless clients
     33 #
     34 # The -f flag is to override the built-in safety check which requires
     35 # that the starting-point OS be a least a certain revision.
     36 #
     37 # You have to be super-user.  It's safest to run this from the
     38 # system console, although I've run it under OW and even via
     39 # remote login with no problems.
     40 #
     41 # You will have to reboot the system when the upgrade is complete.
     42 #
     43 # You should add any administrative files you care about to this list.
     44 # Warning: there had better be no leading '/' on any of these filenames.
     45 
     46 #
     47 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
     48 # under certain circumstances, which can really screw things up; unset it.
     49 #
     50 unset CDPATH
     51 
     52 export LC_ALL="C"
     53 
     54 if [ -z "$GATEPATH" ]; then
     55 	GATEPATH=/ws/onnv-gate
     56 	test -d $GATEPATH || GATEPATH=/net/onnv.eng/export/onnv-gate
     57 fi
     58 export GATE=${GATEPATH}
     59 export ARCHIVE=${ARCHIVEPATH:-${GATEPATH}}
     60 
     61 #
     62 # NOTE:	Entries in *_files must expand to either the exact files required,
     63 #	or to directories that will be scoured for files.  Any directories
     64 #	(and subdirectories) resulting from a wildcard expansion will be
     65 #	fully recursed by BFU's searching for files.  (E.g. /etc/inet/* will
     66 #	include all files in any of its directories, as well as any files in
     67 #	/etc/inet/ itself.
     68 #
     69 #	These lists should really be generated automatically from the
     70 #	pkgmap(4) metadata.
     71 #
     72 
     73 #
     74 # First list: files to be saved in global and non-global zones.
     75 #
     76 all_zones_files="
     77 	etc/.login
     78 	etc/acct/holidays
     79 	etc/auto_*
     80 	etc/cron.d/at.deny
     81 	etc/cron.d/cron.deny
     82 	etc/crypto/pkcs11.conf
     83 	etc/default/*
     84 	etc/dev/reserved_devnames
     85 	etc/dfs/dfstab
     86 	etc/dumpdates
     87 	etc/ftpd/*
     88 	etc/ftpusers
     89 	etc/group
     90 	etc/gss/gsscred.conf
     91 	etc/gss/mech
     92 	etc/gss/qop
     93 	etc/inet/*
     94 	etc/init.d/*
     95 	etc/inittab
     96 	etc/ipf/ipf.conf
     97 	etc/iu.ap
     98 	etc/krb5/kadm5.acl
     99 	etc/krb5/kdc.conf
    100 	etc/krb5/kpropd.acl
    101 	etc/krb5/krb5.conf
    102 	etc/krb5/warn.conf
    103 	etc/ksh.kshrc
    104 	etc/logadm.conf
    105 	etc/logindevperm
    106 	etc/lp/Systems
    107 	etc/mail/*.cf
    108 	etc/mail/*.hf
    109 	etc/mail/*.rc
    110 	etc/mail/aliases
    111 	etc/mail/helpfile
    112 	etc/mail/local-host-names
    113 	etc/mail/trusted-users
    114 	etc/named.conf
    115 	etc/net/*/services
    116 	etc/netconfig
    117 	etc/nfs/nfslog.conf
    118 	etc/nfssec.conf
    119 	etc/nscd.conf
    120 	etc/nsswitch.*
    121 	etc/pam.conf
    122 	etc/passwd
    123 	etc/policy.conf
    124 	etc/printers.conf
    125 	etc/profile
    126 	etc/project
    127 	etc/publickey
    128 	etc/remote
    129 	etc/resolv.conf
    130 	etc/rmmount.conf
    131 	etc/rpc
    132 	etc/rpld.conf
    133 	etc/saf/_sactab
    134 	etc/saf/_sysconfig
    135 	etc/saf/zsmon/_pmtab
    136 	etc/security/audit_class
    137 	etc/security/audit_control
    138 	etc/security/audit_event
    139 	etc/security/audit_startup
    140 	etc/security/audit_user
    141 	etc/security/audit_warn
    142 	etc/security/auth_attr
    143 	etc/security/crypt.conf
    144 	etc/security/exec_attr
    145 	etc/security/policy.conf
    146 	etc/security/prof_attr
    147 	etc/sfw/openssl/openssl.cnf
    148 	etc/shadow
    149 	etc/skel/.profile
    150 	etc/skel/local.*
    151 	etc/smartcard/.keys
    152 	etc/smartcard/desktop.properties
    153 	etc/smartcard/ocf.classpath
    154 	etc/smartcard/opencard.properties
    155 	etc/ssh/ssh_config
    156 	etc/ssh/sshd_config
    157 	etc/syslog.conf
    158 	etc/ttydefs
    159 	etc/ttysrch
    160 	etc/user_attr
    161 	etc/uucp/[A-Z]*
    162 	etc/vfstab
    163 	var/smb/*
    164 	var/spool/cron/crontabs/*
    165 	var/yp/Makefile
    166 	var/yp/aliases
    167 	var/yp/nicknames
    168 "
    169 
    170 #
    171 # Second list: files to be saved in the global zone only.
    172 #
    173 global_zone_only_files="
    174 	boot/grub/menu.lst
    175 	boot/solaris/bootenv.rc
    176 	boot/solaris/devicedb/master
    177 	boot/solaris/filelist.ramdisk
    178 	etc/aggregation.conf
    179 	etc/dladm/*
    180 	etc/bootrc
    181 	etc/crypto/kcf.conf
    182 	etc/devlink.tab
    183 	etc/driver_aliases
    184 	etc/driver_classes
    185 	etc/lvm/devpath
    186 	etc/lvm/lock
    187 	etc/lvm/md.cf
    188 	etc/lvm/md.ctlrmap
    189 	etc/lvm/md.tab
    190 	etc/lvm/mddb.cf
    191 	etc/lvm/runtime.cf
    192 	etc/mach
    193 	etc/minor_perm
    194 	etc/name_to_major
    195 	etc/name_to_sysnum
    196 	etc/nca/nca.if
    197 	etc/nca/ncakmod.conf
    198 	etc/nca/ncalogd.conf
    199 	etc/nca/ncaport.conf
    200 	etc/openwin/server/etc/OWconfig
    201 	etc/path_to_inst
    202 	etc/power.conf
    203 	etc/ppp/chap-secrets
    204 	etc/ppp/options
    205 	etc/ppp/pap-secrets
    206 	etc/security/device_policy
    207 	etc/security/extra_privs
    208 	etc/security/tsol/tnrhdb
    209 	etc/security/tsol/tnrhtp
    210 	etc/security/tsol/tnzonecfg
    211 	etc/security/tsol/label_encodings
    212 	etc/security/tsol/relabel
    213 	etc/security/tsol/devalloc_defaults
    214 	etc/system
    215 	etc/zones/index
    216 	kernel/drv/aac.conf
    217 	kernel/drv/elxl.conf
    218 	kernel/drv/md.conf
    219 	kernel/drv/options.conf
    220 	kernel/drv/ra.conf
    221 	kernel/drv/scsa2usb.conf
    222 	kernel/drv/scsi_vhci.conf
    223 	kernel/drv/sd.conf
    224 	kernel/drv/mpt.conf
    225 	platform/*/kernel/drv/*ppm.conf
    226 	platform/i86pc/kernel/drv/aha.conf
    227 	platform/i86pc/kernel/drv/asy.conf
    228 	platform/sun4u/boot.conf
    229 "
    230 
    231 #
    232 # Third list: files extracted from generic.root but which belong in the global
    233 # zone only: they are superfluous (and some even harmful) in nonglobal zones.
    234 #
    235 # (note: as /etc/init.d scripts are converted to smf(5) "Greenline" services,
    236 # they (and their /etc/rc?.d hardlinks) should be removed from this list when
    237 # they are added to smf_obsolete_rc_files, below)
    238 #
    239 superfluous_nonglobal_zone_files="
    240 	dev/dsk
    241 	dev/fd
    242 	dev/pts
    243 	dev/rdsk
    244 	dev/rmt
    245 	dev/stderr
    246 	dev/stdin
    247 	dev/stdout
    248 	dev/swap
    249 	dev/term
    250 	dev/vt
    251 	devices
    252 	etc/dacf.conf
    253 	etc/dat
    254 	etc/default/metassist.xml
    255 	etc/default/power
    256 	etc/flash/postdeployment/svm.cleanup
    257 	etc/flash/predeployment/svm.save
    258 	etc/inet/ipqosconf.1.sample
    259 	etc/inet/ipqosconf.2.sample
    260 	etc/inet/ipqosconf.3.sample
    261 	etc/inet/sock2path
    262 	etc/init.d/devlinks
    263 	etc/init.d/dodatadm.udaplt
    264 	etc/init.d/drvconfig
    265 	etc/init.d/llc2
    266 	etc/init.d/ncakmod
    267 	etc/init.d/ncalogd
    268 	etc/init.d/pcmcia
    269 	etc/init.d/pppd
    270 	etc/init.d/wrsmcfg
    271 	etc/llc2
    272 	etc/lvm
    273 	etc/nca
    274 	etc/openwin
    275 	etc/ppp
    276 	etc/rc0.d/K34ncalogd
    277 	etc/rc0.d/K50pppd
    278 	etc/rc0.d/K52llc2
    279 	etc/rc1.d/K34ncalogd
    280 	etc/rc1.d/K50pppd
    281 	etc/rc1.d/K52llc2
    282 	etc/rc2.d/S40llc2
    283 	etc/rc2.d/S42ncakmod
    284 	etc/rc2.d/S47pppd
    285 	etc/rc2.d/S81dodatadm.udaplt
    286 	etc/rc2.d/S94ncalogd
    287 	etc/rcS.d/K34ncalogd
    288 	etc/rcS.d/K44wrsmcfg
    289 	etc/rcS.d/K50pppd
    290 	etc/rcS.d/K52llc2
    291 	etc/rcS.d/S29wrsmcfg
    292 	etc/rcm
    293 	etc/sock2path
    294 	etc/usb
    295 	etc/wrsm
    296 	etc/zones
    297 	kernel
    298 	lib/libmeta.so
    299 	lib/libmeta.so.1
    300 	lib/svc/method/sf880dr
    301 	lib/svc/method/svc-cvcd
    302 	lib/svc/method/svc-dcs
    303 	lib/svc/method/svc-drd
    304 	lib/svc/method/svc-dscp
    305 	lib/svc/method/svc-dumpadm
    306 	lib/svc/method/svc-intrd
    307 	lib/svc/method/svc-hal
    308 	lib/svc/method/svc-labeld
    309 	lib/svc/method/svc-mdmonitor
    310 	lib/svc/method/svc-metainit
    311 	lib/svc/method/svc-metasync
    312 	lib/svc/method/svc-oplhpd
    313 	lib/svc/method/svc-poold
    314 	lib/svc/method/svc-pools
    315 	lib/svc/method/svc-power
    316 	lib/svc/method/svc-resource-mgmt
    317 	lib/svc/method/svc-rmvolmgr
    318 	lib/svc/method/svc-scheduler
    319 	lib/svc/method/svc-sckmd
    320 	lib/svc/method/svc-syseventd
    321 	lib/svc/method/svc-tnctl
    322 	lib/svc/method/svc-tnd
    323 	lib/svc/method/svc-vntsd
    324 	lib/svc/method/svc-zones
    325 	lib/svc/method/vtdaemon
    326 	platform/*/kernel
    327 	platform/SUNW,Sun-Fire-15000/lib/cvcd
    328 	platform/SUNW,Ultra-Enterprise-10000/lib/cvcd
    329 	platform/i86pc/biosint
    330 	platform/i86pc/multiboot
    331 	platform/sun4u/cprboot
    332 	platform/sun4u/lib/libwrsmconf.so
    333 	platform/sun4u/lib/libwrsmconf.so.1
    334 	platform/sun4u/lib/sparcv9/libwrsmconf.so
    335 	platform/sun4u/lib/sparcv9/libwrsmconf.so.1
    336 	platform/sun4u/sbin
    337 	platform/sun4u/wanboot
    338 	platform/sun4v/wanboot
    339 	sbin/metadb
    340 	sbin/metadevadm
    341 	sbin/metainit
    342 	sbin/metarecover
    343 	sbin/metastat
    344 	usr/include/sys/dcam
    345 	usr/lib/devfsadm/linkmod/SUNW_dcam1394_link.so
    346 	usr/lib/ldoms
    347 	usr/platform/SUNW,SPARC-Enterprise/lib/dscp.ppp.options
    348 	usr/platform/SUNW,SPARC-Enterprise/lib/libdscp.so
    349 	usr/platform/SUNW,SPARC-Enterprise/lib/libdscp.so.1
    350 	usr/platform/SUNW,SPARC-Enterprise/lib/llib-ldscp.ln
    351 	usr/platform/SUNW,SPARC-Enterprise/sbin/prtdscp
    352 	var/adm/pool
    353 	var/log/pool
    354 	var/svc/manifest/network/rpc/mdcomm.xml
    355 	var/svc/manifest/network/rpc/meta.xml
    356 	var/svc/manifest/network/rpc/metamed.xml
    357 	var/svc/manifest/network/rpc/metamh.xml
    358 	var/svc/manifest/network/tnctl.xml
    359 	var/svc/manifest/network/tnd.xml
    360 	var/svc/manifest/platform/i86pc/eeprom.xml
    361 	var/svc/manifest/platform/sun4u/dcs.xml
    362 	var/svc/manifest/platform/sun4u/dscp.xml
    363 	var/svc/manifest/platform/sun4u/efdaemon.xml
    364 	var/svc/manifest/platform/sun4u/oplhpd.xml
    365 	var/svc/manifest/platform/sun4u/sckmd.xml
    366 	var/svc/manifest/platform/sun4u/sf880drd.xml
    367 	var/svc/manifest/platform/sun4v
    368 	var/svc/manifest/system/cvc.xml
    369 	var/svc/manifest/system/dumpadm.xml
    370 	var/svc/manifest/system/fmd.xml
    371 	var/svc/manifest/system/hal.xml
    372 	var/svc/manifest/system/intrd.xml
    373 	var/svc/manifest/system/labeld.xml
    374 	var/svc/manifest/system/mdmonitor.xml
    375 	var/svc/manifest/system/metainit.xml
    376 	var/svc/manifest/system/metasync.xml
    377 	var/svc/manifest/system/picl.xml
    378 	var/svc/manifest/system/poold.xml
    379 	var/svc/manifest/system/pools.xml
    380 	var/svc/manifest/system/power.xml
    381 	var/svc/manifest/system/resource-mgmt.xml
    382 	var/svc/manifest/system/scheduler.xml
    383 	var/svc/manifest/system/sysevent.xml
    384 	var/svc/manifest/system/vtdaemon.xml
    385 	var/svc/manifest/system/zones.xml
    386 	var/svc/manifest/system/filesystem/rmvolmgr.xml
    387 "
    388 
    389 #
    390 # Fourth list: files to be preserved, ie unconditionally restored to
    391 # "child" versions
    392 #
    393 preserve_files="
    394 	etc/hostid
    395 	kernel/misc/amd64/sysinit
    396 	kernel/misc/amd64/usbs49_fw
    397 	kernel/misc/sparcv9/usbs49_fw
    398 	kernel/misc/sysinit
    399 	kernel/misc/usbs49_fw
    400 	var/adm/aculog
    401 	var/adm/spellhist
    402 	var/adm/utmpx
    403 	var/adm/wtmpx
    404 	var/log/authlog
    405 	var/log/syslog
    406 	var/saf/zsmon/log
    407 "
    408 
    409 realmode_files="
    410 	boot/solaris/bootenv.rc
    411 	boot/solaris/devicedb/master
    412 "
    413 
    414 fail() {
    415 	print "$*" >& 2
    416 	print "bfu aborting" >& 2
    417 	rm -f "$bfu_zone_list"
    418 	exit 1
    419 }
    420 
    421 filelist() {
    422 	files="$all_zones_files $preserve_files"
    423 	if [ $1 = "global" ]; then
    424 		files="$global_zone_only_files $files"
    425 	fi
    426 	find $files -depth -type f ! -name core -print 2>/dev/null | sort -u || {
    427 		#
    428 		# Force cpio to return non-zero by printing an error message
    429 		# to stdout that it won't be able to lstat().
    430 		#
    431 		echo 'filelist: sort failed'
    432 		fail "sort failed"
    433 	}
    434 }
    435 
    436 realmode_filelist() {
    437 	find $realmode_files -depth -type f ! -name core -print 2>/dev/null | sort
    438 }
    439 
    440 smf_inetd_conversions="
    441 	100134
    442 	100150
    443 	100155
    444 	100229
    445 	100230
    446 	100234
    447 	100242
    448 	100422
    449 	chargen
    450 	comsat
    451 	daytime
    452 	discard
    453 	echo
    454 	eklogin
    455 	exec
    456 	finger
    457 	ftp
    458 	gssd
    459 	klogin
    460 	krb5_prop
    461 	kshell
    462 	ktkt_warnd
    463 	login
    464 	metad
    465 	metamedd
    466 	metamhd
    467 	name
    468 	ocfserv
    469 	printer
    470 	rexd
    471 	rquotad
    472 	rstatd
    473 	rusersd
    474 	shell
    475 	smserverd
    476 	sprayd
    477 	sun-dr
    478 	talk
    479 	telnet
    480 	time
    481 	uucp
    482 	walld
    483 "
    484 
    485 enable_next_boot () {
    486 	if [ -x /tmp/bfubin/svccfg ]; then
    487 	    svcadm disable -t $1
    488 	    [ $? = 0 ] || echo "warning: unable to temporarily disable $1"
    489 	    svccfg -s $1 setprop general/enabled = true
    490 	    [ $? = 0 ] || echo "warning: unable to enable $1 for next boot"
    491 	fi
    492 }
    493 
    494 #
    495 # If we're in the global zone, import the manifest for the specified service.
    496 # Note that we will need to see whether we are in an smf root if we are using
    497 # an alternate root. If so, import the service directly; otherwise, print the
    498 # warning messages.
    499 #
    500 # $1: the path of the xml file (the related path to /var/svc/manifest)
    501 # $2: the service name - specified only if the service is enabled after reboot.
    502 #
    503 smf_import_service() {
    504 	if [[ $zone = global && -f $rootprefix/var/svc/manifest/$1 ]]; then
    505 		if [[ -n $rootprefix && -x /usr/sbin/svccfg ]]; then
    506 			SVCCFG_REPOSITORY=$rootprefix/etc/svc/repository.db \
    507 			/usr/sbin/svccfg import $rootprefix/var/svc/manifest/$1
    508 		elif [[ -n $rootprefix ]]; then
    509 			echo "Warning: This system does not have SMF, so I"
    510 			echo "cannot ensure the pre-import of $1. If it does"
    511 			echo "not work, reboot your alternate root to fix it."
    512 		elif [[ -x /tmp/bfubin/svccfg ]]; then
    513 			if [[ "${2}a" == a ]]; then
    514 				/tmp/bfubin/svccfg import /var/svc/manifest/$1
    515 			else
    516 				tmpfile=/tmp/`echo "$1" | tr / :`.$$
    517 				sed -e "s/enabled='true'/enabled='false'/" \
    518 				    /var/svc/manifest/$1 > "$tmpfile"
    519 				/tmp/bfubin/svccfg import "$tmpfile"
    520 				#
    521 				# Make sure the service is enabled after reboot.
    522 				#
    523 				enable_next_boot $2
    524 			fi
    525 		fi
    526 	fi
    527 }
    528 
    529 smf_inetd_disable() {
    530 	inetconf=$rootprefix/etc/inet/inetd.conf
    531 	inettmp=/tmp/inetd.tmp.$$
    532 
    533 	sed "$(for i in $smf_inetd_conversions; do 
    534 		echo "s:^[ 	]*$i[ 	/]:#SMFbfu# &:"
    535 	done)" $inetconf > $inettmp && ! cmp -s $inettmp $inetconf &&
    536 	    cp $inettmp $inetconf
    537 
    538 	rm -f -- $inettmp
    539 }
    540 
    541 smf_inetd_reenable() {
    542 	inetconf=$rootprefix/etc/inet/inetd.conf
    543 	inettmp=/tmp/inetd.tmp.$$
    544 
    545 	sed 's/^#SMFbfu# //' $inetconf > $inettmp && cp $inettmp $inetconf
    546 
    547 	rm -f -- $inettmp
    548 }
    549 
    550 smf_tftp_reinstall() {
    551 	inetconf=$rootprefix/etc/inet/inetd.conf
    552 	inettmp=/tmp/inetd.tmp.$$
    553 
    554 	if grep '^#SMFbfu# tftp' $inetconf >/dev/null ; then
    555 		# BFU previously commented out, put it back in place
    556 	    	sed 's/^#SMFbfu# tftp/tftp/' $inetconf > $inettmp &&
    557 		    cp $inettmp $inetconf
    558 	elif ! grep '^[#	 ]*tftp' $inetconf >/dev/null; then
    559 		# No entry, append to end
    560 		cat >>$inetconf <<EOF
    561 # TFTPD - tftp server (primarily used for booting)
    562 #tftp	dgram	udp6	wait	root	/usr/sbin/in.tftpd	in.tftpd -s /tftpboot
    563 EOF
    564 	fi
    565 
    566 	rm -f -- $inettmp
    567 }
    568 
    569 inetd_conf_svm_hack() {
    570 	# Since inetd.conf is updated by SUNWmdr's postinstall script,
    571 	# we will update the actual inetd.conf here to reflect the postinstall
    572 	# changes.
    573 
    574 	inetconf=$rootprefix/etc/inet/inetd.conf
    575 	inettmp=/tmp/inetd.tmp.$$
    576 	inetnew=/tmp/inetd.new.$$
    577 
    578 	#
    579 	# only change inetd.conf if the rpc.metad entry is out of date
    580 	#
    581 
    582 	if ! grep "^[# 	]*100229/1-2" $inetconf > /dev/null ; then
    583 
    584 		# Grab existing rpc entries for rpc.metad
    585 		# and convert spaces to tabs within the rpc entry, as well as
    586 		# the transport method; 
    587 		# or add a new entry in case there was none.
    588 		if grep "^[# 	]*100229/1" $inetconf > /dev/null ; then
    589 			grep "^# METAD - SLVM metadb" $inetconf > $inettmp
    590 			grep "^[# 	]*100229/1" $inetconf | \
    591 			    sed -e 's/[ 	][ 	]*/	/g' \
    592 				-e 's?100229/1?100229/1-2?' >> $inettmp
    593 		else
    594 			echo '# METAD - SVM metadb Daemon' > $inettmp
    595 			echo "100229/1-2\ttli\trpc/tcp\twait\troot\t/usr/sbin/rpc.metad\trpc.metad" >> $inettmp
    596 		fi
    597 
    598 		grep -v '^# METAD - SLVM metadb' $inetconf | \
    599 		    grep -v '^[# 	]*100229/1' > $inetnew
    600 		cat $inettmp >> $inetnew
    601 
    602 		if ! diff $inetnew $inetconf > /dev/null ; then
    603 			print "Updating inet.conf metad entry ... \c"
    604 			if cp $inetnew $inetconf ; then
    605 				print "done."
    606 			else
    607 				print "failed."
    608 			fi
    609 		fi
    610 		rm -f $inettmp $inetnew
    611 	fi
    612 
    613 	#
    614 	# only change inetd.conf if the rpc.mdcommd entry is out of date
    615 	#
    616 
    617 	if ! grep "^[# 	]*100422/1" $inetconf > /dev/null ; then
    618 
    619 		# Grab existing rpc entries for rpc.mdcommd
    620 		# and convert spaces to tabs within the rpc entry,
    621 		# or add a new entry in case there was none.
    622 		if grep "^[#    ]*100422/1" $inetconf > /dev/null ; then
    623 			grep "^# MDMN_COMMD - SVM Multi node" $inetconf > $inettmp
    624 			grep "^[#       ]*100422/1" $inetconf | \
    625 				sed -e 's/[         ][      ]*/     /g' >> $inettmp 
    626 		else
    627 			echo '# MDMN_COMMD - SVM Multi node communication daemon' >$inettmp
    628 			echo '100422/1\ttli\trpc/tcp\twait\troot\t/usr/sbin/rpc.mdcommd\trpc.mdcommd' >> $inettmp
    629 		fi
    630 
    631 		grep -v '^# MDMN_COMMD - SVM Multi node' $inetconf | \
    632 		grep -v '^[#        ]*100422/1' > $inetnew
    633 		cat $inettmp >> $inetnew
    634 
    635 		if ! diff $inetnew $inetconf > /dev/null ; then
    636 			print "Updating inetd.conf rpc.mdcommd entry ... \c"
    637 			if cp $inetnew $inetconf; then
    638 				print "done."
    639 			else
    640 				print "failed."
    641 			fi
    642 		fi
    643 
    644 		rm -f $inettmp $inetnew
    645 	fi
    646 }
    647 
    648 upgrade_aggr_and_linkprop () {
    649 	# Since aggregation.conf and linkprop.conf are upgraded by
    650 	# SUNWcnetr's postinstall script, put the relevant portions of the
    651 	# postinstall script here, modified to rename the old files instead
    652 	# of removing them.
    653 
    654 	#
    655 	# Convert datalink configuration into a series of dladm(1M) commands
    656 	# and keep them in an upgrade script. This script will then be run
    657 	# in the network-physical service.
    658 	#
    659 	# Note that we cannot use the /var/svc/profile/upgrade script because
    660 	# that script is run in the manifest-import service which is too late
    661 	# for the datalink configuration.
    662 	#
    663 	UPGRADE_SCRIPT=/var/svc/profile/upgrade_datalink
    664 
    665 	AGGR_CONF=/etc/aggregation.conf
    666 	ORIG=$rootprefix$AGGR_CONF
    667 	if [[ ! -f $ORIG ]]; then
    668 		# Try the alternate location.
    669 		AGGR_CONF=/etc/dladm/aggregation.conf
    670 		ORIG=$rootprefix$AGGR_CONF
    671 	fi
    672 
    673 	if [[ -f $ORIG ]]; then
    674 		# Strip off comments, then each remaining line defines
    675 		# an aggregation the administrator configured on the old
    676 		# system.  Each line corresponds to one dladm command
    677 		# that is appended to the upgrade script.
    678 		cat $ORIG | grep '^[^#]' | while read line; do
    679 			echo $line | while read aggr_index rest
    680 			do
    681 				policy=`echo $rest | /usr/bin/awk '{print $1}'`
    682 				nports=`echo $rest | /usr/bin/awk '{print $2}'`
    683 				ports=`echo $rest | /usr/bin/awk '{print $3}'`
    684 				mac=`echo $rest | /usr/bin/awk '{print $4}'`
    685 				lacp_mode=`echo $rest | /usr/bin/awk \
    686 				    '{print $5}'`
    687 				lacp_timer=`echo $rest | /usr/bin/awk \
    688 				    '{print $6}'`
    689 				dladm_string="dladm create-aggr -P $policy -l \
    690 				    $lacp_mode -T $lacp_timer"
    691 				# A fixed MAC address
    692 				if [[ $mac != "auto" ]]; then
    693 					dladm_string="$dladm_string -u $mac"
    694 				fi
    695 				i=1
    696 				while [ $i -le $nports ]; do
    697 					device=`echo $ports | cut -d, -f$i`
    698 					# Older aggregation.conf files have the
    699 					# format of device_name/port_number.
    700 					# We don't need the port number, so get
    701 					# rid of it if it is there.
    702 					device=`echo $device | cut -d/ -f1`
    703 					((i = i + 1))
    704 					dladm_string="$dladm_string -d \
    705 					    $device"
    706 				done
    707 				dladm_string="$dladm_string $aggr_index"
    708 				echo $dladm_string >> \
    709 					$rootprefix$UPGRADE_SCRIPT
    710 			done
    711 		done
    712 		mv $ORIG $ORIG.bak
    713 	fi
    714 
    715 	# Upgrade linkprop.conf
    716 	ORIG=$rootprefix/etc/dladm/linkprop.conf
    717 
    718 	if [[ -f $ORIG ]]; then
    719 		# Strip off comments, then each remaining line lists
    720 		# properties the administrator configured for a	
    721 		# particular interface.  Each line includes several
    722 		# properties, but we can only set one property per
    723 		# dladm invocation.
    724 		cat $ORIG | grep '^[^#]' | while read line; do
    725 			echo $line | while read link rest
    726 			do
    727 				while [ -n "$rest" ]; do
    728 					linkprop=`echo $rest | cut -d";" -f1`
    729 					rest=`echo $rest | cut -d";" -f2-`
    730 					echo dladm set-linkprop -p $linkprop \
    731 					    $link >> $rootprefix$UPGRADE_SCRIPT
    732 				done
    733 			done
    734 		done
    735 		mv $ORIG $ORIG.bak
    736 	fi
    737 }
    738 
    739 # Update aac.conf for set legacy-name-enable properly
    740 update_aac_conf()
    741 {
    742 	conffile=$rootprefix/kernel/drv/aac.conf
    743 	childconffile=$rootprefix/bfu.child/kernel/drv/aac.conf
    744 
    745 	# Already using autoenumeration mode, return
    746 	egrep -s "legacy-name-enable" $childconffile && \
    747 	    grep "legacy-name-enable" $childconffile | egrep -s "no" && return
    748 
    749 	# Else enable legacy mode
    750 	sed -e 's/legacy-name-enable="no"/legacy-name-enable="yes"/g' \
    751 	    < $conffile > /tmp/aac.conf.$$
    752 	mv -f /tmp/aac.conf.$$ $conffile
    753 }
    754 
    755 # update x86 version mpt.conf for property tape
    756 mpttapeprop='[ 	]*tape[ 	]*=[ 	]*"sctp"[ 	]*;'
    757 update_mptconf_i386()
    758 {
    759 	conffile=$rootprefix/kernel/drv/mpt.conf
    760 	test -f $conffile || return
    761 	egrep -s "$mpttapeprop" $conffile
    762 	if [ $? -ne 0 ] ; then
    763 	    echo 'tape="sctp";' >> $conffile
    764 	fi
    765 }
    766 
    767 # update x86 etc/mach file after xVM_uppc is added,
    768 # which makes xpv_psm a non-default psm module
    769 update_etc_mach_i386()
    770 {
    771 	etc_mach=$rootprefix/etc/mach
    772 	test -f $etc_mach || return
    773 	grep -w "xpv_psm" $etc_mach > /dev/null 2>&1
    774 	if [ $? -ne 0 ] ; then
    775 	    echo 'xpv_psm' >> $etc_mach
    776 	fi
    777 }
    778 
    779 # check and update driver class for scsi-self-identifying
    780 chk_update_drv_class()
    781 {
    782 
    783     drvclassfile=$rootprefix/etc/driver_classes
    784     name2majorfile=$rootprefix/etc/name_to_major
    785     drvname=$1
    786     classentry="^$drvname[ 	].*scsi-self-identifying"
    787 
    788     [ -f $drvclassfile ] || return
    789     [ -f $name2majorfile ] || return
    790 
    791     grep -w $drvname $name2majorfile > /dev/null 2>&1 || return
    792 
    793     egrep -s "$classentry" $drvclassfile
    794     if [ $? -ne 0 ]; then
    795 	echo "$drvname	scsi-self-identifying" >> $drvclassfile
    796     fi
    797 }
    798 
    799 update_drvclass_i386()
    800 {
    801     chk_update_drv_class ahci
    802     chk_update_drv_class si3124
    803     chk_update_drv_class marvell88sx
    804     chk_update_drv_class nv_sata
    805 }
    806 
    807 update_policy_conf() {
    808 	# update /etc/security/policy.conf with the default
    809 	# Solaris crypt(3c) policy.
    810 	
    811 	dest=$rootprefix/etc/security/policy.conf
    812 
    813 	grep 'CRYPT_' $dest > /dev/null 2>&1
    814 	if [ $? = 1 ] ; then
    815 		print "Updating entries for crypt(3c), see policy.conf(4)"
    816 	cat >> $dest <<EOM
    817 
    818 # crypt(3c) Algorithms Configuration
    819 #
    820 # CRYPT_ALGORITHMS_ALLOW specifies the algorithms that are allowed to
    821 # be used for new passwords.  This is enforced only in crypt_gensalt(3c).
    822 #
    823 CRYPT_ALGORITHMS_ALLOW=1,2a,md5
    824 
    825 # To deprecate use of the traditional unix algorithm, uncomment below
    826 # and change CRYPT_DEFAULT= to another algorithm.  For example,