20 lines
536 B
Bash
Executable file
20 lines
536 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# ramdl_server <mountpoint> <size>
|
|
|
|
ramdl_script() {
|
|
printf "Creating ramdisk at %s of size %s\n" "$1" "$2"
|
|
mkdir -p "$1" || exit 1
|
|
chown root:root "$1" || exit 1
|
|
mount -t ramfs -o size="$2" "ramdl_disk" "$1" || exit 1
|
|
printf "Creating swapfile\n"
|
|
dd if=/dev/zero of="$1/ramdl" bs="$2" count=1 || exit 1
|
|
printf "Setting permissions\n"
|
|
chmod -R 777 "$1" || 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
|