source: genesis/tools/svn-hook/genesis-check.sh

Last change on this file was 10690, checked in by rick, 13 years ago

Fix issues of not checking duplicates IPs.

While here, add feature that commits which mention no-genesis-check force-fully
overrides the config validators errors.

Related-To: beheer#211

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1#!/bin/sh
2#
3# Check for valid genesis syntax
4#
5# Rick van der Zwet <rick@wirelessleiden.nl>
6#
7REPOS="$1"
8TXN="$2"
9
10TMPDIR=`mktemp -d -t $(basename $0 .sh)`
11
12# External definition used for debugging
13SVNLOOK="${SVNLOOK:-/usr/local/bin/svnlook --transaction $TXN}"
14GENESISDIR='node-config/genesis'
15
16# Check whether we need to check something first
17$SVNLOOK changed -t $TXN $REPOS | grep -q $GENESISDIR
18if [ $? -eq 1 ]; then
19 exit 0
20fi
21
22# Allow us to commit stuff even if the validator fails
23$SVNLOOK log -t $TXN $REPOS | grep -q 'no-genesis-check' && exit 0
24
25# Clean up on exit
26trap "rm -R $TMPDIR" 0 1 2 3 15
27
28echo "Checking genesis config, please hold your horses..." 1>&2
29for ENTRY in `$SVNLOOK tree --full-paths $REPOS $GENESISDIR`; do
30 echo $ENTRY | grep -q 'retired' && continue
31
32 echo $ENTRY | grep -q '/$'
33 if [ $? -eq 0 ]; then
34 mkdir -p $TMPDIR/$ENTRY
35 else
36 $SVNLOOK cat $REPOS $ENTRY > $TMPDIR/$ENTRY
37 fi
38done
39
40# Do actual checking
41echo $TMPDIR/$GENESISDIR/tools/before-commit.sh 1>&2
42sh $TMPDIR/$GENESISDIR/tools/before-commit.sh 2>> $TMPDIR/log.txt 1>>$TMPDIR/log.txt
43RETVAL=$?
44
45sed "s+$TMPDIR/node-config/genesis/nodes/++g" $TMPDIR/log.txt 1>&2
46
47exit $RETVAL
Note: See TracBrowser for help on using the repository browser.