Setup/4_DomainLogin.sh

71 lines
2.4 KiB
Bash
Executable File
Raw 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
# Sicherstellen, dass das Skript mit Root-Rechten ausgeführt wird
if [[ $EUID -ne 0 ]]; then
echo "❌ Dieses Skript muss als root ausgeführt werden."
exit 1
fi
read -p "❓ Soll SDDM so konfiguriert werden, dass Domänenbenutzer angezeigt werden? (j/n) [n]: " answer
answer=${answer,,} # In Kleinbuchstaben umwandeln
answer=${answer:-n} # Standardwert 'n', falls leer
if [[ "$answer" == "j" ]] || [[ "$answer" == "y" ]]; then
# SDDM-Konfigurationsdatei in sddm.conf.d erstellen
SDDM_CONF_DIR="/etc/sddm.conf.d"
SDDM_CUSTOM_CONF="$SDDM_CONF_DIR/ad_login.conf"
mkdir -p "$SDDM_CONF_DIR"
# SDDM-Konfigurationsdatei sichern
if [[ -f "$SDDM_CUSTOM_CONF" ]]; then
cp "$SDDM_CUSTOM_CONF" "$SDDM_CUSTOM_CONF.bak"
echo " SDDM-Konfigurationsdatei gesichert als $SDDM_CUSTOM_CONF.bak"
else
echo "⚠️ SDDM-Konfigurationsdatei nicht gefunden, keine Sicherung vorgenommen."
fi
# Bestehende Konfiguration sichern und anpassen
if [[ -f "$SDDM_CUSTOM_CONF" ]]; then
sed -i '/MaximumUid/d' "$SDDM_CUSTOM_CONF"
sed -i '/MinimumUid/d' "$SDDM_CUSTOM_CONF"
sed -i '/HideShells/d' "$SDDM_CUSTOM_CONF"
echo "MaximumUid=99999999999999999999" >>"$SDDM_CUSTOM_CONF"
echo "MinimumUid=1000" >>"$SDDM_CUSTOM_CONF"
echo "HideShells=/sbin/nologin,/bin/false,/usr/sbin/nologin" >>"$SDDM_CUSTOM_CONF"
else
cat <<EOF >"$SDDM_CUSTOM_CONF"
[Users]
MaximumUid=999999999999999999
MinimumUid=1000
HideShells=/sbin/nologin,/bin/false,/usr/sbin/nologin
EOF
fi
# SSSD-Konfiguration anpassen, falls die Datei existiert
SSSD_CONF="/etc/sssd/sssd.conf"
# SSSD-Konfigurationsdatei sichern
if [[ -f "$SSSD_CONF" ]]; then
cp "$SSSD_CONF" "$SSSD_CONF.bak"
echo " SSSD-Konfigurationsdatei gesichert als $SSSD_CONF.bak"
else
echo "⚠️ SSSD-Konfigurationsdatei nicht gefunden, keine Sicherung vorgenommen."
fi
if [[ -f "$SSSD_CONF" ]]; then
if grep -q "^enumerate" "$SSSD_CONF"; then
sed -i 's/^enumerate.*/enumerate = false/' "$SSSD_CONF"
else
echo "enumerate = false" >>"$SSSD_CONF"
fi
# Berechtigungen für SSSD-Konfigurationsdatei setzen
chmod 600 "$SSSD_CONF"
fi
# SSSD und SDDM neu starten
systemctl restart sssd
systemctl restart sddm
fi
echo "✅ Konfiguration von SDDM und sssd abgeschlossen!"