xref: /illumos-gate/usr/src/cmd/boot/scripts/boot-archive-update.ksh (revision f6c47fdeea63a9c5d1abefdffb93d3f87e12b7d0)
158091fd8Ssetje#!/sbin/sh
258091fd8Ssetje#
358091fd8Ssetje# CDDL HEADER START
458091fd8Ssetje#
558091fd8Ssetje# The contents of this file are subject to the terms of the
658091fd8Ssetje# Common Development and Distribution License (the "License").
758091fd8Ssetje# You may not use this file except in compliance with the License.
858091fd8Ssetje#
958091fd8Ssetje# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1058091fd8Ssetje# or http://www.opensolaris.org/os/licensing.
1158091fd8Ssetje# See the License for the specific language governing permissions
1258091fd8Ssetje# and limitations under the License.
1358091fd8Ssetje#
1458091fd8Ssetje# When distributing Covered Code, include this CDDL HEADER in each
1558091fd8Ssetje# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1658091fd8Ssetje# If applicable, add the following below this CDDL HEADER, with the
1758091fd8Ssetje# fields enclosed by brackets "[]" replaced with your own identifying
1858091fd8Ssetje# information: Portions Copyright [yyyy] [name of copyright owner]
1958091fd8Ssetje#
2058091fd8Ssetje# CDDL HEADER END
2158091fd8Ssetje#
2258091fd8Ssetje#
233b133becSGangadhar Mylapuram# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2458091fd8Ssetje# Use is subject to license terms.
2575383e32SAndy Fiddaman# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
26*f6c47fdeSJoshua M. Clulow# Copyright 2021 Oxide Computer Company
2758091fd8Ssetje#
2858091fd8Ssetje
2958091fd8Ssetje. /lib/svc/share/smf_include.sh
3058091fd8Ssetje. /lib/svc/share/fs_include.sh
3158091fd8Ssetje
323b133becSGangadhar MylapuramUPDATEFILE=/etc/svc/volatile/boot_archive_safefile_update
3358091fd8Ssetje
34*f6c47fdeSJoshua M. Clulowif smf_is_nonglobalzone || smf_root_is_ramdisk; then
35*f6c47fdeSJoshua M. Clulow	#
36*f6c47fdeSJoshua M. Clulow	# Boot archives only exist in the global zone of persistent root
37*f6c47fdeSJoshua M. Clulow	# systems, but this is either a non-global zone or a system booted from
38*f6c47fdeSJoshua M. Clulow	# a ramdisk image.
39*f6c47fdeSJoshua M. Clulow	#
40*f6c47fdeSJoshua M. Clulow	exit $SMF_EXIT_OK
41*f6c47fdeSJoshua M. Clulowfi
4258091fd8Ssetje
43986fd29aSsetjeif [ `uname -p` = "i386" ]; then
4475383e32SAndy Fiddaman	# on x86 get rid of transient reboot entry in the GRUB menu
4558091fd8Ssetje	if [ -f /stubboot/boot/grub/menu.lst ]; then
4658091fd8Ssetje		/sbin/bootadm -m update_temp -R /stubboot
4758091fd8Ssetje	else
4858091fd8Ssetje		/sbin/bootadm -m update_temp
4958091fd8Ssetje	fi
5075383e32SAndy Fiddaman	# Remove old 32-bit archives if present.
5175383e32SAndy Fiddaman	plat=/platform/`uname -i`
5275383e32SAndy Fiddaman	[ -f $plat/boot_archive ] && rm -f $plat/boot_archive
5375383e32SAndy Fiddaman	[ -f $plat/boot_archive.hash ] && rm -f $plat/boot_archive.hash
5475383e32SAndy Fiddaman	[ -d $plat/archive_cache ] && rm -rf $plat/archive_cache
55986fd29aSsetjefi
5658091fd8Ssetje
5758091fd8Ssetjeif [ -f $UPDATEFILE ] || [ -f /reconfigure ]; then
5858091fd8Ssetje	/usr/sbin/rtc -c > /dev/null 2>&1
5958091fd8Ssetje	/sbin/bootadm update-archive
6058091fd8Ssetje	rm -f $UPDATEFILE
6158091fd8Ssetjefi
6258091fd8Ssetje
6358091fd8Ssetjeexit $SMF_EXIT_OK
64