1
|
#!/bin/sh
|
2
|
# Functions which unmount all mounted disk filesystems
|
3
|
|
4
|
# Script that adds our gmirror devices for syncing
|
5
|
start_gmirror_sync()
|
6
|
{
|
7
|
|
8
|
cd ${MIRRORCFGDIR}
|
9
|
for DISK in `ls *`
|
10
|
do
|
11
|
MIRRORDISK="`cat ${DISK} | cut -d ':' -f 1`"
|
12
|
MIRRORBAL="`cat ${DISK} | cut -d ':' -f 2`"
|
13
|
MIRRORNAME="`cat ${DISK} | cut -d ':' -f 3`"
|
14
|
|
15
|
# Start the mirroring service
|
16
|
rc_halt "gmirror insert ${MIRRORNAME} /dev/${MIRRORDISK}"
|
17
|
|
18
|
done
|
19
|
|
20
|
};
|
21
|
|
22
|
# Unmounts all our mounted file-systems
|
23
|
unmount_all_filesystems()
|
24
|
{
|
25
|
# Copy the logfile to disk before we unmount
|
26
|
cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log
|
27
|
cd /
|
28
|
|
29
|
# Start by unmounting any ZFS partitions
|
30
|
zfs_cleanup_unmount
|
31
|
|
32
|
# Lets read our partition list, and unmount each
|
33
|
##################################################################
|
34
|
for PART in `ls ${PARTDIR}`
|
35
|
do
|
36
|
|
37
|
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
|
38
|
PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
|
39
|
PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
|
40
|
PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
|
41
|
|
42
|
if [ "${PARTENC}" = "ON" ]
|
43
|
then
|
44
|
EXT=".eli"
|
45
|
else
|
46
|
EXT=""
|
47
|
fi
|
48
|
|
49
|
#if [ "${PARTFS}" = "SWAP" ]
|
50
|
#then
|
51
|
# rc_nohalt "swapoff /dev/${PART}${EXT}"
|
52
|
#fi
|
53
|
|
54
|
# Check if we've found "/", and unmount that last
|
55
|
if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
|
56
|
then
|
57
|
rc_halt "umount -f /dev/${PART}${EXT}"
|
58
|
|
59
|
# Re-check if we are missing a label for this device and create it again if so
|
60
|
if [ ! -e "/dev/label/${PARTLABEL}" ]
|
61
|
then
|
62
|
case ${PARTFS} in
|
63
|
UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
|
64
|
UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
|
65
|
UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;;
|
66
|
*) ;;
|
67
|
esac
|
68
|
fi
|
69
|
fi
|
70
|
|
71
|
# Check if we've found "/" and make sure the label exists
|
72
|
if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ]
|
73
|
then
|
74
|
if [ ! -e "/dev/label/${PARTLABEL}" ]
|
75
|
then
|
76
|
case ${PARTFS} in
|
77
|
UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
|
78
|
UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
|
79
|
UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;;
|
80
|
*) ;;
|
81
|
esac
|
82
|
fi
|
83
|
fi
|
84
|
done
|
85
|
|
86
|
# Last lets the /mnt partition
|
87
|
#########################################################
|
88
|
rc_nohalt "umount -f ${FSMNT}"
|
89
|
|
90
|
# If are using a ZFS on "/" set it to legacy
|
91
|
if [ ! -z "${FOUNDZFSROOT}" ]
|
92
|
then
|
93
|
rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
|
94
|
fi
|
95
|
|
96
|
# If we need to relabel "/" do it now
|
97
|
if [ ! -z "${ROOTRELABEL}" ]
|
98
|
then
|
99
|
${ROOTRELABEL}
|
100
|
fi
|
101
|
|
102
|
# Unmount our CDMNT
|
103
|
rc_nohalt "umount -f ${CDMNT}"
|
104
|
|
105
|
# Check if we need to run any gmirror syncing
|
106
|
ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
|
107
|
if [ "$?" = "0" ]
|
108
|
then
|
109
|
# Lets start syncing now
|
110
|
start_gmirror_sync
|
111
|
fi
|
112
|
|
113
|
# Import any pools, so they are active at shutdown and ready to boot potentially
|
114
|
zpool import -a
|
115
|
|
116
|
};
|
117
|
|
118
|
# Unmounts any filesystems after a failure
|
119
|
unmount_all_filesystems_failure()
|
120
|
{
|
121
|
cd /
|
122
|
|
123
|
# if we did a fresh install, start unmounting
|
124
|
if [ "${INSTALLMODE}" = "fresh" ]
|
125
|
then
|
126
|
|
127
|
# Lets read our partition list, and unmount each
|
128
|
##################################################################
|
129
|
if [ -d "${PARTDIR}" ]
|
130
|
then
|
131
|
for PART in `ls ${PARTDIR}`
|
132
|
do
|
133
|
|
134
|
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
|
135
|
PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
|
136
|
PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
|
137
|
|
138
|
#if [ "${PARTFS}" = "SWAP" ]
|
139
|
#then
|
140
|
# if [ "${PARTENC}" = "ON" ]
|
141
|
# then
|
142
|
# rc_nohalt "swapoff /dev/${PART}.eli"
|
143
|
# else
|
144
|
# rc_nohalt "swapoff /dev/${PART}"
|
145
|
# fi
|
146
|
#fi
|
147
|
|
148
|
# Check if we've found "/" again, don't need to mount it twice
|
149
|
if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
|
150
|
then
|
151
|
rc_nohalt "umount -f /dev/${PART}"
|
152
|
rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
|
153
|
fi
|
154
|
done
|
155
|
|
156
|
# Last lets the /mnt partition
|
157
|
#########################################################
|
158
|
rc_nohalt "umount -f ${FSMNT}"
|
159
|
|
160
|
fi
|
161
|
else
|
162
|
# We are doing a upgrade, try unmounting any of these filesystems
|
163
|
chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} >>${LOGOUT}
|
164
|
umount -f ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT}
|
165
|
umount -f ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT}
|
166
|
umount -f ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
|
167
|
rc_nohalt "sh ${TMPDIR}/.upgrade-unmount"
|
168
|
fi
|
169
|
|
170
|
# Unmount our CDMNT
|
171
|
rc_nohalt "umount ${CDMNT}"
|
172
|
|
173
|
# Import any pools, so they are active at shutdown and ready to boot potentially
|
174
|
zpool import -a
|
175
|
};
|