10Sstevel@tonic-gate#!/sbin/sh 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 61573Sdp# Common Development and Distribution License (the "License"). 71573Sdp# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 220Sstevel@tonic-gate# 2312549SGangadhar.M@Sun.COM# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate# 250Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 260Sstevel@tonic-gate# All rights reserved. 270Sstevel@tonic-gate# 280Sstevel@tonic-gate# 290Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 300Sstevel@tonic-gate. /lib/svc/share/fs_include.sh 310Sstevel@tonic-gate 3211906SGangadhar.M@Sun.COMUPDATEFILE=/etc/svc/volatile/boot_archive_needs_update 3311906SGangadhar.M@Sun.COM 340Sstevel@tonic-gate# 356423Sgw25295# Once root is read/write we can enable the dedicated dumpdevice if it exists 366423Sgw25295# locally. This is an optimization as svc-dumpadm will attempt do this later. 370Sstevel@tonic-gate# 386423Sgw25295dump_setup() 396423Sgw25295{ 406423Sgw25295 [ -r /etc/dumpadm.conf ] && . /etc/dumpadm.conf 416423Sgw25295 426423Sgw25295 readswapdev $DUMPADM_DEVICE < $vfstab 436423Sgw25295 446423Sgw25295 # 456897Sgw25295 # Make sure that the dump save area has been configured before 466897Sgw25295 # proceeding. If the variable has not been defined or does not exist 476897Sgw25295 # then bail out early. This will prevent us from configuring a 486897Sgw25295 # dump save area before a hostname has been configured (i.e after 496897Sgw25295 # sys-unconfig has been invoked). 506897Sgw25295 # 516897Sgw25295 [ -z "$DUMPADM_SAVDIR" ] && return 526897Sgw25295 536897Sgw25295 # 546423Sgw25295 # If we have a dedicated dump device, then go ahead and configure it. 556423Sgw25295 # 566423Sgw25295 if [ "x$special" != "x$DUMPADM_DEVICE" ]; then 576423Sgw25295 if [ -x /usr/sbin/dumpadm -a -b $DUMPADM_DEVICE ]; then 586423Sgw25295 /usr/sbin/dumpadm -u || exit $SMF_EXIT_ERR_CONFIG 596423Sgw25295 fi 606423Sgw25295 fi 616423Sgw25295} 620Sstevel@tonic-gate 63*12967Sgavin.maltby@oracle.com# 64*12967Sgavin.maltby@oracle.com# Write a unique id into this kernel image; this will be included 65*12967Sgavin.maltby@oracle.com# in the dump header and panicbuf of any crashdump of this image. 66*12967Sgavin.maltby@oracle.com# 67*12967Sgavin.maltby@oracle.comif [ -x /usr/sbin/dumpadm ]; then 68*12967Sgavin.maltby@oracle.com /usr/sbin/dumpadm -i 69*12967Sgavin.maltby@oracle.comfi 70*12967Sgavin.maltby@oracle.com 716168Shs24103rootiszfs=0 726168Shs24103# get the fstype of root 736168Shs24103readmnttab / </etc/mnttab 746168Shs24103if [ "$fstype" = zfs ] ; then 756168Shs24103 rootiszfs=1 766423Sgw25295 dump_setup 776168Shs24103fi 786168Shs24103 790Sstevel@tonic-gate# 806423Sgw25295# Add physical swap. 816423Sgw25295# 826423Sgw25295/sbin/swapadd -1 836423Sgw25295 846423Sgw25295# 850Sstevel@tonic-gate# Check and remount the / (root) file system. 860Sstevel@tonic-gate# For NFS mounts, force the llock option on. 870Sstevel@tonic-gate# 886168Shs24103if smf_is_globalzone && [ $rootiszfs = 0 ]; then 890Sstevel@tonic-gate readvfstab / < $vfstab 900Sstevel@tonic-gate checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL 910Sstevel@tonic-gate checkopt "llock" $mntopts 920Sstevel@tonic-gate mntopts='remount' 930Sstevel@tonic-gate 940Sstevel@tonic-gate [ -n "$otherops" ] && mntopts="${mntopts},${otherops}" 950Sstevel@tonic-gate [ "$fstype" = nfs ] && mntopts="${mntopts},llock" 960Sstevel@tonic-gate 970Sstevel@tonic-gate # if root dev is a read-only metadevice then fail 980Sstevel@tonic-gate case $special in 990Sstevel@tonic-gate /dev/md/dsk/*) 1000Sstevel@tonic-gate dd if=/dev/null of=$special count=0 >/dev/null 2>&1 || 1010Sstevel@tonic-gate exit $SMF_EXIT_ERR_FATAL 1020Sstevel@tonic-gate ;; 1030Sstevel@tonic-gate esac 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate mountfs -m $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 1060Sstevel@tonic-gatefi 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate# 1090Sstevel@tonic-gate# Check and remount the /usr file system (formerly mounted read-only). 1106168Shs24103# Unless root is zfs, in which case we've already mounted /usr read-write 1110Sstevel@tonic-gate# 1126168Shs24103if [ "$rootiszfs" = 0 ] ; then 1136168Shs24103 readvfstab /usr < $vfstab 1146168Shs24103 if [ "$mountp" ]; then 1156168Shs24103 if [ "$fstype" = cachefs ]; then 1166168Shs24103 mountfs -O $mountp cachefs $mntopts $special || 1170Sstevel@tonic-gate exit $SMF_EXIT_ERR_FATAL 1186168Shs24103 else 1196168Shs24103 checkopt ro $mntopts 1206168Shs24103 if [ "x$option" != xro ]; then 1216168Shs24103 checkfs $fsckdev $fstype $mountp || 1226168Shs24103 exit $SMF_EXIT_ERR_FATAL 1236168Shs24103 if [ "x$mntopts" != x- ]; then 1246168Shs24103 mntopts="remount,$mntopts" 1256168Shs24103 else 1266168Shs24103 mntopts="remount" 1276168Shs24103 fi 1280Sstevel@tonic-gate 1296168Shs24103 # if usr dev is a read-only metadevice then fail 1306168Shs24103 case $special in 1316168Shs24103 /dev/md/dsk/*) 1326168Shs24103 dd if=/dev/null of=$special count=0 \ 1336168Shs24103 >/dev/null 2>&1 || exit $SMF_EXIT_ERR_FATAL 1346168Shs24103 ;; 1356168Shs24103 esac 1360Sstevel@tonic-gate 1376168Shs24103 mountfs - /usr $fstype $mntopts - || 1386168Shs24103 exit $SMF_EXIT_ERR_FATAL 1396168Shs24103 fi 1400Sstevel@tonic-gate fi 1410Sstevel@tonic-gate fi 1420Sstevel@tonic-gatefi 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate# 1450Sstevel@tonic-gate# Check and mount the /usr/platform file system. This should only be 1460Sstevel@tonic-gate# present when a SunOS 5.5 (Solaris 2.5) or greater client is being 1470Sstevel@tonic-gate# administered by a SunOS 5.4 or less host. 1480Sstevel@tonic-gate# 1490Sstevel@tonic-gatereadvfstab /usr/platform < $vfstab 1500Sstevel@tonic-gateif [ "$mountp" ]; then 1510Sstevel@tonic-gate checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL 1520Sstevel@tonic-gate mountfs - $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 1530Sstevel@tonic-gatefi 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate# 1560Sstevel@tonic-gate# Mount the fd file systems if mount point exists. 1570Sstevel@tonic-gate# 1580Sstevel@tonic-gatereadvfstab /dev/fd < $vfstab 1590Sstevel@tonic-gateif [ "$mountp" -a -d /dev/fd ]; then 1600Sstevel@tonic-gate mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL 1610Sstevel@tonic-gatefi 1620Sstevel@tonic-gate 16311906SGangadhar.M@Sun.COMif [ -f "${UPDATEFILE}" ]; then 16411906SGangadhar.M@Sun.COM /usr/sbin/bootadm update-archive 16511906SGangadhar.M@Sun.COM if [ $? != 0 ]; then 16611906SGangadhar.M@Sun.COM cecho "" 16711906SGangadhar.M@Sun.COM cecho "WARNING: Automatic update of the boot archive failed." 16812006SGangadhar.M@Sun.COM cecho "Update the archives using 'bootadm update-archive'" 16911906SGangadhar.M@Sun.COM cecho "command and then reboot the system from the same device that" 17011906SGangadhar.M@Sun.COM cecho "was previously booted." 17111906SGangadhar.M@Sun.COM cecho "" 17211906SGangadhar.M@Sun.COM exit $SMF_EXIT_ERR_FATAL 17311906SGangadhar.M@Sun.COM fi 17411906SGangadhar.M@Sun.COM rm -f $UPDATEFILE 17511906SGangadhar.M@Sun.COM bootcmd=`/usr/sbin/eeprom bootcmd | /usr/bin/sed -e 's#bootcmd=##g'` 17611906SGangadhar.M@Sun.COM if [ `uname -p` = "i386" ]; then 17711906SGangadhar.M@Sun.COM /usr/sbin/reboot -f dryrun 17811906SGangadhar.M@Sun.COM if [ $? = 0 ]; then 17911906SGangadhar.M@Sun.COM /usr/sbin/reboot -f -- "$bootcmd" 18011906SGangadhar.M@Sun.COM exit $SMF_EXIT_OK 18111906SGangadhar.M@Sun.COM fi 18212549SGangadhar.M@Sun.COM boot_prop=`/usr/sbin/svccfg -s svc:/system/boot-config:default listprop config/auto-reboot-safe | \ 18311906SGangadhar.M@Sun.COM /usr/bin/nawk '{ print $3}'` 18411906SGangadhar.M@Sun.COM if [ "$boot_prop" != "true" ]; then 18511906SGangadhar.M@Sun.COM cecho "" 18611906SGangadhar.M@Sun.COM cecho "WARNING: Reboot required." 18711906SGangadhar.M@Sun.COM cecho "The system has updated the cache of files (boot archive) that is used" 18811906SGangadhar.M@Sun.COM cecho "during the early boot sequence. To avoid booting and running the system" 18911906SGangadhar.M@Sun.COM cecho "with the previously out-of-sync version of these files, reboot the" 19011906SGangadhar.M@Sun.COM cecho "system from the same device that was previously booted." 19111906SGangadhar.M@Sun.COM cecho "" 19211906SGangadhar.M@Sun.COM exit $SMF_EXIT_ERR_FATAL 19311906SGangadhar.M@Sun.COM else 19411906SGangadhar.M@Sun.COM /usr/sbin/reboot -p 19511906SGangadhar.M@Sun.COM exit $SMF_EXIT_OK 19611906SGangadhar.M@Sun.COM fi 19711906SGangadhar.M@Sun.COM fi 19811906SGangadhar.M@Sun.COM /usr/sbin/reboot -- "$bootcmd" 19911906SGangadhar.M@Sun.COMfi 20011906SGangadhar.M@Sun.COM 2010Sstevel@tonic-gateexit $SMF_EXIT_OK 202