From dc4fffa9806ca9215827561e5baeef9105825a83 Mon Sep 17 00:00:00 2001 From: Marek Miklewicz Date: Fri, 1 Dec 2023 09:27:56 +0100 Subject: [PATCH] Update dapostinstall.sh --- dapostinstall.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/dapostinstall.sh b/dapostinstall.sh index b28727d..7598719 100755 --- a/dapostinstall.sh +++ b/dapostinstall.sh @@ -1,10 +1,17 @@ #!/bin/bash -# VERSION 1.6.4-23.08,2923 +# VERSION 1.6.5-29.11.2023 +if [ -f "/var/log/dapostinstall.done" ]; then + echo -e "\e[31mSkrypt DApostinstall był już uruchomiony na tym serwerze - przerywam działanie.\e[0m" + exit 1 +fi + DAPOSTINSTALL_DIR=/opt/dapostinstall DADIR=/usr/local/directadmin CBDIR=/usr/local/directadmin/custombuild LOG_FILE=/var/log/dapostinstall.log HTLINK="https://ht.zenadmin.pl" +MIN_PASSWORD_LENGHT=18 +MAX_PASSWORD_LENGHT=24 exec > >(tee -ia "$LOG_FILE") 2>&1 cd $DAPOSTINSTALL_DIR yum -y install htop wget rsync nano mc ncdu borgbackup @@ -22,7 +29,7 @@ sed -i '/PermitRootLogin yes/s/^#//g' /etc/ssh/sshd_config sed -i "s/PermitRootLogin yes/PermitRootLogin without-password/g" /etc/ssh/sshd_config echo "Poprawa locale" -dnf install -y glibc-all-langpacks langpacks-pl glibc-langpack-pl shuf +dnf install -y glibc-all-langpacks langpacks-pl glibc-langpack-pl localectl set-locale LANG=pl_PL.utf8 echo "Tworzenie domyslnego pakietu" @@ -347,20 +354,14 @@ cd $DAPOSTINSTALL_DIR chmod 755 da_cli.sh echo "Generowanie hasla DirectAdmin" - -echo "Generowanie hasla DirectAdmin" - -min_length=18 -max_length=24 - -special_chars='-._' DA_ADMINPASS=$( while true; do - base_part=$(tr -dc '[:alnum:]' < /dev/urandom | fold -w "$((RANDOM % (max_length - min_length - 1) + min_length - 1))" | head -n 1) - special_part=$(echo $special_chars | fold -w1 | shuf | head -n "$((RANDOM % 3 + 1))" | tr -d '\n') - password="${base_part:0:1}${special_part}${base_part:1}" + base_part=$(tr -dc '[:alnum:]' < /dev/urandom | tr -d 'oO0l1I' | fold -w "$((RANDOM % (MAX_PASSWORD_LENGTH - MIN_PASSWORD_LENGTH -$ + special_char=$(tr -dc '[:graph:]' < /dev/urandom | tr -d '#oO0l1I' | fold -w 1 | head -n1) + special_index=$((RANDOM % ${#base_part})) + password="${base_part:0:special_index}${special_char}${base_part:special_index}" - if echo "$password" | grep -qE '[[:digit:]]' && echo "$password" | grep -qE '[[:upper:]]' && echo "$password" | grep -qE '[-.,_]'; then + if echo "$password" | grep -qE '[[:digit:]]' && echo "$password" | grep -qE '[[:upper:]]' && echo "$password" | grep -q '[^[:alnum$ echo "$password" break fi @@ -608,6 +609,7 @@ sh da_cli.sh createemptybackup clear +touch /var/log/dapostinstall.done echo -e "\e[92mKonfiguracja zakonczona - usuwam pliki tymczasowe - tekst powitalny z uzupelnionymi odpowiednimi danymi znajdziesz w /root/mail_powitalny.txt\e[0m" cd ~ exec >/dev/null 2>&1