#!/bin/bash

# Script to copy web files to SD card system directory
# Make sure your SD card is mounted and accessible

# Set your SD card mount point here (adjust as needed)
SD_MOUNT_POINT="/media/$USER/SD_CARD"  # Common Linux mount point
# Alternative mount points you might need to try:
# SD_MOUNT_POINT="/mnt/sd"
# SD_MOUNT_POINT="/media/sd"

echo "Copying web files to SD card system directory..."

# Check if SD card is mounted
if [ ! -d "$SD_MOUNT_POINT" ]; then
    echo "Error: SD card not found at $SD_MOUNT_POINT"
    echo "Please adjust SD_MOUNT_POINT in this script to match your SD card mount point"
    echo "Common mount points:"
    echo "  /media/\$USER/SD_CARD"
    echo "  /mnt/sd"
    echo "  /media/sd"
    exit 1
fi

# Create system directory if it doesn't exist
mkdir -p "$SD_MOUNT_POINT/system"

# Copy files
echo "Copying style.css..."
cp web/style.css "$SD_MOUNT_POINT/system/"

echo "Copying script.js..."
cp web/script.js "$SD_MOUNT_POINT/system/"

echo "Copying index.html..."
cp web/index.html "$SD_MOUNT_POINT/system/"

echo "Files copied successfully!"
echo "Your SD card system directory now contains:"
ls -la "$SD_MOUNT_POINT/system/"

echo ""
echo "Memory optimization complete! The web files are now served from SD card instead of RAM."
