Setup/0_Setup.sh

103 lines
3.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
# 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/*
# Passwort root
read -p "❓ Soll ein Passwort für root gesetzt werden? (j/n) [n]: " answer
answer=${answer,,} # In Kleinbuchstaben umwandeln
answer=${answer:-n} # Standardwert 'n', falls leer
if [[ "$answer" == "j" ]] || [[ "$answer" == "y" ]]; then
passwd root
fi
echo "✅ Abgeschlossen. Zum Anwenden der Änderungen bitte neu einloggen!"