Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 47ee0e49d8c66e2d4646ac72f44ee3e36dc85919 1 parent cfecf7a
Frank Denis authored
3  .gitignore
... ... @@ -0,0 +1,3 @@
  1 +*.log
  2 +*~
  3 +.DS_Store
1  COPYING
... ... @@ -0,0 +1 @@
  1 +(c) 2012 Frank Denis - Public domain.
64 scripts/ldns-signzone.sh
... ... @@ -0,0 +1,64 @@
  1 +#! /bin/sh
  2 +
  3 +LDNS_SIGNZONE="ldns-signzone"
  4 +
  5 +errx() {
  6 + echo "$1" >&2
  7 + exit 1
  8 +}
  9 +
  10 +parse_opts() {
  11 + opts=''
  12 + output=''
  13 + while [ $# -gt 0 ]; do
  14 + case $1 in
  15 + -[eioE]) opts="$opts $1"; shift ;;
  16 + -f) shift; output=$1; shift ;;
  17 + --) shift; break ;;
  18 + -*) ;;
  19 + *) break ;;
  20 + esac
  21 + opts="$opts $1"; shift
  22 + done
  23 + [ $# -lt 2 ] && exit 1
  24 + zonefile=$1; shift
  25 + keys=$*
  26 + [ "$output" = '' ] && output="${zonefile}.signed"
  27 + echo "$opts"; echo "$zonefile"; echo "$keys"; echo "$output"
  28 +}
  29 +
  30 +preprocess_include() {
  31 + file="$1"
  32 + line="$2"
  33 + echo "$line" | {
  34 + read include_statement included_file
  35 + if [ -f "$included_file" ]; then
  36 + preprocess_file "$included_file"
  37 + else
  38 + alt_included_file=$(dirname "$file")/$(basename "$included_file")
  39 + [ -f "$alt_included_file" ] || \
  40 + errx "Nonexistent file: [$included_file] included from [$file]"
  41 + preprocess_file "$alt_included_file"
  42 + fi
  43 + }
  44 +}
  45 +
  46 +preprocess_file() {
  47 + file="$1"
  48 + while read line; do
  49 + case "$line" in
  50 + \$[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]*)
  51 + preprocess_include "$file" "$line" || exit $?
  52 + ;;
  53 + *) echo "$line" ;;
  54 + esac
  55 + done < "$file" | egrep -v "^[[:blank:]]*$"
  56 +}
  57 +
  58 +parse_opts $* | {
  59 + read opts; read zonefile; read keys; read output
  60 +
  61 + [ -z "$zonefile" -o -z "$keys" -o -z "$output" ] && \
  62 + errx "Usage: $0 [opts] zonefile key [key [key]]"
  63 + preprocess_file $zonefile | "$LDNS_SIGNZONE" -f "$output" $opts -- - $keys
  64 +}
15 scripts/sign-everything.sh
... ... @@ -0,0 +1,15 @@
  1 +#! /bin/sh
  2 +
  3 +LDNS_SIGNZONE_WRAPPER="./ldns-signzone.sh"
  4 +
  5 +find . -type f -name "*.zone" -print | {
  6 + while read zonefile_; do
  7 + zonefile=$(basename "$zonefile_")
  8 + zone=$(echo "$zonefile" | sed 's/.zone$//')
  9 + keyfiles=$(ls "K${zone}."*.key 2>/dev/null)
  10 + [ -z "$keyfiles" ] && continue
  11 + keys=$(echo "$keyfiles" | sed s/.key//)
  12 + echo "Signing $zone"
  13 + "$LDNS_SIGNZONE_WRAPPER" -o "$zone" -n "$zonefile" $keys
  14 + done
  15 +}

0 comments on commit 47ee0e4

Please sign in to comment.
Something went wrong with that request. Please try again.