22 lines
524 B
Bash
Executable file
22 lines
524 B
Bash
Executable file
#!/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
|