22 lines
348 B
Bash
Executable file
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
|