diff options
author | Magnus Ahltorp <map@kth.se> | 2017-02-02 16:08:24 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2017-02-02 21:58:38 +0100 |
commit | 8a1f3a5f5b1458aceb7567add95e7637e9c2e5fc (patch) | |
tree | 188f039cce63266dbe0dcca0477ca63bc983e74d /tools/genconfig.sh | |
parent | f481bd4f30a00fa3d4a5b4aecd0f881b1f5b58f5 (diff) |
Added tools for getting and generating global config
Diffstat (limited to 'tools/genconfig.sh')
-rwxr-xr-x | tools/genconfig.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/genconfig.sh b/tools/genconfig.sh new file mode 100755 index 0000000..89bcd85 --- /dev/null +++ b/tools/genconfig.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# usage: genconfig.sh <template> <apikeydir> <logpublickeyfile> <cacertfile> <logadminkey> <destination> + +BINDIR=$(dirname $0) + +template=$1 +apikeydir=$2 +logpublickeyfile=$3 +cacertfile=$4 +logadminkey=$5 +destination=$6 + +nodenames=$($BINDIR/compileconfig.py --config=${template} --getnodenames) + +cat ${template} > ${destination} + +echo "apikeys:" >> ${destination} + +for node in ${nodenames}; do \ + apipk=$(grep -v '^-----' ${apikeydir}/${node}.pem | tr '\n' ' ') + echo " - nodename: ${node}" >> ${destination} + echo " publickey: ${apipk}" >> ${destination} +done + +if [ -f ${destination}.version ]; then + oldversion=$(cat ${destination}.version) + version=$(expr $oldversion + 1) +else + version=1 +fi + +echo ${version} > ${destination}.version + +cafingerprint=$(openssl x509 -in ${cacertfile} -noout -sha256 -fingerprint | sed -e 's/.*=//' -e 's/://g') + +logpk=$(grep -v '^-----' ${logpublickeyfile} | tr '\n' ' ') +echo "logpublickey: ${logpk}" >> ${destination} +echo "cafingerprint: ${cafingerprint}" >> ${destination} +echo "version: ${version}" >> ${destination} + +openssl dgst -sha256 -sign ${logadminkey} -out ${destination}.sig ${destination} + |