[archiso] Add a new function _mnt_dev(), use it for mounting archisodevice.
Separate this code from main mount hook, and make it more generic. _mnt_dev(device, mountpoint, flags) -> wait for device and mount, launch a shell if something goes wrong. Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
This commit is contained in:
parent
18d7493530
commit
91e11c30f4
@ -76,6 +76,44 @@ _mnt_sfs() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args: device, mountpoint, flags
|
||||||
|
_mnt_dev() {
|
||||||
|
local dev="${1}"
|
||||||
|
local mnt="${2}"
|
||||||
|
local flg="${3}"
|
||||||
|
|
||||||
|
local fstype fserror
|
||||||
|
|
||||||
|
msg ":: Mounting '${dev}' to '${mnt}'"
|
||||||
|
|
||||||
|
while ! poll_device "${dev}" 30; do
|
||||||
|
echo "ERROR: '${dev}' device did not show up after 30 seconds..."
|
||||||
|
echo " Falling back to interactive prompt"
|
||||||
|
echo " You can try to fix the problem manually, log out when you are finished"
|
||||||
|
launch_interactive_shell
|
||||||
|
done
|
||||||
|
|
||||||
|
fstype=$(blkid -o value -s TYPE -p "${dev}" 2> /dev/null)
|
||||||
|
if [[ -n "${fstype}" ]]; then
|
||||||
|
if mount ${flg} -t "${fstype}" "${dev}" "${mnt}"; then
|
||||||
|
msg ":: Device '${dev}' mounted successfully."
|
||||||
|
fserror=0
|
||||||
|
else
|
||||||
|
echo "ERROR; Failed to mount '${dev}' (FS is ${fstype})"
|
||||||
|
fserror=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "ERROR: '${dev}' found, but the filesystem type is unknown."
|
||||||
|
fserror=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${fserror} -eq 1 ]]; then
|
||||||
|
echo " Falling back to interactive prompt"
|
||||||
|
echo " You can try to fix the problem manually, log out when you are finished"
|
||||||
|
launch_interactive_shell
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_verify_checksum() {
|
_verify_checksum() {
|
||||||
local _status
|
local _status
|
||||||
cd "/bootmnt/${archisobasedir}"
|
cd "/bootmnt/${archisobasedir}"
|
||||||
@ -85,7 +123,6 @@ _verify_checksum() {
|
|||||||
return ${_status}
|
return ${_status}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
run_hook() {
|
run_hook() {
|
||||||
modprobe loop
|
modprobe loop
|
||||||
|
|
||||||
@ -109,38 +146,12 @@ run_hook() {
|
|||||||
# args: /path/to/newroot
|
# args: /path/to/newroot
|
||||||
archiso_mount_handler() {
|
archiso_mount_handler() {
|
||||||
local newroot="${1}"
|
local newroot="${1}"
|
||||||
local fstype fserror
|
|
||||||
|
|
||||||
_init_loop_dev
|
_init_loop_dev
|
||||||
|
|
||||||
msg ":: Waiting for boot device..."
|
_mnt_dev "${archisodevice}" "/bootmnt" "-r"
|
||||||
while ! poll_device "${archisodevice}" 30; do
|
if [[ ! -f "${aitab}" ]]; then
|
||||||
echo "ERROR: boot device didn't show up after 30 seconds..."
|
echo "ERROR: '${aitab}' file does not exist."
|
||||||
echo " Falling back to interactive prompt"
|
|
||||||
echo " You can try to fix the problem manually, log out when you are finished"
|
|
||||||
launch_interactive_shell
|
|
||||||
done
|
|
||||||
|
|
||||||
fstype=$(blkid -o value -s TYPE -p "${archisodevice}" 2> /dev/null)
|
|
||||||
if [[ -n "${fstype}" ]]; then
|
|
||||||
if mount -r -t "${fstype}" "${archisodevice}" /bootmnt; then
|
|
||||||
if [[ -f "${aitab}" ]]; then
|
|
||||||
msg ":: Mounted archiso volume successfully."
|
|
||||||
fserror=0
|
|
||||||
else
|
|
||||||
echo "ERROR: Mounting was successful, but the '${aitab}' file does not exist."
|
|
||||||
fserror=1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "ERROR; Failed to mount '${archisodevice}' (FS is ${fstype})"
|
|
||||||
fserror=1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "ERROR: '${archisodevice}' found, but the filesystem type is unknown."
|
|
||||||
fserror=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${fserror} -eq 1 ]]; then
|
|
||||||
echo " Falling back to interactive prompt"
|
echo " Falling back to interactive prompt"
|
||||||
echo " You can try to fix the problem manually, log out when you are finished"
|
echo " You can try to fix the problem manually, log out when you are finished"
|
||||||
launch_interactive_shell
|
launch_interactive_shell
|
||||||
|
Loading…
Reference in New Issue
Block a user