Fixed posix script and added stats
This commit is contained in:
parent
ca121e248b
commit
34fd31e33d
19
czds
19
czds
@ -20,16 +20,13 @@ authenticate() {
|
|||||||
download_zone() {
|
download_zone() {
|
||||||
url="$1"
|
url="$1"
|
||||||
token="$2"
|
token="$2"
|
||||||
filename=$(basename "$url")
|
tld=$(basename "$url" .zone)
|
||||||
tld=$(echo "$filename" | cut -d '.' -f 1)
|
|
||||||
filepath="zonefiles/$tld.txt.gz"
|
|
||||||
|
|
||||||
# Create output directory if it does not exist
|
|
||||||
mkdir -p zonefiles
|
|
||||||
|
|
||||||
# Make the GET request and save the response to a file
|
# Make the GET request and save the response to a file
|
||||||
curl --progress-bar -o "$filepath" -H "Authorization: Bearer $token" "$url"
|
echo "Downloading $url..."
|
||||||
echo "Downloaded zone file to $filepath"
|
curl --progress-bar -o zonefiles/$tld.txt.gz -H "Authorization: Bearer $token" "$url"
|
||||||
|
echo "Downloaded zone file to zonefiles/$tld.txt.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main program starts here
|
# Main program starts here
|
||||||
@ -53,12 +50,12 @@ echo "Fetching zone file links..."
|
|||||||
# Fetch zone links with inline URL and download zone files
|
# Fetch zone links with inline URL and download zone files
|
||||||
zone_links=$(curl -s -H "Authorization: Bearer $token" "https://czds-api.icann.org/czds/downloads/links" | grep -o 'https://[^"]*')
|
zone_links=$(curl -s -H "Authorization: Bearer $token" "https://czds-api.icann.org/czds/downloads/links" | grep -o 'https://[^"]*')
|
||||||
|
|
||||||
|
# Create output directory if it does not exist
|
||||||
|
mkdir -p zonefiles
|
||||||
|
|
||||||
# Download zone files
|
# Download zone files
|
||||||
for url in $zone_links; do
|
for url in $zone_links; do
|
||||||
if [ ! -f $filepath ]; then
|
download_zone "$url" "$token"
|
||||||
echo "Downloading $url..."
|
|
||||||
download_zone "$url" "$token"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "All zone files downloaded."
|
echo "All zone files downloaded."
|
||||||
|
Loading…
Reference in New Issue
Block a user