umorpha-boxes/pkg/umorpha-disk/mkinitcpio-hook

33 lines
936 B
Plaintext
Raw Permalink Normal View History

#!/hint/ash
# Copyright (C) 2023 Umorpha Systems
# SPDX-License-Identifier: AGPL-3.0-or-later
# args: errmsg
umorpha_emergency_shell() {
run_hookfunctions 'run_emergencyhook' 'emergency hook' $EMERGENCYHOOKS
err "$*"
echo "You are now being dropped into an emergency shell."
launch_interactive_shell
msg "Trying to continue (this will most likely fail) ..."
}
# args: /path/to/newroot
umorpha_mount_handler() {
local newroot="$1"
msg ":: mounting '$root'+'$overlay' on real root"
if ! umorpha-mount \
--root="$root:$rootfstype:ro${rootflags:+,$rootflags}" \
--overlay="$overlay:$overlayfstype:${rwopt:-ro}${overlayflags:+,$overlayrootflags}" \
${boot:+--boot="$boot:$bootfstype:${rwopt:-ro}${bootflags:+,$bootflags}"} \
2023-12-25 21:50:54 +00:00
--basedir=/run/umorpha-root \
--final-mountpoint="$newroot"
then
umorpha_emergency_shell "Failed to mount base filesystem"
fi
}
run_hook() {
export mount_handler='umorpha_mount_handler'
}