commit: 2a095a3301c0a81381cc1ae3f11e9871e9baeb8d
parent 133c05426c2133c60bdb0b42c1dda64b3bc6bb7d
Author: Gábor Stefanik <netrolller.3d@gmail.com>
Date: Mon, 1 Jan 2024 23:36:13 +0100
After bootstrap, drop to a shell if needed, then shut down cleanly
Diffstat:
3 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/steps/improve/after.sh b/steps/improve/after.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# After bootstrap, drop to a shell if needed, then shut down cleanly.
+
+. /steps/bootstrap.cfg
+. /steps/env
+
+if [ "${INTERACTIVE}" = True ]; then
+ env - PATH=${PREFIX}/bin PS1="\w # " bash -i
+fi
+
+if [ "${CHROOT}" = False ]; then
+ # ignore errors due to fstab or swapfile not existing
+ swapoff -a &> /dev/null || true
+ sync
+ # sysrq to avoid device busy; then mount to wait for it to finish
+ echo u > /proc/sysrq_trigger
+ mount -o remount,ro /
+ echo o > /proc/sysrq_trigger # power off
+fi
diff --git a/steps/jump/move_disk.sh b/steps/jump/move_disk.sh
@@ -27,5 +27,6 @@ mkdir -p /rootonly
# This doesn't recursively mount - that's why we're able to copy everything over
mount --bind / /rootonly
cp -ar /rootonly/* /newroot/
+sed -e 's/newroot//' /rootonly/etc/mtab | grep -v 'rootonly' > /newroot/etc/mtab
umount /rootonly
switch_root /newroot /init
diff --git a/steps/manifest b/steps/manifest
@@ -182,3 +182,4 @@ build: binutils-2.41
build: gcc-13.1.0
improve: null_time ( FORCE_TIMESTAMPS == True )
improve: update_checksums ( UPDATE_CHECKSUMS == True )
+improve: after