diff scripts/check_db_safety @ 12:41b330b11a33 draft

coded a tinydns datafile generator
author Nick <nick@somerandomnick.ano>
date Mon, 19 Apr 2010 06:10:07 +0000
parents
children 059b5f3d7808
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/check_db_safety	Mon Apr 19 06:10:07 2010 +0000
@@ -0,0 +1,29 @@
+#!/bin/sh
+if [ "$(ls db/dom/ | tr -d 'a-z0-9\n-' | wc -c)" != 0 ]; then
+ echo "There's a bad TLD.  You probably don't want to run any shell scripts." >&2
+ exit 1
+fi
+for tld in db/dom/* ; do
+ if [ "$(ls $tld/ | tr -d 'a-z0-9\n-' | wc -c)" != 0 ]; then
+  tld="$(basename $tld)"
+  echo "There's a bad domain under $tld." >&2
+  echo "You probably don't want to run any shell scripts." >&2
+  exit 1
+ fi
+ for dom in $tld/* ; do
+  if [ "$(ls $dom/ns/ | tr -d 'a-z0-9\n.-' | wc -c)" != 0 ]; then
+   domain="$(basename $dom).$(basename $tld)"
+   echo "There's a bad nameserver under $domain." >&2
+   echo "You probably don't want to run any shell scripts." >&2
+  fi
+  for ns in $dom/ns/* ; do
+   if [ "$(cat $ns | tr -d '0-9.\n' | wc -c)" != 0 ]; then
+    domain="$(basename $dom).$(basename $tld)"
+    nsname="$(basename $ns)"
+    echo "There's a bad nameserver IP under $domain, for" >&2
+    echo " $nsname" >&2
+    echo "You probably don't want to run any shell scripts." >&2
+   fi
+  done
+ done
+done