-
Notifications
You must be signed in to change notification settings - Fork 0
/
namesilobalance
26 lines (19 loc) · 1.07 KB
/
namesilobalance
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
# Bash script to discover current funds balance of the Namesilo.com account and report via email if the balance is below the defined treshold
# chmod 700 /root/scripts/namesilobalance
# run the script periodically using cron, example line in /etc/cron.d/crons: 0 */6 * * * root /bin/sh /root/scripts/namesilobalance
# to run every 6 hours
# Minimum funds balance in dollars (without decimals)
treshold=60
# Namesilo API key
apikey=abcdef012345
webresponse=$(curl -s "https://www.namesilo.com/api/getAccountBalance?version=1&type=xml&key=$apikey")
balance=$(echo "$webresponse"|grep -o -P '(?<=<balance>).*(?=</balance>)' | cut -d '.' -f 1|sed -e 's|,||g')
if [[ -z "$balance" ]];then echo -e "Balance is null. Web response was:\n$webresponse\n\nBalance was:\n$balance" && exit;fi
if [[ "$balance" -lt "$treshold" ]];then
echo "Namesilo account balance \"$balance\" is under $treshold USD
Add funds: https://www.namesilo.com/account_funds_add.php
This is script /root/scripts/namesilobalance at $(hostname)" | mail -s "Namesilo, Add funds" $adminmail
fi
#