Page MenuHomePhabricator

raw-paste-data.txt

Authored By
stwalkerster
Dec 30 2022, 6:17 PM
Size
1 KB
Referenced Files
None
Subscribers
None

raw-paste-data.txt

#!/bin/bash -e
ENDPOINT="https://dnsmanager.local/"
USERNAME="%username%"
PASSWORD="%password%"
HORIZON="0"
rm -rf zones/ tmp/ invalid/ log/ zones.tar.gz cookiejar
mkdir -p zones tmp invalid log
curl -v -k -d "Username=${USERNAME}&Password=${PASSWORD}" -X POST -c cookiejar ${ENDPOINT}login 2>/dev/null
if grep -q .AspNetCore.Identity.Application cookiejar; then
echo "Login succeeded"
else
echo "##teamcity[buildProblem description='API Login failure' identity='noLoginCookie']"
exit 1
fi
for zone in $(curl -v -k -b cookiejar ${ENDPOINT}api/zonefile/zones?horizon=${HORIZON} 2>/dev/null); do
echo "Processing zone ${zone}"
zoneName=$(echo $zone | cut -d '|' -f 1)
zoneId=$(echo $zone | cut -d '|' -f 2)
zoneFileName="db.${zoneName}"
curl -k -b cookiejar ${ENDPOINT}api/zonefile/zonefile?id=${zoneId} > tmp/${zoneFileName} 2>/dev/null
echo "Checking zone file for validity"
/usr/sbin/named-checkzone \
-k fail \
-m fail \
-M fail \
-n fail \
-r fail \
-S fail \
$zoneName tmp/${zoneFileName} \
| tee log/${zoneFileName}.log | sed -re 's/^/ /'
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
mv tmp/${zoneFileName} invalid/${zoneFileName}
else
mv tmp/${zoneFileName} zones/${zoneFileName}
cat <<EEOOFF >> zones/named.conf.localzones
zone "${zoneName}" {
type master;
file "/etc/bind/${zoneFileName}";
};
EEOOFF
fi
done
mv zones output

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
519638
Default Alt Text
raw-paste-data.txt (1 KB)

Event Timeline