33 lines
		
	
	
		
			936 B
		
	
	
	
		
			Bash
		
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			936 B
		
	
	
	
		
			Bash
		
	
	
	
| #!/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}"} \
 | |
| 		--basedir=/run/umorpah-root \
 | |
| 		--final-mountpoint="$newroot"
 | |
| 	then
 | |
| 		umorpha_emergency_shell "Failed to mount base filesystem"
 | |
| 	fi
 | |
| }
 | |
| 
 | |
| run_hook() {
 | |
| 	export mount_handler='umorpha_mount_handler'
 | |
| }
 |