!/bin/bash
#Get domains from file
domains=($(cat /home/syafriel/domains.txt))
for d in “${domains[@]}”
do
#Get the expiration date
expdate=”$(whois $d | egrep -i ‘Registry Expiry Date:|Expiration:|Domain Expiration Date:|Registrar Registration Expiration Date:|expire:|paid-till:|option expiration date:|Expires on|Expiry date:|Expiry Date:|Expiration date:|Expiration Date:|Renewal date:|paid-till:|Domain expires:|renewal date:|expires:|Expires:|Expires On:’| head -1 | sed -r ‘s!^[^0-9]+!!’)”
#Turn it into seconds
expdate=”$(date -d”$expdate” +%s)”
#Get the current date in seconds
curdate=”$(date +%s)”
#Set exp variable
exp=”$(((expdate-curdate)/86400))”
#Send info if expired in less 30 days
if [ “$exp” -lt “30” ]; then
token=’Bot Token ‘
chat=Chat ID Tujuan
subj=”\ud83d\udd25 $d expires in $exp days”
message=” “
/usr/bin/curl –header ‘Content-Type: Content-Type: application/json’ –request ‘POST’ –data “{\”chat_id\”:\”${chat}\”,\”text\”:\”${subj}\n${message}\”}” “https://api.telegram.org/bot${token}/sendMessage” > /dev/null 2>&1
fi
done