Files
linux-setup/common/add-nfs-mounts.sh
2026-01-07 19:05:59 -08:00

44 lines
1.0 KiB
Bash

#!/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 server
# Change to the script's directory
cd "$script_dir" || exit
# Now you are in the script's directory
# echo "Current directory: $(pwd)"
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."