Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Import ldns-signzone.sh and sign-everything.sh

  • Loading branch information...
commit 47ee0e49d8c66e2d4646ac72f44ee3e36dc85919 1 parent cfecf7a
@jedisct1 authored
View
3  .gitignore
@@ -0,0 +1,3 @@
+*.log
+*~
+.DS_Store
View
1  COPYING
@@ -0,0 +1 @@
+(c) 2012 Frank Denis - Public domain.
View
64 scripts/ldns-signzone.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+
+LDNS_SIGNZONE="ldns-signzone"
+
+errx() {
+ echo "$1" >&2
+ exit 1
+}
+
+parse_opts() {
+ opts=''
+ output=''
+ while [ $# -gt 0 ]; do
+ case $1 in
+ -[eioE]) opts="$opts $1"; shift ;;
+ -f) shift; output=$1; shift ;;
+ --) shift; break ;;
+ -*) ;;
+ *) break ;;
+ esac
+ opts="$opts $1"; shift
+ done
+ [ $# -lt 2 ] && exit 1
+ zonefile=$1; shift
+ keys=$*
+ [ "$output" = '' ] && output="${zonefile}.signed"
+ echo "$opts"; echo "$zonefile"; echo "$keys"; echo "$output"
+}
+
+preprocess_include() {
+ file="$1"
+ line="$2"
+ echo "$line" | {
+ read include_statement included_file
+ if [ -f "$included_file" ]; then
+ preprocess_file "$included_file"
+ else
+ alt_included_file=$(dirname "$file")/$(basename "$included_file")
+ [ -f "$alt_included_file" ] || \
+ errx "Nonexistent file: [$included_file] included from [$file]"
+ preprocess_file "$alt_included_file"
+ fi
+ }
+}
+
+preprocess_file() {
+ file="$1"
+ while read line; do
+ case "$line" in
+ \$[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]*)
+ preprocess_include "$file" "$line" || exit $?
+ ;;
+ *) echo "$line" ;;
+ esac
+ done < "$file" | egrep -v "^[[:blank:]]*$"
+}
+
+parse_opts $* | {
+ read opts; read zonefile; read keys; read output
+
+ [ -z "$zonefile" -o -z "$keys" -o -z "$output" ] && \
+ errx "Usage: $0 [opts] zonefile key [key [key]]"
+ preprocess_file $zonefile | "$LDNS_SIGNZONE" -f "$output" $opts -- - $keys
+}
View
15 scripts/sign-everything.sh
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+LDNS_SIGNZONE_WRAPPER="./ldns-signzone.sh"
+
+find . -type f -name "*.zone" -print | {
+ while read zonefile_; do
+ zonefile=$(basename "$zonefile_")
+ zone=$(echo "$zonefile" | sed 's/.zone$//')
+ keyfiles=$(ls "K${zone}."*.key 2>/dev/null)
+ [ -z "$keyfiles" ] && continue
+ keys=$(echo "$keyfiles" | sed s/.key//)
+ echo "Signing $zone"
+ "$LDNS_SIGNZONE_WRAPPER" -o "$zone" -n "$zonefile" $keys
+ done
+}
Please sign in to comment.
Something went wrong with that request. Please try again.