Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Little optimizations - comments are now in bad English.
The style of the cycles is now the same
, the extra variable lsl has been removed
The most important thing is the changes in "10" > "$valid_dayb"
Signs greater than and less than compare not numbers, but strings, for numbers you need to use -gt, -ge, -lt, -le
corrected to " $valid_dayb" -le 10
#!/bin/bash
clear
# getting list of real web-sites in httpd configuration
for variable in $(find /etc/httpd/bx/conf -name "bx_ext*" | sed 's/\/etc\/httpd\/bx\/conf\/bx_ext_//g' | sed 's/\.conf//g' )
do
# pinging sites
ping -c 1 "$variable" 2>/dev/null | grep -e $(/sbin/ifconfig | sed -n '2 p' | awk '{print $2}') &> /dev/null && variable_ping_ok=$variable || variable_ping_ok="failed ip"
# skip A-records, which points to another server
if ; then
valid_days=$(($(date -d "$(curl -sIv https://$variable_ping_ok |& grep "expire date:" | sed -e 's/\(.*\)expire date: //g')" +%j)-$(date +%j)))
# check how many days till certificate expiration and if less then 10, requesting new cert.
if ; then
echo "$variable_ping_ok $valid_days requesting new certificate"
certbot certonly --dry-run -m [email protected]$variable_ping_ok --webroot -w /home/bitrix/sites/$variable_ping_ok -d $variable_ping_ok -d www.$variable_ping_ok &> /dev/null && sudo -u root /opt/webdir/bin/bx-sites -a configure_le --site $variable_ping_o --email [email protected]$variable_ping_o --dns $variable_ping_o -o json
fi
else
echo "$variable_ping_ok $valid_days current certificate is ok"
fi
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question