rc: small tweaks

This commit is contained in:
Franco Fichtner 2018-05-28 08:40:57 +02:00
parent 426acedf52
commit 52d55ff5a3

View File

@ -111,6 +111,16 @@ timeout_prompt()
return ${RETURN}
}
zfs_load()
{
# we need to load ZFS to list pools
if kldstat -qm zfs; then
export ZFS="yes"
else
kldload zfs
fi
}
probe_for_part()
{
DEV=${1}
@ -124,11 +134,6 @@ probe_for_part()
export PART="/dev/${DEV}p3"
return 0
elif [ "${DEV}" = "zroot" ]; then
if kldstat -qm zfs; then
export ZFS="yes"
else
kldload zfs
fi
if zpool import | awk '{ print $1 " " $2 }' | grep -q "${DEV} ONLINE"; then
export POOL="${DEV}"
return 0
@ -142,6 +147,8 @@ DEVS=
PART=
if [ -n "${1}" ]; then
zfs_load
if ! probe_for_part ${1}; then
echo "No previous configuration was found on this device."
bootstrap_and_exit 1
@ -159,6 +166,8 @@ else
fi
fi
zfs_load
DEVS=$(camcontrol devlist; gmirror status -s; graid status -s)
fi
@ -197,8 +206,8 @@ elif [ -n "${POOL}" ]; then
echo "Starting import for ZFS pool '${POOL}'."
echo
if ! zpool import -f -R /tmp/hdrescue ${POOL} && \
zfs mount ${POOL}/ROOT/default; then
zpool import -f -R /tmp/hdrescue ${POOL};
if ! zfs mount ${POOL}/ROOT/default; then
echo "The device could not be mounted."
fi
fi