forked from jpconver/dnsexit_dnshook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup.sh
executable file
·40 lines (30 loc) · 1.48 KB
/
cleanup.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash -e
# load config
. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/config.sh"
. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/base.sh"
# certbot environment variables
certbotDomain="${CERTBOT_DOMAIN}"
validation="${CERTBOT_VALIDATION}"
cookiesFile="/tmp/dnsExitCookies.txt"
# calculated variables
txtName="_acme-challenge.${fullDomain/$baseDomain/}"
txtValue="${validation}"
token="10d56a723037e3ff850edb5ce6878dd9^1920:1080|1855:1056|24:24^^180"
# login
curl -s -D - -X POST --data "login=${username}&password=${password}&fptoken=${token}" -c ${cookiesFile} https://www.dnsexit.com/Login.sv > /tmp/dnsExitLoginPage.html
# get dnsExit domain
getDnsExitDomain baseDomain "$certbotDomain" "/tmp/dnsExitLoginPage.html"
# open domain information
curl -s -D - -X GET -c ${cookiesFile} -b ${cookiesFile} "https://www.dnsexit.com/Direct.sv?cmd=userShowDns&domainname=${baseDomain}" > /tmp/dnsExitDomainPage.html
# get txt record deletion url
IFS=" "
grepCommand="grep -Pzo (?s)${validation}(.*?)Edit</a>.\\|.<a.class=\"winlink\".href=\"\K(.*?)\" /tmp/dnsExitDomainPage.html"
deletionUrl=`${grepCommand}`
deletionUrl="https://www.dnsexit.com/"${deletionUrl::-1}
# execute delete url
curl -s -D - -X GET -c ${cookiesFile} -b ${cookiesFile} "${deletionUrl}" > /tmp/dnsExitDomainPage.html
# save changes
curl -s -D - -X GET -c ${cookiesFile} -b ${cookiesFile} "https://www.dnsexit.com/Direct.sv?cmd=userShowDns&actioncode=2" > /tmp/dnsExitSaveChanges.html
# cleanup
rm -f /tmp/dnsExit*.*
exit 0