]> code.citadel.org Git - citadel.git/blob - citadel/dumploadtest.sh
html_to_ascii.c : prepare to modernize!
[citadel.git] / citadel / dumploadtest.sh
1 #!/bin/bash
2
3 # This script dumps the database, deletes the database, loads the database, dumps it again...
4 # ...and then compares the two dumps to see if we have full fidelity between them.
5 #
6 # Did you read that correctly?  Yes, it will DELETE your database.  So don't run this.
7
8
9 if [ "${YES_DELETE_MY_DATABASE}" != '' ] ; then
10         echo Ah, I see you have set YES_DELETE_MY_DATABASE to a non-empty value.
11         echo The dump and load test will now proceed.
12 else
13         echo 'This script dumps the database, deletes the database, loads the database, dumps it again...'
14         echo '...and then compares the two dumps to see if we have full fidelity between them.'
15         echo 'Did you read that correctly?  Yes, it will DELETE your database.'
16         echo 'If this is really what you want, set the environment variable YES_DELETE_MY_DATABASE'
17         echo 'to a non-empty value, and run it again.'
18         exit 0
19 fi
20
21 ps ax | grep citserver | grep -v grep >/dev/null 2>/dev/null && {
22         echo Do not do this while the server is running.
23         exit 1
24 }
25
26 ./ctdldump -y >dump.dat
27 first=$(md5sum dump.dat | awk ' { print $1 } ' )
28
29 rm -fv data/*
30 ./ctdlload -y <dump.dat
31 ./ctdldump -y >dump.dat
32 second=$(md5sum dump.dat | awk ' { print $1 } ' )
33
34 echo
35 echo
36 echo MD5 of initial dump: ${first}
37 echo MD5 of sequent dump: ${second}
38 echo
39 if [ ${first} == ${second} ] ; then
40         echo Congratulations, you have full fidelity between two dumps.
41 else
42         echo Epic fail, you do NOT have full fidelity between two dumps.
43 fi