trios/scripts/mount.sh
2023-04-28 19:17:17 -04:00

22 lines
348 B
Bash
Executable file

#!/bin/sh
DISK=disk.img
MOUNTPOINT=mnt
OFFSET=1048576
if [ "$(id -u)" -ne 0 ]; then
echo "must be root"
exit 1
fi
if mountpoint "$MOUNTPOINT" >/dev/null; then
echo "unmounting"
umount "$MOUNTPOINT"
losetup -D "$DISK"
else
echo "mounting"
LOOPDEV="$(losetup -f)"
losetup "$LOOPDEV" "$DISK" -o "$OFFSET"
mount "$LOOPDEV" "$MOUNTPOINT"
fi