feat: improve the Justfile/mount-tool a bit.
This commit is contained in:
parent
56bc015b7a
commit
1dfd27f6ae
3 changed files with 58 additions and 24 deletions
5
Justfile
5
Justfile
|
|
@ -4,7 +4,10 @@ build:
|
||||||
docker buildx build --pull --platform linux/amd64 -t "forge.lys.ee/lyssieth/rave:amd64" --load .
|
docker buildx build --pull --platform linux/amd64 -t "forge.lys.ee/lyssieth/rave:amd64" --load .
|
||||||
|
|
||||||
mount:
|
mount:
|
||||||
bash ./mount.sh
|
bash ./mount-tool.sh mount
|
||||||
|
|
||||||
|
unmount:
|
||||||
|
bash ./mount-tool.sh unmount
|
||||||
|
|
||||||
run: mount
|
run: mount
|
||||||
RAVE_STORAGE_DIR=/tmp/media-for-rave cargo r
|
RAVE_STORAGE_DIR=/tmp/media-for-rave cargo r
|
||||||
|
|
|
||||||
54
mount-tool.sh
Executable file
54
mount-tool.sh
Executable file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail # exit on error
|
||||||
|
|
||||||
|
# check for `fuse-overlayfs` executable
|
||||||
|
if ! command -v fuse-overlayfs &>/dev/null; then
|
||||||
|
echo "fuse-overlayfs could not be found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function mount_rave {
|
||||||
|
# check if already mounted; im /tmp so it's ephemeral
|
||||||
|
if [ -d /tmp/media-for-rave ]; then exit 0; fi
|
||||||
|
|
||||||
|
# mount the music directory; assumes a fstab entry like:
|
||||||
|
# /dev/sda1 /mnt/Media ext4 defaults 0 0
|
||||||
|
# or equivalent; as long as it mounts to /mnt/Media
|
||||||
|
sudo mount /mnt/Media
|
||||||
|
|
||||||
|
# create the overlayfs
|
||||||
|
mkdir -p /tmp/overlay /tmp/work /tmp/media-for-rave
|
||||||
|
|
||||||
|
# mount the overlayfs
|
||||||
|
fuse-overlayfs -o lowerdir=/mnt/Media/Music -o upperdir=/tmp/overlay -o workdir=/tmp/work /tmp/media-for-rave
|
||||||
|
}
|
||||||
|
|
||||||
|
function unmount_rave {
|
||||||
|
# check if already unmounted
|
||||||
|
if [ ! -d /tmp/media-for-rave ]; then exit 0; fi
|
||||||
|
|
||||||
|
# unmount the overlayfs
|
||||||
|
umount /tmp/media-for-rave || true
|
||||||
|
|
||||||
|
# clean up the overlayfs if `CLEAN` is set
|
||||||
|
if [ "${CLEAN:-}" = "true" ]; then
|
||||||
|
rm -rf /tmp/overlay /tmp/work /tmp/media-for-rave
|
||||||
|
fi
|
||||||
|
|
||||||
|
# unmount the music directory
|
||||||
|
sudo umount /mnt/Media || true
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
mount)
|
||||||
|
mount_rave
|
||||||
|
;;
|
||||||
|
unmount)
|
||||||
|
unmount_rave
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {mount|unmount}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
23
mount.sh
23
mount.sh
|
|
@ -1,23 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail # exit on error
|
|
||||||
|
|
||||||
# check for `fuse-overlayfs` executable
|
|
||||||
if ! command -v fuse-overlayfs &>/dev/null; then
|
|
||||||
echo "fuse-overlayfs could not be found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check if already mounted; im /tmp so it's ephemeral
|
|
||||||
if [ -d /tmp/media-for-rave ]; then exit 0; fi
|
|
||||||
|
|
||||||
# mount the music directory; assumes a fstab entry like:
|
|
||||||
# /dev/sda1 /mnt/Media ext4 defaults 0 0
|
|
||||||
# or equivalent; as long as it mounts to /mnt/Media
|
|
||||||
sudo mount /mnt/Media
|
|
||||||
|
|
||||||
# create the overlayfs
|
|
||||||
mkdir -p /tmp/overlay /tmp/work /tmp/media-for-rave
|
|
||||||
|
|
||||||
# mount the overlayfs
|
|
||||||
fuse-overlayfs -o lowerdir=/mnt/Media/Music -o upperdir=/tmp/overlay -o workdir=/tmp/work /tmp/media-for-rave
|
|
||||||
Loading…
Reference in a new issue