Update Linux/SSH/README.md
This commit is contained in:
@@ -254,6 +254,52 @@ fi
|
||||
log "Setup abgeschlossen! Nur folgende Benutzer dürfen sich per SSH anmelden: ${WHITE}$VALID_USERS"
|
||||
```
|
||||
|
||||
# BASH Farbprofil
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
BASHRC_CONTENT="\n# Farbiges ls und grep\nalias ls='ls --color=auto'\nalias grep='grep --color=auto'\nalias egrep='egrep --color=auto'\nalias fgrep='fgrep --color=auto'\neval \"\$(dircolors -b ~/.dircolors)\"\nif [ \"\$EUID\" -eq 0 ]; then\n PS1='\\[\\e[1;31m\\]\\u\\[\\e[0;33m\\]@\\[\\e[1;30m\\]\\h \\\[\\e[1;33m\\]\\w\\[\\e[0m\\] # '
|
||||
else\n PS1='\\[\\e[1;32m\\]\\u\\[\\e[0;33m\\]@\\[\\e[1;30m\\]\\h \\\[\\e[1;34m\\]\\w\\[\\e[0m\\] \\$
|
||||
fi\n"
|
||||
|
||||
# Sicherstellen, dass die Datei ~/.dircolors erstellt wird
|
||||
dircolors -p > ~/.dircolors
|
||||
|
||||
# Funktion, um die .bashrc Datei zu aktualisieren
|
||||
update_bashrc() {
|
||||
local user_home=$1
|
||||
local bashrc_file="$user_home/.bashrc"
|
||||
|
||||
# Sicherstellen, dass die Datei existiert
|
||||
touch "$bashrc_file"
|
||||
|
||||
# Prüfen, ob der Inhalt bereits existiert, wenn nicht, hinzufügen
|
||||
if ! grep -q "Farbiges ls und grep" "$bashrc_file"; then
|
||||
echo -e "$BASHRC_CONTENT" >> "$bashrc_file"
|
||||
echo "$bashrc_file wurde aktualisiert."
|
||||
else
|
||||
echo "$bashrc_file ist bereits aktuell."
|
||||
fi
|
||||
|
||||
# .dircolors in das Benutzerverzeichnis kopieren
|
||||
cp ~/.dircolors "$user_home/.dircolors"
|
||||
chown $(basename $user_home):$(basename $user_home) "$user_home/.dircolors"
|
||||
}
|
||||
|
||||
# Aktualisiere die .bashrc Datei für root
|
||||
update_bashrc /root
|
||||
|
||||
# Aktualisiere die .bashrc Datei für alle Benutzer im /home Verzeichnis
|
||||
for dir in /home/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
update_bashrc "$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Skriptausführung abgeschlossen."
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Falls du weitere Fragen hast oder Anpassungen benötigst, lass es mich wissen! 😊
|
||||
|
||||
Reference in New Issue
Block a user