diff --git a/dapostinstall.sh b/dapostinstall.sh index bb5126a..4b93c71 100755 --- a/dapostinstall.sh +++ b/dapostinstall.sh @@ -145,7 +145,11 @@ EOT echo "Ustawienie kluczy logowania do DirectAdmina i kluczy SSH hitme" daupdate klucze -daupdate keyput + +if ! grep -q '^Match User root' /etc/ssh/sshd_config; then + daupdate keyput +fi + cd $DAPOSTINSTALL_DIR echo "Instalacja Modsecurity i regułek malware experts" @@ -605,19 +609,15 @@ $DADIR/plugins/redis_management/scripts/install.sh cd $DAPOSTINSTALL_DIR echo "Instalacja IMAPsync" -dnf -y install --enablerepo=powertools imapsync +dnf -y install imapsync mkdir $DADIR/plugins/imapsync tar -zxf imapsync.tar.gz -C $DADIR/plugins/imapsync $DADIR/plugins/imapsync/scripts/install.sh -echo 'imapsync=type=checkbox&string=IMAPsync migrations (plugin)&desc=Allow access to imapsync migrations&default=yes' >> /usr/local/directadmin/data/admin/custom_package_items.conf echo 'imapsync=ON' >> /usr/local/directadmin/data/users/admin/user.conf cp lang_pl.php $DADIR/plugins/imapsync/lang -# echo "Dodanie kolorowego prompta hitme" -# echo "PS1='\[\e[0;1;38;5;46m\]\u\[\e[0m\]@\[\e[0;1;38;5;214m\]\h\[\e[0m\][\[\e[0;1;97m\]\W\[\e[0m\]]\[\e[0;38;5;46m\]$ \[\e[0m\]'" | sudo tee -a /etc/profile - -# echo "dodanie kolorowego prompta dla roota" -# echo "PS1='\[\e[0;1;91m\]\u\[\e[0m\]@\[\e[0;1;38;5;214m\]\h\[\e[0m\][\[\e[0;1;97m\]\W\[\e[0m\]]\[\e[0;1m\]# \[\e[0m\]'" | sudo tee -a /root/.bash_profile +echo "instalacja promptów" +sh prompt.sh echo "never_commands=custombuild:updates:license" >> /usr/local/directadmin/conf/directadmin.conf systemctl restart directadmin diff --git a/prompt.sh b/prompt.sh new file mode 100644 index 0000000..c9179db --- /dev/null +++ b/prompt.sh @@ -0,0 +1,44 @@ +#!/bin/bash +BASHRC_FILE="/etc/bashrc" +ROOT_BASHRC_FILE="/root/.bashrc" +PROFILE_FILE="/etc/profile" +ROOT_BASH_PROFILE="/root/.bash_profile" + +read -r -d '' PROMPT_BLOCK << 'EOF' +if [ -n "$STY" ]; then + screen_info="\[\e[0;1;33m\](screen $(echo "$STY" | cut -d. -f2)) \[\e[0m\]" +else + screen_info="" +fi +PS1="${screen_info}\[\e[0;1;38;5;46m\]\u\[\e[0m\]@\[\e[0;1;38;5;214m\]\h\[\e[0m\][\[\e[0;1;97m\]\W\[\e[0m\]]\[\e[0;38;5;46m\]\$ \[\e[0m\]" +EOF + +read -r -d '' ROOT_PROMPT_BLOCK << 'EOF' +if [ -n "$STY" ]; then + screen_info="\[\e[0;1;33m\](screen $(echo "$STY" | cut -d. -f2)) \[\e[0m\]" +else + screen_info="" +fi +PS1="${screen_info}\[\e[0;1;91m\]\u\[\e[0m\]@\[\e[0;1;38;5;214m\]\h\[\e[0m\][\[\e[0;1;97m\]\W\[\e[0m\]]\[\e[0;1;91m\]# \[\e[0m\]" +EOF + +append_prompt() { + local file="$1" + local block="$2" + echo "$block" | sudo tee -a "$file" > /dev/null +} + +remove_last_PS1_line() { + local file="$1" + if [ -f "$file" ]; then + if tail -n 1 "$file" | grep -q '^PS1='; then + sudo sed -i '${/^PS1=/d;}' "$file" + fi + fi +} + +append_prompt "$BASHRC_FILE" "$PROMPT_BLOCK" +append_prompt "$ROOT_BASHRC_FILE" "$ROOT_PROMPT_BLOCK" +remove_last_PS1_line "$PROFILE_FILE" +remove_last_PS1_line "$ROOT_BASH_PROFILE" +