gen_sql 16.7 KB
Newer Older
1
2
#! /usr/local/bin/bash

Dan Reading's avatar
Dan Reading committed
3
4
5
# let the checkutils.sh script know we are running offline
declare -i offline=1

6
7
8
source checkutils.sh


9
checkdrift_main() {
10
    declare -i countsame=1 filecount=0 hostcount=0 
Dan Reading's avatar
Dan Reading committed
11
12
    declare -i tellNoSN=0 tellNonMFS=0; 
    declare print_blank=no
13
    for host in $allnodes ; do
Dan Reading's avatar
Dan Reading committed
14
	print_blank=yes
Dan Reading's avatar
Dan Reading committed
15
	((hostcount++))
16
17
	if [ -d $projdir/$host/.tbdb ] ; then
	    cd $projdir/$host/.tbdb
18
	    allchecks=$(ls | sort -r | paste -s -d \\\  -) # paste command used to convert into space seperated words.
19
	    allchecks+=' ' # grrr my string matching, expects space at end
20

21
	    # set newest file and take off list
22
23
	    newest=${allchecks%%\ *}
	    allchecks=${allchecks#* } # pop the list
24
	    [[ ! $allchecks ]] && continue # ran out of files for this node
Dan Reading's avatar
Dan Reading committed
25

26
	    #only compare inventory computed in mfsmode=1
27
            # from the top of list skip file that have mfsmode=0
Dan Reading's avatar
Dan Reading committed
28
29
	    while (grep -c 'ismfs=0' $newest &> /dev/null ) ; do
		newest=${allchecks%%\ *} # take off the top
30
		allchecks=${allchecks#* } # pop the list
31
		[[ ! $allchecks ]] && break # ran out of files, break from loop
32
	    done
33
	    [[ ! $allchecks ]] && continue # make sure we didn't consume all the file for node
Dan Reading's avatar
Dan Reading committed
34
	    if (( $tellNoSN )); then
35
36
	    # X X X Hackitly Hackit Hack
	    # drop those files that have empty SN, but report it
Dan Reading's avatar
Dan Reading committed
37
38
39
40
41
	    if [ "$(grep 'DISKUNIT TYPE' $newest)" -o "$(grep 'DISKUNIT SECSIZE' $newest)" ] ; then
		echo "===> Missing SN in $host $(pwd)/$newest"
# pop or not to pop - that is the question (ignore !SN file or process)
#::		newest=${allchecks%%\ *} # take off the top
#::		allchecks=${allchecks#* } # pop the list
42
43
		[[ ! $allchecks ]] && continue # ran out of files
	    fi
Dan Reading's avatar
Dan Reading committed
44
	    fi
45

Dan Reading's avatar
Dan Reading committed
46
47
	    # read $newset into the hwinvcopy array, hwinvcopy array has
	    # been declared in the checkutils.sh script
48
49
	    readtmcinfo $newest hwinvcopy
	    for tocheck in $allchecks ; do
Dan Reading's avatar
Dan Reading committed
50
51
52
		if (( ! $tellNonMFS )) ; then
		# if not in ismfs mode then don't check
 		[[ $(grep 'ismfs=0' $tocheck) ]] && continue 
53
		fi
54
55
56
		readtmcinfo $tocheck hwinv
		# note: will check against self for sanity
		comparetmcinfo /tmp/.$$checkdiff
Dan Reading's avatar
Dan Reading committed
57
		((filecount++))
58
		if [ -s /tmp/.$$checkdiff ] ; then
Dan Reading's avatar
Dan Reading committed
59
60
61
		    [[ "$print_blank" == "yes" ]] && { echo ""; print_blank=no; }
		    echo "$host generated tbdb $newest $tocheck are not the same"
		    echo "==============================================================="
62
63
64
		    cat /tmp/.$$checkdiff
#		    echo "diff $tocheck $newest"
#		    diff $tocheck $newest
65
		    # reset compare file
66
67
		    newest=$tocheck
		    readtmcinfo $newest hwinvcopy
68
69
70
71
72
73
74
		    # XXX - start
		    # XXX Do not enable this code unless you want
		    # the files moved out of the way
#		    [[ ! -d $projdir/$host/.tbdb/.notsame ]] && sudo mkdir -p $projdir/$host/.tbdb/.notsame 
#		    sudo mv $tocheck $projdir/$host/.tbdb/.notsame
		    # XXX - end
		else
Dan Reading's avatar
Dan Reading committed
75
# : echo "$host $newest $tocheck SAME"
76
77
78
79
		    ((countsame++))
		fi
		rm -f /tmp/.$$checkdiff
	    done
Dan Reading's avatar
Dan Reading committed
80
# :[[ $countsame -gt 1 ]] && echo "$host $countsame inventory files are the same"
81
# :	    echo -n .
82
83
84
85
	else
	    echo "No record of node id \"$host\"."
	fi
    done
Dan Reading's avatar
Dan Reading committed
86
87
    echo ""
    echo "$filecount files in $hostcount nodes checked"
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
}
checkwce_main() {

    for host in $allnodes ; do
	if [ -f $projdir/$host/full ] ; then

	#    wcestate=$(grep $projdir/$host/full$)
	    readtmcinfo $projdir/$host/full hwinv
	    numberofdrives=${hwinv["DISKINFO"]}
	    numberofdrives=${numberofdrives/DISKINFO UNITS=/}
	    
            for ((idx=0; idx<${numberofdrives}; idx++)) ; do
		unset -v d ; declare -a d=(${hwinv["DISKUNIT$idx"]})
                wce=${d[2]}
		if [ "$wce" != "${wce/enabled}" ] ; then
		    :
		elif [ "$wce" != "${wce/disabled}" ] ; then
		    x=${d[1]}
		    x=${x##*SN=}; x=${x%% *}; x=${x//\"/}
		    echo "$host ${d[8]} Write Cache Disabled bsidx=$(get_bsidx_from_sn $x)"
		else
		    :
		fi
            done

113
114
115
116
117
118
	else
	    echo "No record of node id \"$host\"."
	fi
    done
}

Dan Reading's avatar
Dan Reading committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#   README
#   to get HD info from serial number
# select b.node_id,b.bs_id,b.bsidx,a.attrvalue from blockstores as b,blockstore_attributes as a where b.bsidx=a.bsidx and b.role='element' and a.attrkey='serialnum' and a.attrvalue='$sn';
#   to get HD info from node_id
# select b.node_id,b.bs_id,b.bsidx,a.attrvalue from blockstores as b,blockstore_attributes as a where b.bsidx=a.bsidx and b.role='element' and a.attrkey='serialnum' and b.node_id='pc510';
#
#   to get bsidx from serial number
# db_bsidx=$(mysql -B -N -e "select b.bsidx from blockstores as b,blockstore_attributes as a where b.bsidx=a.bsidx and b.role='element' and a.attrkey='serialnum' and a.attrvalue='$sn';" tbdb)
#   to get serial number from bsidx
# db_sn=$(mysql -B -N -e "select a.attrvalue from blockstores as b,blockstore_attributes as a where b.bsidx=a.bsidx and b.role='element' and a.attrkey='serialnum' and b.bsidx=$bsidx;" tbdb);

get_bsidx_from_sn() {
    echo $(mysql -B -N -e "select b.bsidx from blockstores as b,blockstore_attributes as a where b.bsidx=a.bsidx and b.role='element' and a.attrkey='serialnum' and a.attrvalue='$1';" tbdb)
}
get_sn_from_bsidx() {
    echo $(mysql -B -N -e "select a.attrvalue from blockstores as b,blockstore_attributes as a where b.bsidx=a.bsidx and b.role='element' and a.attrkey='serialnum' and b.bsidx=$1;" tbdb);
}
get_host_from_bsidx() {
    echo $(mysql -B -N -e "select node_id from blockstores where bsidx=$1;" tbdb);
}
get_drive_from_bsidx() {
    echo $(mysql -B -N -e "select bs_id from blockstores where bsidx=$1;" tbdb);
}
142
143
144
get_bsidx_from_hostAnddrive() {
    echo $(mysql -B -N -e "select bsidx from blockstores where node_id=\"$1\" and bs_id=\"disk${2}\";" tbdb)
}
Dan Reading's avatar
Dan Reading committed
145

146
gentbsql_main() {
Dan Reading's avatar
Dan Reading committed
147
    local sn="UNK" hdtype="UNK" secsize="UNK" sectors="UNK" wspeed="UNK" rspeed="UNK"
148
    # get current unique BlockStore number from tbdb
Dan Reading's avatar
Dan Reading committed
149
150
    bsidx_base=$(mysql -B -N -e "select idx from emulab_indicies where name='next_bsidx';" tbdb)
    keep_bsidx_base=$bsidx_base
Dan Reading's avatar
Dan Reading committed
151
152
153
    # XXX
    # try to fill gaps above 1000, good idea?
    bsidx_base=1000
Dan Reading's avatar
Dan Reading committed
154
    
155
    for host in $allnodes ; do
156
157
	if [ -d $projdir/$host ] ; then
	    cd $projdir/$host
Dan Reading's avatar
Dan Reading committed
158
	    sn="UNK" hdtype="UNK" secsize="UNK" sectors="UNK" wspeed="UNK" rspeed="UNK"
159
#	    [[ -f "diff" ]] || { echo "# $host: No changes needed"; continue; }
160
	    # need the diff and node files to continue. No diff then nothing to update
161
	    [[ -f "diff" ]] || continue;
Dan Reading's avatar
Dan Reading committed
162
	    [[ -f "node" ]] || { echo "# $host: Missing node file"; continue; }
163
	    # check for old version of file
164
	    if [ -z "$(grep "Diff Report" diff)" ] ; then
Dan Reading's avatar
Dan Reading committed
165
		echo "# $host Inventory Report to old to use"
166
167
		continue
	    fi
168

169
170
171
	    # we need a diff file that has SN in it, check the .diff directory
	    # for the info
	    # so try and find the SN in any .full/* file with serial numbers
172
# debugging	    echo "# $(pwd)"
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
	    dotDiffFiles=$(ls -t .diff)
	    for dDF in $dotDiffFiles ; do
		SNinfo=$(grep 'DISKs:' .diff/$dDF | grep -v UNKNOWN)
		[[ $SNinfo ]] && break # found, stop
	    done
	    # if we failed to find a file then default to the sym link
	    # else we found it 
	    if [ "$SNinfo" ] ; then
		indexF=$dDF
		diffFile=.diff/$dDF
		nodeFile=.tbdb/$dDF
	    else
		indexF=$(pwd)
		diffFile=diff
		nodeFile=node
	    fi
	    listofdisks=$(grep 'DISKs:' $diffFile)
	    listofdisks=${listofdisks//DISKs:}  # take string out
Dan Reading's avatar
Dan Reading committed
191
	    hdnum=0
192
193
194
195
196
	    # if 'DISKs:' is empty then try OUT OF ORDER message
	    if [ -z "$listofdisks" ]; then
		local_listofdisks=$(grep 'OUT OF ORDER' $diffFile)
		# remove up to first 'local['
		local_listofdisks=${local_listofdisks#*local\[}
Dan Reading's avatar
Dan Reading committed
197
		# remove from ']' to end
198
		local_listofdisks=${local_listofdisks%%]*}
Dan Reading's avatar
Dan Reading committed
199
200
201
                # have a second case where "ERROR DISK OUT OF ORDER"
                # remove up to 'from tbdb'
		local_listofdisks=${local_listofdisks#*from\ tbdb\ }
202
203
204
205
206
207
                for i in $local_listofdisks ; do
		    [[ $i == "UNKNOWN" ]] && continue
		    echo "# Local $host disks out of order - rewrite order this run. Run $0 again"
		    echo "mysql -e \"delete from blockstore_attributes where attrvalue='$i';\" tbdb"
		    listofdisks="$listofdisks $i"
                    done
Dan Reading's avatar
Dan Reading committed
208
echo "### not enabled - sudo rm $projdir/$host/diff"
209
	    fi
210
	    for i in $listofdisks ; do
211

212
		toadd=$(grep $i $nodeFile)
213
214
		if [ -n "$toadd" ] ; then
		    toadd=${toadd/DISKUNIT}
Dan Reading's avatar
Dan Reading committed
215
216
217
218
219
220
		    if [ "${toadd/SN=}" != "$toadd" ]; then
			sn=${toadd##*SN=}
			sn=${sn%% *}
			sn=${sn//\"/}
			# check and see if serial number is already in database
			bsidx=$(get_bsidx_from_sn $sn)
221
			[[ "$bsidx" ]] && continue
Dan Reading's avatar
Dan Reading committed
222
223
		    fi

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
		    # /* by Mike's orders
		    #  type		"class"	"protocol"	"rot-speed"	nodes with this type
		    # 
		    #  pata-generic	local	PATA		7200		pc600,pc850,pc2000
		    #  scsi-generic	local	SCSI		10000		pc3000,pc6000
		    #  sata-generic	local	SATA		7200		pc2400w,d710,d820,pcivy
		    #  sas-generic	local	SAS		10000		d820
		    #  ssd-generic	local	SATA		0		gpuhost,d820(pc601)
		    #  c2100-sas	local	SAS		15000		c2100
		    # */
		    nodetype=$(mysql -B -N -e "select type from nodes where node_id='$host';" tbdb)
		    case $nodetype in
			pc600 | pc850 | pc2000 ) hdtype="pata-generic" ;;
			pc3000 | pc6000 ) hdtype="scsi-generic" ;;
			pc2400w | d710 | d820 | pcivy ) hdtype="sata-generic" ;;
			d820 ) hdtype="sas-generic" ;;
			gpuhost ) hdtype="ssd-generic" ;;
			c2100 ) hdtype="c2100-sas" ;;
			* ) 
			    hdtype=${toadd##*TYPE=}
			    hdtype=${hdtype%% *}
			    ;;
		    esac
		    # translate type
		    [[ "$hdtype" == "SATA" ]] && hdtype="sata-generic"
		    [[ "$hdtype" == "PATA" ]] && hdtype="pata-generic"
		    [[ "$hdtype" == "SAS" ]] && hdtype="sas-generic"
		    # XXX XXX XXX special case
		    if [ "$host" == "pc601" ] ; then
			hdtype="ssd-generic"
		    fi
		    # XXX XXX XXX special case
Dan Reading's avatar
Dan Reading committed
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
		    if [ "${toadd/SECSIZE=}" != "$toadd" ]; then
			secsize=${toadd##*SECSIZE=}
			secsize=${secsize%% *}
		    fi
		    if [ "${toadd/SECTORS=}" != "$toadd" ]; then
			sectors=${toadd##*SECTORS=}
			sectors=${sectors%% *}
		    fi
		    if [ "${toadd/RSPEED=}" != "$toadd" ]; then
			rspeed=${toadd##*RSPEED=}
			rspeed=${rspeed%% *}
		    fi
		    if [ "${toadd/WSPEED=}" != "$toadd" ]; then
			wspeed=${toadd##*WSPEED=}
			wspeed=${wspeed%% *}
		    fi
		    size=$(($sectors / 2048))
		    # check and see if bsidx already used
		    while [ "$(mysql -B -N -e "select bsidx from blockstores where bsidx=$bsidx_base;" tbdb)" ] ; do
			echo "# bsidx=$bsidx_base already used, bumping bsidx_base again"
			((++bsidx_base))
		    done
                    # check and see if drive already used
279
280
		    found_blockstores_idx=''
		    found_blockstoreattr_idx=''
Dan Reading's avatar
Dan Reading committed
281
		    while [ "$(mysql -B -N -e "select bs_id from blockstores where node_id=\"$host\" and bs_id=\"disk${hdnum}\";" tbdb)" ] ; do
282
283
284
			# found a driveX on this host - see what we can find in the db
			found_blockstores_idx=''
			found_blockstoreattr_idx=''
285
			found_blockstores_idx=$(get_bsidx_from_hostAnddrive $host ${hdnum})
286
287
288
			found_blockstoreattr_idx=$(get_sn_from_bsidx $found_blockstores_idx)

			if [ "$found_blockstores_idx" ] ; then
289
			    echo -n "# $host drive${hdnum} already used @ bsidx=$found_blockstores_idx"
290
291
292
293
294
			    break
			else
			    echo "# drive${hdnum} already used, bumping hdnum again"
			    ((++hdnum))
			fi
Dan Reading's avatar
Dan Reading committed
295
		    done
296
297
298
299
300
301
302
303
304
305
306
307
		    if [ "$found_blockstores_idx" ] ; then
			# have a blockstores idx, check if we are missing blockstore_attrs
			if [ ! "$found_blockstoreattr_idx" ] ; then
			    # create one
			    echo " BUT blockstore_attributes missing"
			    printf "mysql -e \"insert into blockstore_attributes values (%d, '%s', '%s', '%s');\" tbdb\n" "$found_blockstores_idx" "serialnum" "$sn" "string" 
			    # assume we don't have to update blockstores, but display entry
			    echo "# MATCHING BLOCKSTORES @ $(mysql -B -N -e "select bsidx,node_id,bs_id,total_size  from blockstores where bsidx=$found_blockstores_idx;" tbdb);"
			else
			    echo ""
			fi
		    else
308
309
310
311
312
313
314
315
316
			# just make sure we don't have an entry
			justcheck=$(mysql -B -N -e "select * from blockstore_attributes where attrvalue='$sn';" tbdb );
			if [ "$justcheck" ] ; then
			    echo "ERROR: tbdb Inconsistance  EXIT"
			    echo "bsidx=$bsidx_base but found $sn in blockstore_attributes"
			    mysql -e "select * from blockstore_attributes where attrvalue='$sn';" tbdb
			    exit
			fi

317
318
319
320
321
322
323
			printf "mysql -e \"insert into blockstores values (%d, '%s', 'disk%d', 0, '%s', 'element', %d, 1, now());\" tbdb\n" "$bsidx_base" "$host" "$hdnum" "$hdtype" "$size" 
			# now the second table
			printf "mysql -e \"insert into blockstore_attributes values (%d, '%s', '%s', '%s');\" tbdb\n" "$bsidx_base" "serialnum" "$sn" "string" 
			# used up a bsidx, incr bsidx
			((++bsidx_base))
		    fi
		    # FINALLY onto the next drive
Dan Reading's avatar
Dan Reading committed
324
		    ((++hdnum))
325
		else
Dan Reading's avatar
Dan Reading committed
326
		    if [ "$i" == "UNKNOWN" ] ; then
327
328
			x=$(get_bsidx_from_hostAnddrive $host ${hdnum})
			if [ -n "$x" ] ; then
329
			    echo -n "# Can not locate Serial Number for disk${hdnum} on $host"
330
331
332
333
334
335
			    # so try and find the SN in any .full/* file with serial numbers
			    dotFullFiles=$(ls .full)
			    for dFF in $dotFullFiles ; do
				SNinfo=$(grep -v 'SN="UNKNOWN"' .full/$dFF | grep DISKUNIT)
				[[ $SNinfo ]] && break # found some stop
			    done
336
			    echo " but found $(get_drive_from_bsidx $x) $(get_host_from_bsidx $x) @ bsidx=$x SN=$(get_sn_from_bsidx $x)" 
337
338
			else
			    echo ""
339
			fi
Dan Reading's avatar
Dan Reading committed
340
341
			((++hdnum))
		    else
342
			toadd="SN='$i'"
343
			if [ "$sn" != "UNK" ] ; then
344
345
346
347
348
349
			    x_bsidx=$(get_bsidx_from_sn $i)
			    [[ $x_bsidx ]] && y_hostid=$(get_host_from_bsidx $x_bsidx) || y_hostid=""
			    if [ -n "$x_bsidx" -a -n "$y_hostid" ] ; then
				printf "mysql -e \"delete from blockstores where node_id='%s' and bsidx='%s';\" tbdb\n" "$host" "$x_bsidx"
				printf "mysql -e \"delete from blockstore_attributes where attrkey='%s';\" tbdb\n" "$i"
			    else
Dan Reading's avatar
Dan Reading committed
350
				echo "#Discovery error node_id $host, full:has SN BUT node:does not"
351
352
353
				      # Have only seen this when the "full" file for host lists a hard drive, including SN
				      # but the "node" file does not have serial number for for the HD
			    fi
354
			fi
Dan Reading's avatar
Dan Reading committed
355
		    fi
356
		fi
357
358
	    done
	    listofnics=$(grep 'NICs:' diff)
359
	    listofnics=${listofnics//NICs:/}
360
361
	    for i in $listofnics ; do
		toadd=$(grep $i node)
362
		if [ -n "$toadd" ] ; then
Dan Reading's avatar
Dan Reading committed
363
364
365
366
		    toadd=${toadd/*ID=\"}
		    toadd=${toadd/\"}
		    uuid=$(uuidgen)
		    printf "#BYHAND mysql -e \"insert into interfaces set node_id='%s',mac='%s',card=X,port=X,interface_type='?',iface='ethX',role='?',uuid='$uuid';\" tbdb\n" "$host" "$toadd"
367
368
		else
		    toadd="ID=\"$i\""
Dan Reading's avatar
Dan Reading committed
369
		    printf "#BYHAND mysql -e \"delete from interfaces where node_id='%s' and %s;\" tbdb\n" "$host" "$toadd"
370
		fi
371
	    done
372
	else
373
	    echo "# No record of node id \"$host\"."
374
	fi
375
    done
Dan Reading's avatar
Dan Reading committed
376
    if [ $keep_bsidx_base -lt $bsidx_base ] ; then
377
	echo "# orginal bsidx=$keep_bsidx_base : new bsidx=$bsidx_base"
Dan Reading's avatar
Dan Reading committed
378
	printf "mysql -e \"update emulab_indicies set idx=%d where name='next_bsidx';\" tbdb\n" "$bsidx_base"
379
380
    else
	echo "# orginal bsidx=$keep_bsidx_base : new bsidx=$bsidx_base == no update"
Dan Reading's avatar
Dan Reading committed
381
    fi
382
383
384
385
386
387
388
389
390
}

setdirstructure() {
    # start XXX
    # decided to change names again, rename if old names -- XXX remove this after all node have run the new code
    # take into consideration if old directory structure was added to to a new directory structure 
    set -u
    projdir=/proj/emulab-ops/nodecheck
    cd $projdir
391
    allnodes=$(ls -d pc* pg* dbox* gpu* 2> /dev/null)
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
    dirs2workon=""
    for i in $allnodes; do [[ -L $i/$i.diff ]] && dirs2workon+="$i "; done
    owd=$PWD

    for host in $dirs2workon ; do
    	if [ -d ${projdir}/$host ] ; then
	    cd ${projdir}/$host
	    [[ -L $host.full ]] && rm $host.full
	    [[ -L $host.diff ]] && rm $host.diff
	    [[ -L $host ]] && rm $host
	    for i in full diff tbdb ; do
		if [ -d $i ] ; then
		    [[ ! -d .$i ]] && (mkdir .$i ; chmod g+x .$i)
		    list=$(ls -A $i)
		    for j in $list ; do
			mv $i/$j .$i
		    done
		    rmdir $i
		fi
	    done
	    cd $owd
	fi
    done
    
    # put links in place
    for i in $dirs2workon ; do
	cd $projdir/$i
	links="full diff node"
	for link in $links ; do
	    case $link in
		full | diff )
		    # make the symlinks
		    if [ ! -e ${link} -a -d .${link} ] ; then
			linkto=$(ls -t .${link} | head -1)
			if [ -n "$linkto" ] ; then
 			    ln -s .${link}/${linkto} $link
			fi
		    fi
		    ;;
		node )
		    if [ ! -e ${link} -a -d .tbdb ] ; then
			linkto=$(ls -t .tbdb | head -1)
			if [ -n "$linkto" ] ; then
 			    ln -s .tbdb/${linkto} $link
			    ln -s .tbdb/${linkto} $i
			fi
		    fi
		    ;;
	    esac
	done
    done
}

445
446
447
# start here
set -u
projdir=/proj/emulab-ops/nodecheck
448
# if projdir is automounted this should mount it
449
450
451
452
453
454
455
456
457
cd $projdir

if (( $# )) ; then
    allnodes="$@"
else
    nodes=$(ls */tmcc)
    allnodes=${nodes//\/tmcc/}
fi

458
if [ "$0" != "${0/setdir}" ] ; then
459
    setdirstructure
460
elif [ "$0" != "${0/sql}" ] ; then
461
    gentbsql_main $@
462
463
elif [ "$0" != "${0/drift}" ] ; then
    checkdrift_main $@
464
465
elif [ "$0" != "wce" ] ; then
    checkwce_main $@
466
467
else
    "Print useage help"
468
469
470
fi