17c478bd9Sstevel@tonic-gate#!/sbin/sh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 66927f468Sdp# Common Development and Distribution License (the "License"). 76927f468Sdp# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 225f10ef69SYuri Pankov 237c478bd9Sstevel@tonic-gate# 24abcc7ef9SGangadhar Mylapuram# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 257c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 267c478bd9Sstevel@tonic-gate# All rights reserved. 275f10ef69SYuri Pankov# Copyright 2016 Nexenta Systems, Inc. 28*e39d8488SAndy Fiddaman# Copyright 2019 OmniOS Community Edition (OmniOSce) Association. 297c478bd9Sstevel@tonic-gate# 305f10ef69SYuri Pankov 317c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 327c478bd9Sstevel@tonic-gate. /lib/svc/share/fs_include.sh 337c478bd9Sstevel@tonic-gate 343b133becSGangadhar MylapuramUPDATEFILE=/etc/svc/volatile/boot_archive_needs_update 353b133becSGangadhar Mylapuram 367c478bd9Sstevel@tonic-gate# 37e7cbe64fSgw25295# Once root is read/write we can enable the dedicated dumpdevice if it exists 38e7cbe64fSgw25295# locally. This is an optimization as svc-dumpadm will attempt do this later. 397c478bd9Sstevel@tonic-gate# 40e7cbe64fSgw25295dump_setup() 41e7cbe64fSgw25295{ 42e7cbe64fSgw25295 [ -r /etc/dumpadm.conf ] && . /etc/dumpadm.conf 43e7cbe64fSgw25295 44e7cbe64fSgw25295 readswapdev $DUMPADM_DEVICE < $vfstab 45e7cbe64fSgw25295 46e7cbe64fSgw25295 # 4759bc618eSgw25295 # Make sure that the dump save area has been configured before 4859bc618eSgw25295 # proceeding. If the variable has not been defined or does not exist 4959bc618eSgw25295 # then bail out early. This will prevent us from configuring a 5059bc618eSgw25295 # dump save area before a hostname has been configured (i.e after 5159bc618eSgw25295 # sys-unconfig has been invoked). 5259bc618eSgw25295 # 5359bc618eSgw25295 [ -z "$DUMPADM_SAVDIR" ] && return 5459bc618eSgw25295 5559bc618eSgw25295 # 56e7cbe64fSgw25295 # If we have a dedicated dump device, then go ahead and configure it. 57e7cbe64fSgw25295 # 58e7cbe64fSgw25295 if [ "x$special" != "x$DUMPADM_DEVICE" ]; then 59e7cbe64fSgw25295 if [ -x /usr/sbin/dumpadm -a -b $DUMPADM_DEVICE ]; then 60e7cbe64fSgw25295 /usr/sbin/dumpadm -u || exit $SMF_EXIT_ERR_CONFIG 61e7cbe64fSgw25295 fi 62e7cbe64fSgw25295 fi 63e7cbe64fSgw25295} 647c478bd9Sstevel@tonic-gate 65f6e214c7SGavin Maltby# 66f6e214c7SGavin Maltby# Write a unique id into this kernel image; this will be included 67f6e214c7SGavin Maltby# in the dump header and panicbuf of any crashdump of this image. 68f6e214c7SGavin Maltby# 69f6e214c7SGavin Maltbyif [ -x /usr/sbin/dumpadm ]; then 70f6e214c7SGavin Maltby /usr/sbin/dumpadm -i 71f6e214c7SGavin Maltbyfi 72f6e214c7SGavin Maltby 73a227b7f4Shs24103rootiszfs=0 74a227b7f4Shs24103# get the fstype of root 75a227b7f4Shs24103readmnttab / </etc/mnttab 76a227b7f4Shs24103if [ "$fstype" = zfs ] ; then 77a227b7f4Shs24103 rootiszfs=1 78e7cbe64fSgw25295 dump_setup 79a227b7f4Shs24103fi 80a227b7f4Shs24103 817c478bd9Sstevel@tonic-gate# 82e7cbe64fSgw25295# Add physical swap. 83e7cbe64fSgw25295# 84e7cbe64fSgw25295/sbin/swapadd -1 85e7cbe64fSgw25295 86e7cbe64fSgw25295# 877c478bd9Sstevel@tonic-gate# Check and remount the / (root) file system. 887c478bd9Sstevel@tonic-gate# For NFS mounts, force the llock option on. 897c478bd9Sstevel@tonic-gate# 90a227b7f4Shs24103if smf_is_globalzone && [ $rootiszfs = 0 ]; then 917c478bd9Sstevel@tonic-gate readvfstab / < $vfstab 927c478bd9Sstevel@tonic-gate checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL 937c478bd9Sstevel@tonic-gate checkopt "llock" $mntopts 947c478bd9Sstevel@tonic-gate mntopts='remount' 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate [ -n "$otherops" ] && mntopts="${mntopts},${otherops}" 977c478bd9Sstevel@tonic-gate [ "$fstype" = nfs ] && mntopts="${mntopts},llock" 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate mountfs -m $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 1007c478bd9Sstevel@tonic-gatefi 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate# 1037c478bd9Sstevel@tonic-gate# Check and remount the /usr file system (formerly mounted read-only). 104a227b7f4Shs24103# Unless root is zfs, in which case we've already mounted /usr read-write 1057c478bd9Sstevel@tonic-gate# 106a227b7f4Shs24103if [ "$rootiszfs" = 0 ] ; then 1077c478bd9Sstevel@tonic-gate readvfstab /usr < $vfstab 1087c478bd9Sstevel@tonic-gate if [ "$mountp" ]; then 1097c478bd9Sstevel@tonic-gate checkopt ro $mntopts 1107c478bd9Sstevel@tonic-gate if [ "x$option" != xro ]; then 1117c478bd9Sstevel@tonic-gate checkfs $fsckdev $fstype $mountp || 1127c478bd9Sstevel@tonic-gate exit $SMF_EXIT_ERR_FATAL 1137c478bd9Sstevel@tonic-gate if [ "x$mntopts" != x- ]; then 1147c478bd9Sstevel@tonic-gate mntopts="remount,$mntopts" 1157c478bd9Sstevel@tonic-gate else 1167c478bd9Sstevel@tonic-gate mntopts="remount" 1177c478bd9Sstevel@tonic-gate fi 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate mountfs - /usr $fstype $mntopts - || 1207c478bd9Sstevel@tonic-gate exit $SMF_EXIT_ERR_FATAL 1217c478bd9Sstevel@tonic-gate fi 1227c478bd9Sstevel@tonic-gate fi 1237c478bd9Sstevel@tonic-gatefi 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate# 1267c478bd9Sstevel@tonic-gate# Check and mount the /usr/platform file system. This should only be 1277c478bd9Sstevel@tonic-gate# present when a SunOS 5.5 (Solaris 2.5) or greater client is being 1287c478bd9Sstevel@tonic-gate# administered by a SunOS 5.4 or less host. 1297c478bd9Sstevel@tonic-gate# 1307c478bd9Sstevel@tonic-gatereadvfstab /usr/platform < $vfstab 1317c478bd9Sstevel@tonic-gateif [ "$mountp" ]; then 1327c478bd9Sstevel@tonic-gate checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL 1337c478bd9Sstevel@tonic-gate mountfs - $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 1347c478bd9Sstevel@tonic-gatefi 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate# 1377c478bd9Sstevel@tonic-gate# Mount the fd file systems if mount point exists. 1387c478bd9Sstevel@tonic-gate# 1397c478bd9Sstevel@tonic-gatereadvfstab /dev/fd < $vfstab 1407c478bd9Sstevel@tonic-gateif [ "$mountp" -a -d /dev/fd ]; then 1417c478bd9Sstevel@tonic-gate mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL 1427c478bd9Sstevel@tonic-gatefi 1437c478bd9Sstevel@tonic-gate 1443b133becSGangadhar Mylapuramif [ -f "${UPDATEFILE}" ]; then 1453b133becSGangadhar Mylapuram /usr/sbin/bootadm update-archive 1463b133becSGangadhar Mylapuram if [ $? != 0 ]; then 1473b133becSGangadhar Mylapuram cecho "" 1483b133becSGangadhar Mylapuram cecho "WARNING: Automatic update of the boot archive failed." 14929db4766SGangadhar Mylapuram cecho "Update the archives using 'bootadm update-archive'" 150*e39d8488SAndy Fiddaman cecho "command and then reboot the system from the same device" 151*e39d8488SAndy Fiddaman cecho "that was previously booted." 1523b133becSGangadhar Mylapuram cecho "" 1533b133becSGangadhar Mylapuram exit $SMF_EXIT_ERR_FATAL 1543b133becSGangadhar Mylapuram fi 1553b133becSGangadhar Mylapuram rm -f $UPDATEFILE 156*e39d8488SAndy Fiddaman 157*e39d8488SAndy Fiddaman cecho "" 158*e39d8488SAndy Fiddaman cecho "WARNING: Reboot required." 159*e39d8488SAndy Fiddaman cecho "The system has updated the cache of files (boot archive) that" 160*e39d8488SAndy Fiddaman cecho "is used during the early boot sequence. To avoid booting and" 161*e39d8488SAndy Fiddaman cecho "running the system with the previously out-of-sync version of" 162*e39d8488SAndy Fiddaman cecho "these files, the system will be restarted." 163*e39d8488SAndy Fiddaman cecho "" 164*e39d8488SAndy Fiddaman 1653b133becSGangadhar Mylapuram bootcmd=`/usr/sbin/eeprom bootcmd | /usr/bin/sed -e 's#bootcmd=##g'` 1663b133becSGangadhar Mylapuram if [ `uname -p` = "i386" ]; then 1673b133becSGangadhar Mylapuram /usr/sbin/reboot -f dryrun 1683b133becSGangadhar Mylapuram if [ $? = 0 ]; then 1693b133becSGangadhar Mylapuram /usr/sbin/reboot -f -- "$bootcmd" 1703b133becSGangadhar Mylapuram exit $SMF_EXIT_OK 1713b133becSGangadhar Mylapuram fi 172*e39d8488SAndy Fiddaman boot_prop=`/usr/sbin/svccfg -s svc:/system/boot-config:default \ 173*e39d8488SAndy Fiddaman listprop config/auto-reboot-safe | \ 1743b133becSGangadhar Mylapuram /usr/bin/nawk '{ print $3}'` 175*e39d8488SAndy Fiddaman if [ "$boot_prop" = "true" ]; then 1763b133becSGangadhar Mylapuram /usr/sbin/reboot -p 1773b133becSGangadhar Mylapuram exit $SMF_EXIT_OK 1783b133becSGangadhar Mylapuram fi 179*e39d8488SAndy Fiddaman cecho "" 180*e39d8488SAndy Fiddaman cecho "It has not been possible to restart automatically." 181*e39d8488SAndy Fiddaman cecho "Reboot the system from the same device that was" 182*e39d8488SAndy Fiddaman cecho "previously booted." 183*e39d8488SAndy Fiddaman cecho "" 184*e39d8488SAndy Fiddaman exit $SMF_EXIT_ERR_FATAL 1853b133becSGangadhar Mylapuram fi 1863b133becSGangadhar Mylapuram /usr/sbin/reboot -- "$bootcmd" 1873b133becSGangadhar Mylapuramfi 1883b133becSGangadhar Mylapuram 1897c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK 190