-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdns01-namesilo.sh
77 lines (62 loc) · 1.96 KB
/
dns01-namesilo.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
. lib.sh
function DNS_LIST_RECORDS() {
local DOMAIN_NAME=$1
local ACTION="dnsListRecords"
local BASE_URL
BASE_URL="$(GET_API_BASE_URL ${ACTION})"
local API
API="${BASE_URL}&domain=${DOMAIN_NAME}"
local RES
RES=$(curl -X GET "${API}" 2>/dev/null)
echo "${RES}"
return $?
}
function GET_API_BASE_URL() {
local API_KEY="" # FILL YOUR NAMESILO API KEY HERE TO OVERRIDE NAMESILO API KEY AUTO DETECTION.
local VERSION="1"
local TYPE="xml"
local API_BASE_URL="https://www.namesilo.com/api"
local ACTION=$1
local API_KEY_AUTO_DETECT=""
API_KEY_AUTO_DETECT="$(FIND_NAMESILO_API_KEY_FROM_PWD)"
if [ -n "${API_KEY_AUTO_DETECT}" ] && [ -z "${API_KEY}" ]; then
API_KEY=${API_KEY_AUTO_DETECT}
fi
local URL="${API_BASE_URL}/${ACTION}?version=${VERSION}&type=${TYPE}&key=${API_KEY}"
echo "${URL}"
return 0
}
function ADD_RECORD() {
local DOMAIN_NAME=$1
local RR_TYPE=$2
local RR_HOST=$3
local RR_VALUE=$4
local RR_TTL=$5
local ACTION="dnsAddRecord"
local BASE_URL
BASE_URL="$(GET_API_BASE_URL ${ACTION})"
local API
API="${BASE_URL}&domain=${DOMAIN_NAME}&rrtype=${RR_TYPE}&rrhost=${RR_HOST}&rrvalue=${RR_VALUE}&rrttl=${RR_TTL}"
local RES
RES=$(curl -X GET "${API}" 2>/dev/null)
echo "${RES}"
return $?
}
function FIND_NAMESILO_API_KEY_FROM_PWD() {
local PWD=""
local NAMESILO_API_KEY_FILE=""
local NAMESILO_API_KEY=""
PWD="$(pwd)"
NAMESILO_API_KEY_FILE="$(ls -la $PWD | grep "NAMESILO-API-KEY-")"
if [ -n "${NAMESILO_API_KEY_FILE}" ]; then
NAMESILO_API_KEY="$(echo $NAMESILO_API_KEY_FILE | awk '{print $NF}' | awk -F '-' '{print $NF}')"
echo $NAMESILO_API_KEY
return $?
fi
}
DEBUG_LOG
ADD_RECORD "stgmsa.me" "TXT" "_acme-challenge" "${CERTBOT_VALIDATION}" "3600"
POLL "${CERTBOT_DOMAIN}" "${CERTBOT_VALIDATION}"
# Test:
# POLL "stgmsa.me" "AaabzW4ibDxfctmGJWwktC7OvqyFLzE3T_wku5DzZBM"