diff --git a/bin/v-update-letsencrypt-ssl b/bin/v-update-letsencrypt-ssl index 36d7a1e9..3105c86c 100755 --- a/bin/v-update-letsencrypt-ssl +++ b/bin/v-update-letsencrypt-ssl @@ -23,6 +23,9 @@ source $VESTA/conf/vesta.conf #----------------------------------------------------------# lecounter=0 +hostname=$(hostname) + +echo "[$(date)] : -----------------------------------------------------------------------------------" >> /usr/local/vesta/log/letsencrypt_cron.log # Checking user certificates for user in $($BIN/v-list-users plain |cut -f 1); do @@ -31,8 +34,20 @@ for user in $($BIN/v-list-users plain |cut -f 1); do for domain in $(search_objects 'web' 'LETSENCRYPT' 'yes' 'DOMAIN'); do fail_counter=$(get_web_counter "$user" "$domain" 'LETSENCRYPT_FAIL_COUNT') - if [[ "$fail_counter" -ge 7 ]]; then - echo "$domain failed $fail_counter times for LetsEncrypt renewing, skipping" + + if [[ "$fail_counter" -ge 8 ]]; then + if [ "$hostname" = "$domain" ]; then + if [ -z "$SKIP_HOSTNAME_LETSENCRIPT_RENEWING_WARNING" ]; then + email=$(grep CONTACT $VESTA/data/users/admin/user.conf) + email=$(echo "$email" | cut -f 2 -d "'") + echo "hostname $domain failed for LetsEncrypt renewing" | $SENDMAIL -s "LetsEncrypt renewing hostname $hostname" "$email" 'yes' + fi + fi + fi + + if [[ "$fail_counter" -ge 8 ]]; then + # echo "$domain failed $fail_counter times for LetsEncrypt renewing, skipping" + echo "[$(date)] : $domain failed $fail_counter times for LetsEncrypt renewing, skipping" >> /usr/local/vesta/log/letsencrypt_cron.log continue; fi crt_data=$(openssl x509 -text -in $USER_DATA/ssl/$domain.crt) @@ -53,11 +68,13 @@ for user in $($BIN/v-list-users plain |cut -f 1); do aliases=$(echo "$aliases" |sed -e ':a;N;$!ba;s/\n/,/g') msg=$($BIN/v-add-letsencrypt-domain $user $domain $aliases) if [ $? -ne 0 ]; then - echo "$domain $msg" if [[ $msg == *"is suspended" ]]; then - echo "OK, it's suspended" + echo "[$(date)] : SUSPENDED: $domain $msg" >> /usr/local/vesta/log/letsencrypt_cron.log else + echo "[$(date)] : $domain $msg" >> /usr/local/vesta/log/letsencrypt_cron.log + echo "$domain $msg" fail_counter=$(alter_web_counter "$user" "$domain" 'LETSENCRYPT_FAIL_COUNT') + echo "[$(date)] : fail_counter = $fail_counter" >> /usr/local/vesta/log/letsencrypt_cron.log echo "fail_counter = $fail_counter" fi fi