1#!/sbin/sh 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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 25# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 26# All rights reserved. 27# Copyright 2016 Nexenta Systems, Inc. 28# Copyright 2019 OmniOS Community Edition (OmniOSce) Association. 29# 30 31. /lib/svc/share/smf_include.sh 32. /lib/svc/share/fs_include.sh 33 34UPDATEFILE=/etc/svc/volatile/boot_archive_needs_update 35 36# 37# Once root is read/write we can enable the dedicated dumpdevice if it exists 38# locally. This is an optimization as svc-dumpadm will attempt do this later. 39# 40dump_setup() 41{ 42 [ -r /etc/dumpadm.conf ] && . /etc/dumpadm.conf 43 44 readswapdev $DUMPADM_DEVICE < $vfstab 45 46 # 47 # Make sure that the dump save area has been configured before 48 # proceeding. If the variable has not been defined or does not exist 49 # then bail out early. This will prevent us from configuring a 50 # dump save area before a hostname has been configured (i.e after 51 # sys-unconfig has been invoked). 52 # 53 [ -z "$DUMPADM_SAVDIR" ] && return 54 55 # 56 # If we have a dedicated dump device, then go ahead and configure it. 57 # 58 if [ "x$special" != "x$DUMPADM_DEVICE" ]; then 59 if [ -x /usr/sbin/dumpadm -a -b $DUMPADM_DEVICE ]; then 60 /usr/sbin/dumpadm -u || exit $SMF_EXIT_ERR_CONFIG 61 fi 62 fi 63} 64 65# 66# Write a unique id into this kernel image; this will be included 67# in the dump header and panicbuf of any crashdump of this image. 68# 69if [ -x /usr/sbin/dumpadm ]; then 70 /usr/sbin/dumpadm -i 71fi 72 73rootiszfs=0 74# get the fstype of root 75readmnttab / </etc/mnttab 76if [ "$fstype" = zfs ] ; then 77 rootiszfs=1 78 dump_setup 79fi 80 81# 82# Add physical swap. 83# 84/sbin/swapadd -1 85 86# 87# Check and remount the / (root) file system. 88# For NFS mounts, force the llock option on. 89# 90if smf_is_globalzone && [ $rootiszfs = 0 ]; then 91 readvfstab / < $vfstab 92 checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL 93 checkopt "llock" $mntopts 94 mntopts='remount' 95 96 [ -n "$otherops" ] && mntopts="${mntopts},${otherops}" 97 [ "$fstype" = nfs ] && mntopts="${mntopts},llock" 98 99 mountfs -m $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 100fi 101 102# 103# Check and remount the /usr file system (formerly mounted read-only). 104# Unless root is zfs, in which case we've already mounted /usr read-write 105# 106if [ "$rootiszfs" = 0 ] ; then 107 readvfstab /usr < $vfstab 108 if [ "$mountp" ]; then 109 checkopt ro $mntopts 110 if [ "x$option" != xro ]; then 111 checkfs $fsckdev $fstype $mountp || 112 exit $SMF_EXIT_ERR_FATAL 113 if [ "x$mntopts" != x- ]; then 114 mntopts="remount,$mntopts" 115 else 116 mntopts="remount" 117 fi 118 119 mountfs - /usr $fstype $mntopts - || 120 exit $SMF_EXIT_ERR_FATAL 121 fi 122 fi 123fi 124 125# 126# Check and mount the /usr/platform file system. This should only be 127# present when a SunOS 5.5 (Solaris 2.5) or greater client is being 128# administered by a SunOS 5.4 or less host. 129# 130readvfstab /usr/platform < $vfstab 131if [ "$mountp" ]; then 132 checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL 133 mountfs - $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 134fi 135 136# 137# Mount the fd file systems if mount point exists. 138# 139readvfstab /dev/fd < $vfstab 140if [ "$mountp" -a -d /dev/fd ]; then 141 mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL 142fi 143 144if [ -f "${UPDATEFILE}" ]; then 145 /usr/sbin/bootadm update-archive 146 if [ $? != 0 ]; then 147 cecho "" 148 cecho "WARNING: Automatic update of the boot archive failed." 149 cecho "Update the archives using 'bootadm update-archive'" 150 cecho "command and then reboot the system from the same device" 151 cecho "that was previously booted." 152 cecho "" 153 exit $SMF_EXIT_ERR_FATAL 154 fi 155 rm -f $UPDATEFILE 156 157 cecho "" 158 cecho "WARNING: Reboot required." 159 cecho "The system has updated the cache of files (boot archive) that" 160 cecho "is used during the early boot sequence. To avoid booting and" 161 cecho "running the system with the previously out-of-sync version of" 162 cecho "these files, the system will be restarted." 163 cecho "" 164 165 bootcmd=`/usr/sbin/eeprom bootcmd | /usr/bin/sed -e 's#bootcmd=##g'` 166 if [ `uname -p` = "i386" ]; then 167 /usr/sbin/reboot -f dryrun 168 if [ $? = 0 ]; then 169 /usr/sbin/reboot -f -- "$bootcmd" 170 exit $SMF_EXIT_OK 171 fi 172 boot_prop=`/usr/sbin/svccfg -s svc:/system/boot-config:default \ 173 listprop config/auto-reboot-safe | \ 174 /usr/bin/nawk '{ print $3}'` 175 if [ "$boot_prop" = "true" ]; then 176 /usr/sbin/reboot -p 177 exit $SMF_EXIT_OK 178 fi 179 cecho "" 180 cecho "It has not been possible to restart automatically." 181 cecho "Reboot the system from the same device that was" 182 cecho "previously booted." 183 cecho "" 184 exit $SMF_EXIT_ERR_FATAL 185 fi 186 /usr/sbin/reboot -- "$bootcmd" 187fi 188 189exit $SMF_EXIT_OK 190