-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathboot_archive
121 lines (108 loc) · 2.99 KB
/
boot_archive
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/ksh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Description:
#
# Script to mount/umount the boot_archive
#
# Author:
# Bernd Schemmer ([email protected])
#
# History
# 03.11.2008 /bs
# inital release
#
# Usage:
#
# boot_archive {umount}
#
# Default action without a parameter is to mount the boot_archive
#
# Notes:
#
# Be aware, that the files in the boot_archive are all gezipped, e.g. to view the files use something like:
#
# gzip -cd /tmp/boot_archive/etc/path_to_inst
#
# or
#
# gzcat /tmp/boot_archive/etc/path_to_inst
#
# this script can run on x86 and SPARC (for OpenSolaris or Solaris 10 Update 6 and later)
#
ARCH="$( uname -m )"
case ${ARCH} in
sun4u | sun4us | sun4v )
BOOT_ARCHIVE="/platform/${ARCH}/boot_archive"
;;
i86pc | i86xpv )
[ "$( isainfo -b )"x = "32"x ] && ISADIR="/" || ISADIR="/amd64/"
BOOT_ARCHIVE="/platform/i86pc${ISADIR}boot_archive"
;;
esac
if [ ! -r "${BOOT_ARCHIVE}" ] ; then
echo "ERROR: The boot archive \"${BOOT_ARCHIVE}\" does not exist or is not readable!"
exit 5
fi
echo "Using the boot archive \"${BOOT_ARCHIVE}\" ..."
# check if there is already a lofi device for the boot_archive
#
LOFI_DEV="$( lofiadm "${BOOT_ARCHIVE}" 2>/dev/null )"
MOUNT_POINT="/tmp/boot_archive"
mkdir -p "${MOUNT_POINT}"
if [ $? -ne 0 ] ; then
echo "ERROR: error creating the temporary mountpoint \"${MOUNT_POINT}\" "
exit 15
fi
case $1 in
-h | --help | "-?" )
echo "Usage: $( basename $0 ) {umount}"
exit 1
;;
uninstall | umount )
if [ "${LOFI_DEV}"x != ""x ] ; then
umount ${LOFI_DEV} 2>/dev/null
lofiadm -d ${LOFI_DEV}
echo "boot_archive umounted"
else
echo "The boot_archive is not mounted."
fi
;;
* )
if [ "${LOFI_DEV}"x = ""x ] ; then
LOFI_DEV=$( lofiadm -a "${BOOT_ARCHIVE}" )
[ $? -ne 0 ] && exit 5
fi
MOUNT_MSG="$( mount | grep " ${LOFI_DEV} " )"
if [ $? != 0 ] ; then
FSTYP=$( fstyp ${LOFI_DEV} )
[ ${FSTYP} ] && MSG="readonly (${FSTYP})]" || MSG="readwrite (${FSTYP})]"
mount -F ${FSTYP} ${LOFI_DEV} ${MOUNT_POINT}
[ $? -ne 0 ] && exit 10
echo "boot_archive mounted ${MSG}: "
mount | grep ${MOUNT_POINT}
else
echo "boot_archive already mounted:"
echo "${MOUNT_MSG}"
fi
;;
esac