Files
HomeLabScripts/nfs/client.sh

28 lines
1.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ───── Interaktive Abfragen ─────
read -p "🔌 IP-Adresse des NFS-Servers: " SERVER_IP
read -p "📁 Remote-Pfad auf dem Server (z.B. /srv/nfs/share): " REMOTE_PATH
read -p "📂 Lokaler Mountpunkt auf diesem Client (z.B. /mnt/nfs_share): " LOCAL_MOUNT
# ───── NFS-Client installieren (für Debian/Ubuntu) ─────
echo "📦 Installiere NFS-Client (falls nötig)..."
apt update && apt install -y nfs-common
# ───── Lokales Verzeichnis vorbereiten ─────
if [ ! -d "$LOCAL_MOUNT" ]; then
echo "📁 Erstelle lokalen Mountpunkt: $LOCAL_MOUNT"
mkdir -p "$LOCAL_MOUNT"
fi
# ───── Mount-Versuch ─────
echo "🔗 Versuche, $SERVER_IP:$REMOTE_PATH nach $LOCAL_MOUNT zu mounten..."
mount -t nfs "$SERVER_IP:$REMOTE_PATH" "$LOCAL_MOUNT"
# ───── Erfolg prüfen ─────
if mountpoint -q "$LOCAL_MOUNT"; then
echo "✅ Share erfolgreich gemountet unter $LOCAL_MOUNT"
else
echo "❌ Mountvorgang fehlgeschlagen."
fi