pilpil-img-tool/umount_img.sh

26 lines
529 B
Bash
Raw Permalink Normal View History

2023-01-17 16:07:52 +01:00
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
cd "$(dirname "$0")"
if [[ -z "${1-}" ]] || [[ ! -e "${1}" ]]; then
echo "Missing or non-existent loop device path."
exit
fi
if [[ ! $(findmnt -M "./rootfs") ]]; then
echo "Not mounted, aborting."
exit
fi
echo "Unmounting FSes..."
sudo umount ./rootfs/boot/
sudo umount ./rootfs/sys/
sudo umount ./rootfs/dev/pts
sudo umount ./rootfs/dev/
sudo umount ./rootfs/proc/
sudo umount ./rootfs/
echo "Detaching loop setup..."
sudo losetup -d "${1}"