ramdl/ramdl

22 lines
524 B
Text
Raw Permalink Normal View History

2023-04-05 17:59:22 +00:00
#!/bin/sh
# ramdl <user@host:path> <mountpoint>
ramdl_script() {
printf "Mounting sshfs at '%s' to '%s'\n" "$1" "$2"
sshfs "$1" "$2" || exit 1
printf "Making swap\n"
mkswap "$2"/ramdl || exit 1
printf "Making loopback device\n"
losetup -f "$2"/ramdl || exit 1
loopdev="$(losetup -j "$2"/ramdl | cut -d":" -f1)"
printf "Swapping\n"
swapon "$loopdev" || exit 1
}
if [ "$#" -eq 2 ]; then
ramdl_script "$1" "$2" || (printf "Failure\n"; exit 1) && printf "Success\n"
else
printf "Wrong argument count\n"; exit 1
fi