#!/bin/bash

# Lista de montajes
declare -A MOUNTS=(
  [downloads]="192.168.0.10:/volume1/downloads"
  [music]="192.168.0.10:/volume1/music"
  [library]="192.168.0.10:/volume1/library"
  [roms]="192.168.0.10:/volume1/roms"
  [software]="192.168.0.10:/volume1/software"
  [system]="192.168.0.10:/volume1/system"
  [maverick]="192.168.0.10:/volume1/maverick"
  [video]="192.168.0.10:/volume1/video"
  [backup]="192.168.0.10:/volume1/backup"
)

BASE="/sustancia"

# Comprobación de argumento
if [[ "$1" != "mount" && "$1" != "umount" ]]; then
  echo "Uso: $0 [mount|umount]"
  exit 1
fi

for name in "${!MOUNTS[@]}"; do
  local_path="$BASE/$name"
  remote_path="${MOUNTS[$name]}"

  if [[ "$1" == "mount" ]]; then
    echo "Montando $remote_path en $local_path..."
    sudo mkdir -p "$local_path"
    sudo mount -t nfs -o defaults,user,noatime "$remote_path" "$local_path"
  else
    echo "Desmontando $local_path..."
    sudo umount "$local_path"
  fi
done

echo "Operación '$1' completada."
