It would be another daily script like check-ssl-certs, with configuration in /etc/pov/check-domains.
It would have a new helper function:
get_expiration_date() {
# this works for .com and .net domains
# whois pov.lt doesn't tell me the expiration date!
whois $1 | grep "^ *Expiration Date:\|^Expires:\|^paid-till:\|^Registry Expiry Date:" | sed -e 's/^[^:]*: *//' -e 's/\([0-9]\{4\}\)[.]\([0-9]\{2\}\)[.]\([0-9]\{2\}\)/\1-\2-\3/g'
# you get something like "28-nov-2013" or "14 Jul 2018 00:00 UTC" or "2014.08.26" or "2018-07-14T00:00:00.000Z"
}
checkdomain() {
local domain=$1
local days=${2:-60}
local expires=$(get_expiration_date $domain)
if [ -z "$expires" ]; then
warn "$domain: cannot get expiration date from whois"
return
fi
local expires_as_time_t=$(date +%s --date="$expires")
local now_as_time_t=$(date +%s)
local seconds_remaining=$((expires_as_time_t - now_as_time_t))
local days_remaining=$((seconds_remaining / 86400))
if [ $days_remaining -le $days ]; then
warn "$domain expires in $days_remaining days ($expires)"
elif [ $verbose -ne 0 ]; then
echo "$domain expires in $days_remaining days ($expires)"
fi
}
It would be another daily script like
check-ssl-certs
, with configuration in/etc/pov/check-domains
.It would have a new helper function: