czds

- ICANN Centralized Zone Data Service Tool
git clone git://git.acid.vegas/czds.git
Log | Files | Refs | Archive | README | LICENSE

commit 34fd31e33dcc1f61934616c9645797954a0b16de
parent ca121e248b26c6485b2ddaccfb558ab72b3c8893
Author: acidvegas <acid.vegas@acid.vegas>
Date: Thu, 15 Feb 2024 15:34:44 -0500

Fixed posix script and added stats

Diffstat:
Mczds | 19++++++++-----------
Mstats_2024-01-31.csv | 3++-

2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/czds b/czds
@@ -20,16 +20,13 @@ authenticate() {
 download_zone() {
 	url="$1"
 	token="$2"
-	filename=$(basename "$url")
-	tld=$(echo "$filename" | cut -d '.' -f 1)
-	filepath="zonefiles/$tld.txt.gz"
+	tld=$(basename "$url" .zone)
 
-	# Create output directory if it does not exist
-	mkdir -p zonefiles
 
 	# Make the GET request and save the response to a file
-	curl --progress-bar -o "$filepath" -H "Authorization: Bearer $token" "$url"
-	echo "Downloaded zone file to $filepath"
+	echo "Downloading $url..."
+	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
@@ -53,12 +50,12 @@ echo "Fetching zone file links..."
 # 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://[^"]*')
 
+# Create output directory if it does not exist
+mkdir -p zonefiles
+
 # Download zone files
 for url in $zone_links; do
-	if [ ! -f $filepath ]; then
-		echo "Downloading $url..."
-		download_zone "$url" "$token"
-	fi
+	download_zone "$url" "$token"
 done
 
 echo "All zone files downloaded."
diff --git a/stats_2024-01-31.csv b/stats_2024-01-31.csv
@@ -1148,4 +1148,4 @@
 "brandon.b93@paloaltonetworks.com","music","approved","2023-10-06T21:02:00Z","","2034-09-18T21:01:14Z"
 "brandon.b93@paloaltonetworks.com","kids","approved","2023-10-06T21:02:00Z","","2034-09-18T21:01:14Z"
 "brandon.b93@paloaltonetworks.com","name","approved","2023-10-16T20:58:08Z","","2034-09-28T20:58:08Z"
-"brandon.b93@paloaltonetworks.com","aero","approved","2023-10-06T21:02:00Z","","2034-09-18T21:01:14Z"
+"brandon.b93@paloaltonetworks.com","aero","approved","2023-10-06T21:02:00Z","","2034-09-18T21:01:14Z"
+\ No newline at end of file