Feat: Fügt Skripte zum aufsetzen von Debian 12 (Bookworm) hinzu.
This commit is contained in:
78
0_Setup.sh
Executable file
78
0_Setup.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Root-Rechte prüfen
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Bitte mit sudo ausführen!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
apt update && apt upgrade -y
|
||||
apt install -y git sudo
|
||||
|
||||
# Der Code, der eingefügt werden soll
|
||||
CONFIG_BLOCK='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'
|
||||
|
||||
# Saubere Lösung über /etc/profile.d/
|
||||
echo "$CONFIG_BLOCK" >/etc/profile.d/custom_path.sh
|
||||
|
||||
# Sudo-Hinweis für bash.bashrc
|
||||
SUDO_HINT_BLOCK='# sudo hint
|
||||
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
|
||||
case " $(groups) " in *\ admin\ *|*\ sudo\ *)
|
||||
if [ -x /usr/bin/sudo ]; then
|
||||
cat <<-EOF
|
||||
To run a command as administrator (user "root"), use "sudo <command>".
|
||||
See "man sudo_root" for details.
|
||||
EOF
|
||||
fi
|
||||
esac
|
||||
fi'
|
||||
|
||||
# Prüfen, ob der sudo-Hinweis bereits existiert
|
||||
if ! grep -Fxq "# sudo hint" /etc/bash.bashrc; then
|
||||
echo -e "\n$SUDO_HINT_BLOCK" | tee -a /etc/bash.bashrc >/dev/null
|
||||
echo "Sudo-Hinweis zur bash.bashrc hinzugefügt."
|
||||
else
|
||||
echo "Sudo-Hinweis ist bereits in bash.bashrc vorhanden."
|
||||
fi
|
||||
|
||||
XDG_BLOCK='# /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
|
||||
'
|
||||
|
||||
echo "$XDG_BLOCK" >/etc/profile.d/xdg_dirs_desktop_session.sh
|
||||
|
||||
echo "Fertig! Bitte neu einloggen."
|
||||
|
||||
Reference in New Issue
Block a user