From eb700d39cca1ee44bbd9a832519b8ca8ab260daa Mon Sep 17 00:00:00 2001 From: Carlos Aldana Date: Thu, 10 Jul 2025 13:48:05 -0700 Subject: [PATCH] updates fstab script --- common/add-nfs-mounts.sh | 39 ++++++++++++++++++++++++++++++++++++++- common/fstab | 22 ++++++++++++---------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/common/add-nfs-mounts.sh b/common/add-nfs-mounts.sh index e281fa6..45bcd32 100644 --- a/common/add-nfs-mounts.sh +++ b/common/add-nfs-mounts.sh @@ -1,7 +1,44 @@ -cat fstab | sudo tee -a /etc/fstab +#!/bin/bash + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# cat fstab | sudo tee -a /etc/fstab sudo mkdir /kpnas cd /kpnas sudo mkdir videos vfx library localData web videos cd ~/ mkdir fabrication projects Remote + +# Change to the script's directory +cd "$script_dir" || exit +# Now you are in the script's directory +echo "Current directory: $(pwd)" + +# Path to the file containing fstab entries +entries_file="fstab" + +if [[ ! -f "$entries_file" ]]; then + echo "Entries file '$entries_file' not found." + exit 1 +fi + +# Backup the original fstab file +# cp /etc/fstab /etc/fstab.bak +# Function to check if an entry exists in fstab +entry_exists() { + local entry="$1" + grep -qF -- "$entry" /etc/fstab +} +# Read entries from the file and add them if they don't exist +while IFS= read -r entry; do + # Skip empty lines or lines starting with # + [[ -z "$entry" || "$entry" =~ ^# ]] && continue + if entry_exists "$entry"; then + echo "Entry already exists: $entry" + else + echo "Adding entry: $entry" + echo "$entry" | sudo tee -a /etc/fstab >/dev/null + fi +done <"$entries_file" +echo "Done." diff --git a/common/fstab b/common/fstab index b6e3306..9a76156 100644 --- a/common/fstab +++ b/common/fstab @@ -1,10 +1,12 @@ -192.168.86.50:/Carlos/Documents /home/carlos/Documents nfs nofail 0 2 -192.168.86.50:/Carlos/Images /home/carlos/Pictures nfs nofail 0 2 -192.168.86.50:/Fabrication /home/carlos/fabrication nfs nofail 0 2 -192.168.86.50:/Projects /home/carlos/projects nfs nofail 0 2 -192.168.86.50:/Carlos /home/carlos/Remote nfs nofail 0 2 -192.168.86.50:/Library /kpnas/library nfs nofail 0 2 -192.168.86.50:/LocalData /kpnas/localData nfs nofail 0 2 -192.168.86.50:/VFX /kpnas/vfx nfs nofail 0 2 -192.168.86.50:/Videos /kpnas/videos nfs nofail 0 2 -192.168.86.50:/Web /kpnas/web nfs nofail 0 2 +kp-server:/mnt/data /kpnas/data nfs nofail 0 2 +192.168.86.50:/Library /kpnas/library nfs nofail 0 2 +192.168.86.50:/LocalData /kpnas/localData nfs nofail 0 2 +192.168.86.50:/Media /kpnas/media nfs nofail 0 2 +192.168.86.50:/NVME /kpnas/nvme nfs nofail 0 2 +192.168.86.50:/Videos /kpnas/videos nfs nofail 0 2 +192.168.86.50:/VFX /kpnas/vfx nfs nofail 0 2 +192.168.86.50:/Web /kpnas/web nfs nofail 0 2 +192.168.86.50:/Carlos/Images /home/carlos/Pictures nfs nofail 0 2 +192.168.86.50:/Fabrication /home/carlos/fabrication nfs nofail 0 2 +192.168.86.50:/Projects /home/carlos/projects nfs nofail 0 2 +