source: trunk/MagicSoft/Mars/datacenter/scripts/dbchk@ 8499

Last change on this file since 8499 was 8380, checked in by hoehne, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#!/bin/sh
2
3
4# SETUP
5
6# directory where the sequence files are stored
7sequencedir=/magic/sequences
8callistodir=/magic/data/callisto
9stardir=/magic/data/star
10# access to the sql database
11alias mymysql='mysql -s -u MAGIC -h vela --password=d99swMT!'
12# database name
13db=MyMagic
14
15
16# TODO
17
18# Spped up with SQL: FIELD(25123, 1, 2, 3, 4, 5, ..., 1000200);
19# Cross check sequences in Sequence and other databases
20# added switch which allows to correct for the problems immediatly
21# unify the checks (especially 1b and 1c)
22# for the sequences better use 0* instead of 0+ ?
23
24
25# CHECK 1
26echo Checking if all sequence files have a corresponding entry in Sequences
27files=`find $sequencedir -type f`
28for file in $files
29do
30 sequence=`echo $file | sed -e "s/^.*\/sequence0\+\([0-9]\+\)\.txt$/\1/"`
31 if [ "$sequence" = "" ]
32 then
33 echo No sequence file: $file
34 continue
35 fi
36
37 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
38 if ! [ "$sequence" = "$var" ]
39 then
40 echo Sequence-File $sequence exist but it is not in Sequences.
41 continue
42 fi
43done
44
45# CHECK 1b (callisto)
46echo Checking if all sequences in $callistodir have a corresponding sequence in Sequence
47dirs=`find $callistodir -type d`
48for dir in $dirs
49do
50 sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
51 if [ "$sequence" = "" ]
52 then
53 echo Invalid directory: $dir
54 continue
55 fi
56
57 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
58 if ! [ "$sequence" = "$var" ]
59 then
60 echo $dir exists but no corresponding sequence in Sequences.
61 continue
62 fi
63done
64
65# CHECK 1c (star)
66echo Checking if all sequences in $stardir have a corresponding sequence in Sequence
67dirs=`find $stardir -type d`
68for dir in $dirs
69do
70 sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
71 if [ "$sequence" = "" ]
72 then
73 echo Invalid directory: $dir
74 continue
75 fi
76
77 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
78 if ! [ "$sequence" = "$var" ]
79 then
80 echo $dir exists but no corresponding sequence in Sequences.
81 continue
82 fi
83done
84
85# CHECK 2
86echo Checking if all sequences in Sequences have a corresponding sequence files
87sequences=`echo SELECT fSequenceFirst FROM $db.Sequences | mymysql`
88for sequence in $sequences
89do
90 var=`find $sequencedir -type f -regex .*/sequence0+${sequence}\.txt$`
91 if [ "$var" = "" ]
92 then
93 echo Sequence-File for $sequence not found but in db.
94 fi
95done
96
97# CHECK 3
98echo Checking if all sequences from Sequences exists RunData
99sequences=`echo SELECT fSequenceFirst FROM $db.Sequences GROUP BY fSequenceFirst | mymysql`
100for sequence in $sequences
101do
102 res=`echo SELECT fSequenceFirst FROM $db.RunData WHERE fSequenceFirst=$sequence GROUP BY fSequenceFirst | mymysql`
103 if ! [ "$sequence" = "$res" ]
104 then
105 echo Sequence $sequence exists in Sequences but not in RunData.
106 continue
107 fi
108done
109
110# CHECK 4
111echo Checking if all sequences from RunData exists in Sequences
112sequences=`echo SELECT fSequenceFirst FROM $db.RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql`
113for sequence in $sequences
114do
115 var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
116 if ! [ "$sequence" = "$var" ]
117 then
118 echo Sequence $sequence exists in RunData but not in Sequences.
119 continue
120 fi
121done
122
Note: See TracBrowser for help on using the repository browser.