Compare commits
6 Commits
8a0362a6e1
...
07820587d8
Author | SHA1 | Date | |
---|---|---|---|
|
07820587d8 | ||
|
b49be41577 | ||
|
c7618c7a4b | ||
|
f8a23992ea | ||
|
523c9984a6 | ||
|
a09dac147a |
12
cfddns.sh
12
cfddns.sh
@ -35,7 +35,7 @@ echo -e "\tmachine's IP6 address can be correctly detected externally."
|
|||||||
echo -e "-h\tDisplay this help page"
|
echo -e "-h\tDisplay this help page"
|
||||||
echo -e "-x\tDisplay script examples"
|
echo -e "-x\tDisplay script examples"
|
||||||
echo -e "-l\tLocation for log file output"
|
echo -e "-l\tLocation for log file output"
|
||||||
echo -e "\tDefault: scriptname.ext.log in same directory as this script"
|
echo -e "\tDefault: scriptname.log in same directory as this script"
|
||||||
echo -e "\n\e[1;39mExamples:"
|
echo -e "\n\e[1;39mExamples:"
|
||||||
echo -e "\e[0;39mRun \e[1;36m$(basename ${0}) \e[1;92m-x\e[0m\n"
|
echo -e "\e[0;39mRun \e[1;36m$(basename ${0}) \e[1;92m-x\e[0m\n"
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
@ -82,7 +82,7 @@ quit none
|
|||||||
function quit {
|
function quit {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
# exit cleanly
|
# exit cleanly
|
||||||
echo -e "${bold}${note}${stamp} -- Script completed --\${normal}" \
|
echo -e "${bold}${note}${stamp} -- Script completed --${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$1" = "none" ]; then
|
elif [ "$1" = "none" ]; then
|
||||||
@ -128,7 +128,7 @@ ip6=0
|
|||||||
|
|
||||||
### define script variables
|
### define script variables
|
||||||
# timestamp
|
# timestamp
|
||||||
stamp="${stamp}"
|
stamp="[`date +%Y-%m-%d` `date +%H:%M:%S`]"
|
||||||
# formatting
|
# formatting
|
||||||
normal="\e[0m"
|
normal="\e[0m"
|
||||||
bold="\e[1m"
|
bold="\e[1m"
|
||||||
@ -261,13 +261,13 @@ echo -e "${info}${stamp} [INFO] Using IP address:" \
|
|||||||
## Check if desired record(s) exist at CloudFlare
|
## Check if desired record(s) exist at CloudFlare
|
||||||
# perform checks on A or AAAA records based on invocation options
|
# perform checks on A or AAAA records based on invocation options
|
||||||
if [ $ip4 -eq 1 ]; then
|
if [ $ip4 -eq 1 ]; then
|
||||||
echo -e "${normal}${stamp} (IP4 lookup: ${dnsRecords[*]})" \
|
echo -e "${normal}${stamp} [INFO] Updating A records: ${dnsRecords[*]}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
for cfLookup in "${dnsRecords[@]}"; do
|
for cfLookup in "${dnsRecords[@]}"; do
|
||||||
cfRecords+=("$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${cfDetails[2]}/dns_records?name=$cfLookup&type=A" -H "X-Auth-Email: ${cfDetails[0]}" -H "X-Auth-Key: ${cfDetails[1]}" -H "Content-Type: application/json")")
|
cfRecords+=("$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${cfDetails[2]}/dns_records?name=$cfLookup&type=A" -H "X-Auth-Email: ${cfDetails[0]}" -H "X-Auth-Key: ${cfDetails[1]}" -H "Content-Type: application/json")")
|
||||||
done
|
done
|
||||||
elif [ $ip6 -eq 1 ]; then
|
elif [ $ip6 -eq 1 ]; then
|
||||||
echo -e "${normal}${stamp} (IP6 lookup: ${dnsRecords[*]})" \
|
echo -e "${normal}${stamp} [INFO] Updating AAAA records: ${dnsRecords[*]}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
for cfLookup in "${dnsRecords[@]}"; do
|
for cfLookup in "${dnsRecords[@]}"; do
|
||||||
cfRecords+=("$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${cfDetails[2]}/dns_records?name=$cfLookup&type=AAAA" -H "X-Auth-Email: ${cfDetails[0]}" -H "X-Auth-Key: ${cfDetails[1]}" -H "Content-Type: application/json")")
|
cfRecords+=("$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${cfDetails[2]}/dns_records?name=$cfLookup&type=AAAA" -H "X-Auth-Email: ${cfDetails[0]}" -H "X-Auth-Key: ${cfDetails[1]}" -H "Content-Type: application/json")")
|
||||||
@ -329,7 +329,7 @@ for recordIdx in "${!currentIP[@]}"; do
|
|||||||
"${dnsRecords[recordIdx]} is up-to-date.${normal}" \
|
"${dnsRecords[recordIdx]} is up-to-date.${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
else
|
else
|
||||||
echo -e "${lit}${stamp} -- [STATUS]" \
|
echo -e "${info}${stamp} -- [STATUS]" \
|
||||||
"${dnsRecords[recordIdx]} needs updating...${normal}" \
|
"${dnsRecords[recordIdx]} needs updating...${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
if [ $ip4 -eq 1 ]; then
|
if [ $ip4 -eq 1 ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user