2020-07-11 18:13:20 +02:00
|
|
|
#!/bin/ash
|
2010-12-01 02:16:19 +01:00
|
|
|
|
|
|
|
run_hook () {
|
2020-07-11 18:13:20 +02:00
|
|
|
# shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
|
|
|
|
[ -n "${img_label}" ] && img_dev="/dev/disk/by-label/${img_label}"
|
|
|
|
[ -z "${img_flags}" ] && img_flags="defaults"
|
|
|
|
# shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
|
|
|
|
if [ -n "${img_dev}" ] && [ -n "${img_loop}" ]; then
|
|
|
|
export mount_handler="archiso_loop_mount_handler"
|
2010-12-01 02:16:19 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
archiso_loop_mount_handler () {
|
|
|
|
newroot="${1}"
|
|
|
|
|
2012-01-10 00:33:35 +01:00
|
|
|
local _dev_loop
|
|
|
|
|
2011-10-24 02:24:17 +02:00
|
|
|
msg ":: Setup a loop device from ${img_loop} located at device ${img_dev}"
|
2016-02-02 15:45:48 +01:00
|
|
|
_mnt_dev "${img_dev}" "/run/archiso/img_dev" "-r" "${img_flags}"
|
2020-07-11 18:13:20 +02:00
|
|
|
# shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
|
|
|
|
if [ "${copytoram}" != "y" ]; then
|
|
|
|
readlink -f "${img_dev}" >> /run/archiso/used_block_devices
|
2012-02-22 23:41:32 +01:00
|
|
|
fi
|
2011-10-24 02:24:17 +02:00
|
|
|
|
2015-08-30 00:39:41 +02:00
|
|
|
if _dev_loop=$(losetup --find --show --read-only "/run/archiso/img_dev/${img_loop}"); then
|
2020-07-11 18:13:20 +02:00
|
|
|
export archisodevice="${_dev_loop}"
|
2015-08-30 00:39:41 +02:00
|
|
|
else
|
2012-01-10 00:33:35 +01:00
|
|
|
echo "ERROR: Setting loopback device for file '/run/archiso/img_dev/${img_loop}'"
|
2010-12-08 18:44:48 +01:00
|
|
|
launch_interactive_shell
|
2010-12-01 02:16:19 +01:00
|
|
|
fi
|
|
|
|
|
2020-07-11 18:13:20 +02:00
|
|
|
archiso_mount_handler "${newroot}"
|
2010-12-01 02:16:19 +01:00
|
|
|
|
2020-07-11 18:13:20 +02:00
|
|
|
if [ "${copytoram}" = "y" ]; then
|
|
|
|
losetup -d "${_dev_loop}" 2>/dev/null
|
2011-10-24 02:24:17 +02:00
|
|
|
umount /run/archiso/img_dev
|
2010-12-01 02:16:19 +01:00
|
|
|
fi
|
|
|
|
}
|
2020-07-11 18:13:20 +02:00
|
|
|
|
|
|
|
# vim: set ft=sh:
|