unload-chroot.sh hinzugefügt
Signed-off-by: hax <hax@lainlounge.xyz>
This commit is contained in:
parent
cdb0a854e6
commit
ccf2d2ac72
1 changed files with 47 additions and 0 deletions
47
unload-chroot.sh
Normal file
47
unload-chroot.sh
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
# Path to the variables log file
|
||||||
|
VARIABLES_LOG="/rescue/variables.log"
|
||||||
|
|
||||||
|
# Check if variables log file exists
|
||||||
|
if [ ! -f "$VARIABLES_LOG" ]; then
|
||||||
|
echo "❌ No variables log file found. Aborting unmount."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read the variables from the log file and convert them to shell format
|
||||||
|
partition=$(sed -n 's/^partition="\([^"]*\)"/\1/p' "$VARIABLES_LOG")
|
||||||
|
efi=$(sed -n 's/^efi="\([^"]*\)"/\1/p' "$VARIABLES_LOG")
|
||||||
|
home=$(sed -n 's/^home="\([^"]*\)"/\1/p' "$VARIABLES_LOG")
|
||||||
|
|
||||||
|
# Check if necessary variables are loaded
|
||||||
|
if [ -z "$partition" ] || [ -z "$efi" ] || [ -z "$home" ]; then
|
||||||
|
echo "❌ Missing variables. Please ensure the script was run previously with valid variables."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Unmount the partitions and resources in reverse order of mounting
|
||||||
|
|
||||||
|
echo "Unmounting /rescue/run..."
|
||||||
|
umount /rescue/run || true
|
||||||
|
echo "Unmounting /rescue/dev/pts..."
|
||||||
|
umount /rescue/dev/pts || true
|
||||||
|
echo "Unmounting /rescue/dev..."
|
||||||
|
umount /rescue/dev || true
|
||||||
|
echo "Unmounting /rescue/sys..."
|
||||||
|
umount /rescue/sys || true
|
||||||
|
echo "Unmounting /rescue/proc..."
|
||||||
|
umount /rescue/proc || true
|
||||||
|
echo "Unmounting /rescue/home..."
|
||||||
|
umount /rescue/home || true
|
||||||
|
echo "Unmounting /rescue/boot..."
|
||||||
|
umount /rescue/boot || true
|
||||||
|
echo "Unmounting /rescue..."
|
||||||
|
umount /rescue || true
|
||||||
|
|
||||||
|
# Optional: clean up the /rescue directory after unmounting
|
||||||
|
echo "Removing /rescue directory (if needed)..."
|
||||||
|
rmdir /rescue || true
|
||||||
|
|
||||||
|
echo "✅ All partitions and resources have been unmounted and cleaned up."
|
||||||
Loading…
Add table
Reference in a new issue