Setup/0_Setup.sh

126 lines
4.2 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
# Root-Rechte prüfen
if [ "$(id -u)" -ne 0 ]; then
echo "❌ Bitte als root ausführen!"
exit 1
fi
apt update && apt upgrade -y
apt install -y git sudo 7zip unrar unzip network-manager software-properties-common tree bluetooth wget curl
# GRUB-Config
read -p "❓ Soll GRUB so konfiguriert werden, dass es nur im Fehlerfall angezeigt wird? (j/n) [n]: " answer
answer=${answer,,} # In Kleinbuchstaben umwandeln
answer=${answer:-n} # Standardwert 'n', falls leer
if [[ "$answer" == "j" ]] || [[ "$answer" == "y" ]]; then
echo " GRUB wird so konfiguriert, dass es nur im Fehlerfall angezeigt wird..."
# Sicherstellen, dass die Datei existiert
GRUB_CFG="/etc/default/grub"
if [[ ! -f "$GRUB_CFG" ]]; then
echo "❌ Fehler: $GRUB_CFG nicht gefunden!"
else
# Backup der aktuellen GRUB-Konfiguration
cp "$GRUB_CFG" "$GRUB_CFG.bak"
# Konfigurationsänderungen vornehmen
sed -i 's/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=0/' "$GRUB_CFG"
sed -i 's/^GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT_STYLE=hidden/' "$GRUB_CFG"
# Falls die Einträge nicht existieren, hinzufügen
grep -q '^GRUB_TIMEOUT=' "$GRUB_CFG" || echo 'GRUB_TIMEOUT=0' >> "$GRUB_CFG"
grep -q '^GRUB_TIMEOUT_STYLE=' "$GRUB_CFG" || echo 'GRUB_TIMEOUT_STYLE=hidden' >> "$GRUB_CFG"
# GRUB-Konfiguration aktualisieren
update-grub
echo "✅ GRUB wurde erfolgreich angepasst. Änderungen werden beim nächsten Boot wirksam."
fi
fi
# sbin in Path
read -p "❓ Soll sbin für sudo-Nutzer in den PATH aufgenommen werden? (j/n) [n]: " answer
answer=${answer,,} # In Kleinbuchstaben umwandeln
answer=${answer:-n} # Standardwert 'n', falls leer
if [[ "$answer" == "j" ]] || [[ "$answer" == "y" ]]; then
cat << 'EOF' > /etc/profile.d/sbin_in_path.sh
if groups | grep -q "\bsudo\b"; then
case ":$PATH:" in
*":/sbin:"*) ;;
*) export PATH="$PATH:/sbin" ;;
esac
case ":$PATH:" in
*":/usr/sbin:"*) ;;
*) export PATH="$PATH:/usr/sbin" ;;
esac
fi
EOF
echo " sbin wurde zum PATH für sudo-Nutzer hinzugefügt."
fi
# sudo-Hinweis
read -p "❓ Soll ein sudo-Hinweis hinzugefügt werden? (j/n) [n]: " answer
answer=${answer,,} # In Kleinbuchstaben umwandeln
answer=${answer:-n} # Standardwert 'n', falls leer
if [[ "$answer" == "j" ]] || [[ "$answer" == "y" ]]; then
cat << 'EOF' > /etc/profile.d/sudo_hint.sh
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
case " $(groups) " in *\ admin\ *|*\ sudo\ *)
if [ -x /usr/bin/sudo ]; then
echo 'To run a command as administrator (user "root"), use "sudo <command>".'
echo 'See "man sudo_root" for details.'
fi
esac
fi
EOF
echo " sudo-Hinweis wurde hinzugefügt!"
fi
# sudo-Hinweis
read -p "❓ Sollen die XDG-Data-Dirs gesetzt werden? (j/n) [n]: " answer
answer=${answer,,} # In Kleinbuchstaben umwandeln
answer=${answer:-n} # Standardwert 'n', falls leer
if [[ "$answer" == "j" ]] || [[ "$answer" == "y" ]]; then
cat << 'EOF' > /etc/profile.d/xdg_dirs_desktop_session.sh
# /etc/profile.d/desktop_session_xdg_dirs.sh - Prepend a $DESKTOP_SESSION-named directory to $XDG_CONFIG_DIRS and $XDG_DATA_DIRS
DEFAULT_XDG_CONFIG_DIRS="/etc/xdg"
DEFAULT_XDG_DATA_DIRS="/usr/local/share/:/usr/share/"
if [ -n "$DESKTOP_SESSION" ]; then
# readd default if was empty
if [ -z "$XDG_CONFIG_DIRS" ]; then
XDG_CONFIG_DIRS="$DEFAULT_XDG_CONFIG_DIRS"
fi
if [ -n "${XDG_CONFIG_DIRS##*$DEFAULT_XDG_CONFIG_DIRS/xdg-$DESKTOP_SESSION*}" ]; then
XDG_CONFIG_DIRS="$DEFAULT_XDG_CONFIG_DIRS"/xdg-"$DESKTOP_SESSION":"$XDG_CONFIG_DIRS"
fi
export XDG_CONFIG_DIRS
# gnome is already added if gnome-session installed
if [ "$DESKTOP_SESSION" != "gnome" ]; then
if [ -z "$XDG_DATA_DIRS" ]; then
XDG_DATA_DIRS="$DEFAULT_XDG_DATA_DIRS"
fi
if [ -n "${XDG_DATA_DIRS##*/usr/share/$DESKTOP_SESSION*}" ]; then
XDG_DATA_DIRS=/usr/share/"$DESKTOP_SESSION":"$XDG_DATA_DIRS"
fi
export XDG_DATA_DIRS
fi
fi
EOF
echo " XDG-Data-Dirs wurden gesetzt!"
fi
chmod +x /etc/profile.d/*
echo "✅ Abgeschlossen. Zum Anwenden der Änderungen bitte neu einloggen!"