#!/bin/sh

# Variables
MOUNT_POINT="/media"
SIZE="250M"

# Check if a RAM disk is already mounted at the mount point
if mountpoint -q "$MOUNT_POINT"; then
	echo "RAM disk is already mounted at $MOUNT_POINT."
	exit 0
else
	echo "No RAM disk detected at $MOUNT_POINT."
fi

# Mount the RAM disk
echo "Mounting a $SIZE RAM disk at $MOUNT_POINT"
mount -t tmpfs -o size=$SIZE tmpfs "$MOUNT_POINT"

# Check if the mount was successful
if mountpoint -q "$MOUNT_POINT"; then
	echo "RAM disk successfully mounted at $MOUNT_POINT with size $SIZE"
else
	echo "Failed to mount RAM disk."
	exit 1
fi

# Copy files to mount point 
cp /home/* "$MOUNT_POINT"

# Display the disk usage
df -h "$MOUNT_POINT"
