xref: /titanic_53/usr/src/cmd/fs.d/zfs/bootinstall/bootinstall.sh (revision 75100ee845c13b4b3c7f0d83fa2f9725e699d6e9)
1943e9869SLori Alt#!/bin/ksh -p
2943e9869SLori Alt#
3943e9869SLori Alt# CDDL HEADER START
4943e9869SLori Alt#
5943e9869SLori Alt# The contents of this file are subject to the terms of the
6943e9869SLori Alt# Common Development and Distribution License (the "License").
7943e9869SLori Alt# You may not use this file except in compliance with the License.
8943e9869SLori Alt#
9943e9869SLori Alt# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10943e9869SLori Alt# or http://www.opensolaris.org/os/licensing.
11943e9869SLori Alt# See the License for the specific language governing permissions
12943e9869SLori Alt# and limitations under the License.
13943e9869SLori Alt#
14943e9869SLori Alt# When distributing Covered Code, include this CDDL HEADER in each
15943e9869SLori Alt# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16943e9869SLori Alt# If applicable, add the following below this CDDL HEADER, with the
17943e9869SLori Alt# fields enclosed by brackets "[]" replaced with your own identifying
18943e9869SLori Alt# information: Portions Copyright [yyyy] [name of copyright owner]
19943e9869SLori Alt#
20943e9869SLori Alt# CDDL HEADER END
21943e9869SLori Alt#
22943e9869SLori Alt
23943e9869SLori Alt#
24*75100ee8SToomas Soome# Copyright (c) 2015, Toomas Soome <tsoome@me.com>
25943e9869SLori Alt# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
26943e9869SLori Alt#
27943e9869SLori Alt
28943e9869SLori AltPATH="/usr/bin:/usr/sbin:${PATH}"; export PATH
29*75100ee8SToomas SoomeLOGGER="/bin/logger -t $0 -p daemon.notice"
30943e9869SLori Alt
31943e9869SLori AltPOOL="$1"
32943e9869SLori AltDEV=$(echo "$2" | sed -e 's+/dsk/+/rdsk/+')
33943e9869SLori Alt
34943e9869SLori Altif [ -z "${POOL}" -o -z "${DEV}" ]; then
35*75100ee8SToomas Soome	$LOGGER "Invalid usage"
36943e9869SLori Alt	exit 1
37943e9869SLori Altfi
38943e9869SLori Alt
39943e9869SLori AltCURPOOL=$(df -k / | awk 'NR == 2 {print $1}' | sed 's,/.*,,')
40943e9869SLori Alt
41943e9869SLori Altif [ "$CURPOOL" != "$POOL" ] ; then
42*75100ee8SToomas Soome	$LOGGER "Modified pool must be current root pool"
43943e9869SLori Alt	exit 1
44943e9869SLori Altfi
45943e9869SLori Alt
46*75100ee8SToomas Soome/sbin/bootadm install-bootloader -f
47943e9869SLori Altif [ $? != 0 ]; then
48*75100ee8SToomas Soome	$LOGGER "Failure installing boot block on ${DEV}"
49943e9869SLori Alt	exit 1
50943e9869SLori Altfi
51943e9869SLori Alt
52943e9869SLori Altexit 0
53