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

Last change on this file since 13598 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
RevLine 
[7300]1#!/bin/sh
2#
3# Check for valid genesis syntax
[10690]4#
5# Rick van der Zwet <rick@wirelessleiden.nl>
6#
[7300]7REPOS="$1"
8TXN="$2"
9
10TMPDIR=`mktemp -d -t $(basename $0 .sh)`
[10091]11
[7300]12# External definition used for debugging
13SVNLOOK="${SVNLOOK:-/usr/local/bin/svnlook --transaction $TXN}"
[10091]14GENESISDIR='node-config/genesis'
[7300]15
16# Check whether we need to check something first
[10690]17$SVNLOOK changed -t $TXN $REPOS | grep -q $GENESISDIR
[7300]18if [ $? -eq 1 ]; then
19 exit 0
20fi
21
[10690]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
[7300]28echo "Checking genesis config, please hold your horses..." 1>&2
29for ENTRY in `$SVNLOOK tree --full-paths $REPOS $GENESISDIR`; do
[10091]30 echo $ENTRY | grep -q 'retired' && continue
31
[7300]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
[10091]41echo $TMPDIR/$GENESISDIR/tools/before-commit.sh 1>&2
42sh $TMPDIR/$GENESISDIR/tools/before-commit.sh 2>> $TMPDIR/log.txt 1>>$TMPDIR/log.txt
[7300]43RETVAL=$?
44
[7306]45sed "s+$TMPDIR/node-config/genesis/nodes/++g" $TMPDIR/log.txt 1>&2
[7300]46
47exit $RETVAL
Note: See TracBrowser for help on using the repository browser.