Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P298
(An Untitled Masterwork)
Active
Public
Actions
Authored by
stwalkerster
on Dec 30 2022, 6:17 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Tags
None
Referenced Files
F700129: raw-paste-data.txt
Dec 30 2022, 6:17 PM
2022-12-30 18:17:23 (UTC+0)
Subscribers
None
#!/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
Event Timeline
stwalkerster
created this paste.
Dec 30 2022, 6:17 PM
2022-12-30 18:17:23 (UTC+0)
stwalkerster
created this object with visibility "Public (No Login Required)".
Log In to Comment