20 lines
621 B
Bash
20 lines
621 B
Bash
#!/bin/bash
|
|
|
|
script_dir="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
cert_valid_for=$(
|
|
certbot certificates 2>/dev/null |
|
|
grep -A 4 "fm.ines.org.pl" |
|
|
grep "Expiry Date" |
|
|
awk -F'[()]' '{print $2}' |
|
|
awk '{print $2}'
|
|
)
|
|
|
|
cert_valid_for="${cert_valid_for//[^0-9]/}"
|
|
cert_valid_for=$((10#${cert_valid_for:-0}))
|
|
|
|
if (( cert_valid_for < 30 ))
|
|
then
|
|
python3 "$script_dir/mail.py" --user "certificates@piga.pl" --password 'cgpM!tABM43_meJ' --to "it@piga.pl" --subject "Wygasa certyfikat dla serwera $(hostname)" --body "Certyfikat dla serwera $(hostname) jest ważny jeszcze $cert_valid_for dni."
|
|
fi
|