Files
HomeLabScripts/nfs/nfsSlowData.sh

53 lines
1.4 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.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ==== Standardwerte direkt im Skript definieren ====
DEFAULT_EXPORT_PATH="/slowData"
DEFAULT_SUBNET="192.168.178.0/24"
# ==== Übergabeparameter auswerten ====
while [[ $# -gt 0 ]]; do
case "$1" in
--path)
EXPORT_PATH="$2"
shift 2
;;
--subnet)
SUBNET="$2"
shift 2
;;
*)
echo "❌ Unbekannter Parameter: $1"
exit 1
;;
esac
done
# ==== Fallback auf Standardwerte ====
EXPORT_PATH="${EXPORT_PATH:-$DEFAULT_EXPORT_PATH}"
SUBNET="${SUBNET:-$DEFAULT_SUBNET}"
# ==== Interaktive Nachfrage, falls dennoch leer ====
[[ -z "$EXPORT_PATH" ]] && read -rp "Pfad des freizugebenden Ordners: " EXPORT_PATH
[[ -z "$SUBNET" ]] && read -rp "Subnetz (z.B. 192.168.178.0/24): " SUBNET
# ==== Ordner vorbereiten ====
sudo mkdir -p "$EXPORT_PATH"
sudo chmod 777 "$EXPORT_PATH"
# ==== Export konfigurieren ====
EXPORT_LINE="$EXPORT_PATH $SUBNET(rw,sync,no_subtree_check,no_root_squash)"
EXPORTS_FILE="/etc/exports"
if ! grep -Fxq "$EXPORT_LINE" "$EXPORTS_FILE"; then
echo "$EXPORT_LINE" | sudo tee -a "$EXPORTS_FILE"
echo "✅ Export wurde hinzugefügt."
else
echo " Export existiert bereits."
fi
# ==== NFS-Dienst neu laden ====
sudo exportfs -ra
sudo systemctl restart nfs-server
echo "✅ NFS-Share aktiv: $EXPORT_PATH$SUBNET (777-Rechte)"