Created
November 2, 2018 07:26
-
-
Save patrikbeno/29b5e2746367acf0e1b587e02b8b3a50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# FORPSI DNS plugin for acme.sh | |
# Usage: ./acme.sh --issue --dns dns_forpsi -d site.example.com | |
username=TOPSECRET | |
pasword=TOPSECRET | |
domain_id=NUMBER | |
domain=example.com | |
url="https://admin.forpsi.sk/domain/domains-dns.php?id=${domain_id}" | |
fcookies=".cookies" | |
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxp...5CPBs" | |
dns_forpsi_add() { | |
echo "dns_forpsi_add $@" | |
dns_forpsi_login | |
curl -sf "$url" \ | |
-XPOST -c $fcookies -b $fcookies \ | |
-d ak=record_add \ | |
-d type=TXT \ | |
-d url="%2Fdomain%2Fdomains-dns.php%3Fid%3D${domain_id}" \ | |
-d name="$(echo $1 | sed "s/.${domain}//")" \ | |
-d rdata="$2" | |
rm $fcookies | |
} | |
#Usage: dns_forpsi_rm fulldomain txtvalue | |
dns_forpsi_rm() { | |
dns_forpsi_login | |
local id="$(curl -sf "$url" -c $fcookies -b $fcookies | grep "$1.*$2" | sed 's/.*delete_row(//; s/,.*//')" | |
echo "Found id: $id" | |
if [ "$id" != "" ]; then | |
curl -sf "$url" \ | |
-XPOST -c $fcookies -b $fcookies \ | |
-d ak=record_del -d r_ID=$id \ | |
>/dev/null | |
fi | |
rm $fcookies | |
} | |
dns_forpsi_login() { | |
curl -sf 'https://admin.forpsi.sk/index.php' \ | |
-XPOST -c $fcookies -b $fcookies \ | |
-d user_name="$username" -d password="$password" -d login_action=client_login -d remember=1 \ | |
>/dev/null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment