-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.sh
executable file
·807 lines (684 loc) · 19.9 KB
/
manage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
#!/bin/bash
#set -x
ARG0=$(basename $0)
function stderr() {
echo "${*}" 1>&2
}
YMLS=(
./postgresql/docker-compose.yml
# ./racedb/docker-compose.yml
./racedb/docker-compose-network.yml
# ./qllabels-qlmuxd/docker-compose.yml
# ./racedb/docker-compose-8080.yml
# ./racedb/docker-compose-8081.yml
)
POSTGRESS=( postgresql )
RACEDB=( racedb_8080 racedb_8081 )
QLMUXD=( qllabels_direct qllabels_qlmuxd )
VARLIB="./postgresql-varlib"
VARDATA="./postgresql-vardata"
INITDB="./postgresql-initdb.d"
ROLEPATH="${VARLIB}/.ROLE"
ARGSPATH="${VARLIB}/.ARGS"
OLDROLEPATH="${VARLIB}/.OLDROLE"
TRIGGERPATH="${VARLIB}/trigger_file_standby_to_failover"
_inspect() {
RUNNING="$(docker inspect -f '{{.State.Running}}' $1)"
stderr RUNNING: $RUNNING
if [ -n "${RUNNING}" -a "${RUNNING}" = "true" ] ; then stderr inspect_OK; return 0 ;
else
stderr inspect_NOT ; return 1; fi
}
inspect() {
_inspect $1 2>/dev/null > /dev/null
#RC=$?
#echo RC: $RC
return $?
}
running() {
#if [ "$(docker inspect -f '{{.State.Running}}' $1)" = "true" ]; then
#echo RC: $RC
inspect $1
#RC=$?
#if [ "$RC" -eq 0 ]; then
if [ $? -eq 0 ]; then
#stderr $1: OK ;
return 0;
else
#stderr $1: NOT;
return 1;
fi
}
checkpostgres() {
BOOL=0
for N in "${POSTGRESS[@]}"; do
running $N
if [ $? -eq 0 ] ; then
if [ $BOOL -eq 1 ] ; then
stderr "Warning - second postgres container"
fi
stderr "Container $N running"
BOOL=1
fi
done
return $BOOL
}
checkracedb() {
BOOL=0
for N in "${RACEDB[@]}"; do
running $N
if [ $? -eq 1 ] ; then
stderr "Container $N running"
BOOL=1
fi
done
return $BOOL
}
#checkpostgres
#POSTGRESS_RUNNING=$?
#checkracedb
#RACEDB_RUNNING=$?
#echo POSTGRESS_RUNNING: $POSTGRESS_RUNNING
#echo RACEDB_RUNNING: $RACEDB_RUNNING
running postgresql_racedb && POSTGRESQL_RACEDB_RUNNING=1 || POSTGRESQL_RACEDB_RUNNING=0
#echo POSTGRESQL_RACEDB_RUNNING: $POSTGRESQL_RACEDB_RUNNING
#running racedb_8080
#running postgresql_primary
#running postgresql_standby
cmdlist() {
for i in "${YMLS[@]}"; do
if [ ! -e "${i}" ] ; then
stderr "Cannot find $i"
exit 1
fi
echo -f "$i";
done
}
YMLLIST=$(cmdlist)
roleusage() {
stderr
stderr "Postgress roll is not set."
stderr
stderr "Use ./manage.sh primary | standby to set database roll."
stderr
exit 1
}
setrole() {
#case "${1}" in
#failover)
# set -x
# touch "${TRIGGERPATH}"
# set +x
# ;;
#*) [ -f "${TRIGGERPATH}" ] && rm -fv "${TRIGGERPATH}" ;;
#esac
[ -f "${ROLEPATH}" ] && cat "${ROLEPATH}" >> "${OLDROLEPATH}"
cat > "${ROLEPATH}" << EOF
# DO NOT HAND EDIT
# use ./manage.sh primary | hot_standby
ROLE=$1
EOF
}
osetargs() {
stderr ARGSPATH: $ARGSPATH
set -x
cat << EOF > "${ARGSPATH}"
${*}
EOF
ls -ltra postgresql-varlib
}
#setargs() {
# stderr ARGSPATH: $ARGSPATH
# set -x
# (echo "${*}") > "${ARGSPATH}"
# #ls -ltra postgresql-varlib
#}
if [ -f "${ROLEPATH}" ] ; then
. "${ROLEPATH}"
case ${ROLE,,} in
primary | hot_standby | failover | restore ) ;;
*) ROLE=no_role ;;
esac
stderr "ROLE: $ROLE"
fi
RACEDB=racedb_8080
DOCKERCMD="docker-compose ${YMLLIST}"
checkconfig() {
stderr
stderr ROLE: $ROLE
stderr YMLLIST: $YMLLIST
stderr DOCKERCMD: $DOCKERCMD
}
stop() {
echo "Stopping RaceDB Container set..."
set -x
$DOCKERCMD stop
}
start() {
echo "Starting RaceDB Container set..."
set -x
$DOCKERCMD up -d
}
restart() {
stop
sleep 2
start
$DOCKERCMD restart
}
failover() {
if [ ${POSTGRESQL_RACEDB_RUNNING} -eq 1 ] ; then
stderr "RaceDB Containers running, doing dumpall prior to failover"
dumpall
else
stderr "RaceDB Containers not running, cannot dumpall first"
fi
stderr "Configuring Failover"
set -x
setrole failover
set -x
touch "${TRIGGERPATH}"
set +x
}
fallback() {
setrole hot_standby
rm -fv "${VARLIBTRIGGERPATH}"
}
erase_db() {
stderr "Erasing DB ..."
set -x
rm -rf "${VARDATA}"
set +x
}
dumpall()
{
DATE=$(date +%Y%m%d-%H%M%S)
FILENAME="${VARLIB}/${ROLE}-${DATE}.sql.gz"
stderr
stderr "dumpall: creating compressed sql backup: ${FILENAME}"
( docker exec --user postgres -i postgresql_racedb pg_dumpall --clean ) | gzip -9 > "${FILENAME}"
}
restore_sql() {
# setrole restore_sql
# setargs "SQLGZ=$(basename $1)"
if [ ! -f "$1" ] ; then
stderr "Cannot see $1"
exit 1
fi
set -x
#gunzip < "$1" | docker exec -i --user postgres postgresql_racedb psql -v ON_ERROR_STOP=1 --username postgres --no-password
gunzip < "$1" | docker exec -i --user postgres postgresql_racedb psql --username postgres --no-password
set +x
}
#primary_restore_local() {
# setrole restore_local
# setargs "BACKUP=$(basename $1)"
#}
#primary_restore_host() {
# setrole restore_local
# setargs "restore_host $1"
#}
pull() {
echo "Starting RaceDB Container set..."
set -x
$DOCKERCMD pull
}
logs() {
$DOCKERCMD logs
}
flogs() {
$DOCKERCMD logs -f
}
bash() {
echo "You are now running commands inside the racedb container"
echo
set -x
$DOCKERCMD exec $RACEDB /bin/bash
}
manage() {
$DOCKERCMD exec $RACEDB /RaceDB/manage.py $@
}
images() {
$DOCKERCMD images
}
services() {
$DOCKERCMD ps --services
}
ps() {
set -x
[ -n "$1" ] && export FILTER="--filter name=$1"
$DOCKERCMD ps $FILTER
}
update() {
stop
echo "Updating RaceDB and PostgreSQL containers (if available)"
$DOCKERCMD pull
}
#build() {
# if [ ! -f "$COMPOSEFILE" ]; then
# echo "ERROR: Command must be run from same directory as the $COMPOSEFILE file."
# exit 1
# fi
# . .dockerdef
# docker build -t $IMAGE:$TAG .
#}
#rebuild() {
# if [ ! -f "$COMPOSEFILE" ]; then
# echo "ERROR: Command must be run from same directory as the $COMPOSEFILE file."
# exit 1
# fi
# . .dockerdef
# docker build -t $IMAGE:$TAG --no-cache .
#}
cleanall() {
# if [ ! -f "$COMPOSEFILE" ]; then
# echo "ERROR: Command must be run from same directory as the $COMPOSEFILE file."
# exit 1
# fi
echo -n "About to wipe all the RaceDB data and configuration!! Are you sure? THIS CANNOT BE UNDONE! (type YES): "
read ENTRY
if [ "$ENTRY" = "YES" ]; then
stop
RACEDBCONTAINERS=$(docker container list -a | grep racedb_app | awk '{ print $1 }')
for container in $RACEDBCONTAINERS
do
echo "Removing container: $container"
docker container rm -f $container
done
RACEDBIMAGES=$(docker image list | grep racedb | awk '{print $3}')
for image in $RACEDBIMAGES
do
echo "Removing image: $image"
docker image rm -f $image
done
VOLUMES=$(docker volume list | grep racedb | awk '{print $2}')
for volume in $VOLUMES
do
echo "Removing RaceDB volume: $volume"
docker volume rm $volume
done
NETWORKS=$(docker network list | grep racedb | awk '{print $2}')
for network in $NETWORKS
do
echo "Removing RaceDB network: $network"
docker network rm $network
done
if [ -f RaceDB.sqlite3 ]; then
echo "Removed old RaceDB.sqlite3"
rm -f RaceDB.sqlite3
fi
else
echo "Clean cancelled"
fi
}
#restoredata()
#{
# filename=$1
#
# if [ -n "${filename}" ] ; then
#
# #if [ ! -f "racedb-data/${filename}" ];then
# # echo "racedb-data/${filename} does not exist"
# # exit 1
# #fi
# echo "Importing racedb-data/${filename}..."
#
# set -x
# $DOCKERCMD exec $RACEDB python3 /RaceDB/manage.py flush
# $DOCKERCMD exec -T $RACEDB python3 /RaceDB/manage.py loaddata /racedb-data/${filename}
# fi
#}
restore_tgz() {
TGZ=$1
if [ ! -f "$1" ] ; then
stderr
stderr "restore_tgz: cannot see file ${TGZ}" stderr
exit 1
fi
set -x
rm -rf ${VARDATA}/*
tar xfz ${TGZ} --one-top-level=${VARDATA}
exit 0
}
backupdata()
{
filename=$1
if [ -z "$filename" ]; then
DATE=$(date +%Y%m%d-%H%M%S)
filename="racedb-export-${DATE}.json"
fi
echo "Backing up in $RACEDB:/racedb-data/${filename}... "
set -x
$DOCKERCMD exec $RACEDB python3 /RaceDB/manage.py dumpdata core --indent 2 --output /racedb-data/${filename}
set +x
echo "Export saved to racedb-data/${filename}..."
}
importdata()
{
filename=$1
if [ "-" = "${filename}" ]; then
echo "Importing from <stdin>"
set -x
$DOCKERCMD exec -T $RACEDB python3 /RaceDB/manage.py flush --no-input
$DOCKERCMD exec -T $RACEDB python3 /RaceDB/manage.py loaddata --format=json -
elif [ -n "${filename}" ] ; then
#if [ ! -f "racedb-data/${filename}" ];then
# echo "racedb-data/${filename} does not exist"
# exit 1
#fi
echo "Importing racedb-data/${filename}..."
set -x
$DOCKERCMD exec $RACEDB python3 /RaceDB/manage.py flush
cat ${filename} | $DOCKERCMD exec -T $RACEDB python3 /RaceDB/manage.py loaddata --format=json -
fi
}
exportdata()
{
set -x
filename=$1
if [ "-" = "${filename}" ]; then
echo "Exporting to <stdout>"
set -x
$DOCKERCMD exec -T $RACEDB python3 /RaceDB/manage.py dumpdata core --indent 2
else
if [ -z "$filename" ]; then
DATE=$(date +%Y%m%d-%H%M%S)
filename="${HOSTNAME}-racedb-export-${DATE}.json"
fi
echo "Exporting from $RACEDB to ${filename}..."
set -x
( $DOCKERCMD exec -T $RACEDB python3 /RaceDB/manage.py dumpdata core --indent 2 ) > ${filename}
set +x
echo "Export saved to ${filename}..."
fi
}
reader() {
READER=$1
if [ -z "$READER" ]; then
echo "You must specify the reader name or ip"
exit 1
fi
if (echo "$READER" | grep -Eq "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); then
READER_IP=$READER
elif (echo "$READER" | grep -Eq ".*\.local$"); then
if [ "$(uname -s)" == "Darwin" ]; then
READER_IP=$(ping -c 1 "$READER" | grep from | awk '{print $4}' | awk -F':' '{print $1}')
else
READER_IP=$(avahi-resolve -n "$READER" | awk '{print $2}')
fi
else
READER_IP=$(host $READER | awk '{print $4}')
if [ "$READER_IP" == "found:" ]; then
echo "READER ip not found"
exit 1
fi
fi
if [ -z "$READER_IP" ];then
echo "Error finding reader IP"
exit 1
fi
echo "Reader IP is $READER_IP"
grep -v RFID_READER_HOST racedb.env > racedb.env.tmp.$$
echo "RFID_READER_HOST=$READER_IP" >> racedb.env.tmp.$$
cp racedb.env racedb.env.bak
mv racedb.env.tmp.$$ racedb.env
echo "racedb.env updated"
}
# ###############################################################################################################################
CMD=$1
shift
# ###############################################################################################################################
# No Role Set
usage_norole() {
stderr
stderr "RaceDB Containers NO ROLE"
stderr "Usage: ./manage.sh primary | hot_standy | restore"
stderr " primary - operate as primary RaceDB"
stderr " hot_standby - operate as hot_standby RaceDB"
stderr " restore - restore from backup"
exit 1
}
case "${ROLE}" in
primary | hot_standby | failover | restore)
stderr "ROLE: ${ROLE}"
# ROLE is set
;;
* )
stderr "ROLE: NOT SET"
# ROLE is not set
if [ -z "${CMD}" ] ; then
echo CCCC
usage_norole
fi
case "${CMD}" in
primary | hot_standby | restore ) setrole "${CMD}";;
standby ) setrole hot_standby;;
help | *) echo DDDD; usage_norole;;
esac
exit 0
;;
esac
# ###############################################################################################################################
# Not Running
usage_notrunning() {
stderr
stderr "RaceDB Containers [${ROLE^^}] NOT RUNNING"
stderr "${ARG0} Commands:"
stderr
stderr " help - display usage"
stderr " start - display usage"
stderr
stderr " primary - start as primary using current database"
stderr " standby - change role to HOT-STANDBY"
stderr " restore - change role to RESTORE"
stderr
case "${ROLE}" in
primary | restore_* )
;;
restore)
stderr
stderr " sql - restore from local sql backup and start"
stderr " tgz - restore from local filesystem backup and start"
stderr " host - restore from another host and start"
stderr
;;
hot_standby | standby)
stderr
stderr " failover - change role from HOT-STANDBY to FAILOVER"
stderr
;;
failover)
stderr
;;
*)
stderr " Role not set"
stderr " primary"
stderr " standby"
stderr " restore"
exit 1
;;
esac
exit 0
}
if [ ! ${POSTGRESQL_RACEDB_RUNNING} -eq 1 ] ; then
case "${ROLE}-${CMD}" in
restore-tgz) restore_tgz ${*} ;;
esac
case "${CMD}" in
primary | hot_standby | restore ) setrole "${CMD}";;
standby ) setrole hot_standby;;
start ) start;;
help | *) usage_notrunning;;
esac
exit 0
fi
# ###############################################################################################################################
# Running
usage_running() {
stderr
stderr "RaceDB Containers [${ROLE^^}] RUNNING"
stderr "${ARG0} Commands:"
stderr " help - display usage"
stderr " restart - stop and restart RaceDB as ${ROLE^^}"
stderr " stop - stop RaceDB as ${ROLE^^}"
stderr " dumpall - do a pg_dumpall backup"
case "${ROLE}" in
primary)
stderr " dumpall - do a pg_dumpall backup"
;;
hot_standby)
stderr " failover - enable HOT-STANDBY FAILOVER (with immediate effect, no restart"
stderr " primary - promote HOT-STANDBY to PRIMARY (will restart)"
;;
failover)
stderr " hot_standby - change FAILOVER back to HOT-STANDBY (will restart)"
stderr " primary - promote HOT-STANDBY to PRIMARY"
;;
*) ;;
esac
}
if [ ${POSTGRESQL_RACEDB_RUNNING} -eq 1 ] ; then
case "${ROLE}-${CMD}" in
restore-sql) restore_sql ${*} ;;
esac
case "${CMD}" in
stop ) stop ;;
restart ) restart ;;
primary | hot_standby | restore ) stop; setrole "${CMD}"; start;;
standby ) stop; setrole hot_standby; start;;
help | *) echo BBBB;usage_running;;
esac
exit 0
fi
exit 0
# ###############################################################################################################################
# Old
usage() {
DATE=$(date +%Y%m%d-%H%M%S)
if [ ${POSTGRESQL_RACEDB_RUNNING} -eq 1 ] ; then
else
fi
return
stderr " Manage containers"
stderr " pull - pull newer images from docker hub"
stderr " run - start the racedb containers"
stderr " stop - stop the racedb containers"
stderr " restart - stop and restart the racedb containers"
stderr " ps - list running racedb containers"
stderr " logs name - show the named racedb container log"
stderr " flogs name - show the named racedb container log and display continuously"
stderr
stderr " Access containers"
stderr " bash name - run bash shell in named running container"
stderr
stderr " RaceDB Manage"
stderr " manage name - run manage.py in named running container, passes additional args to manage"
stderr
stderr " Backup and Restore RaceDB in container"
stderr " backup - export database to $RACEDB/racedb-data/racedb-export-$DATE.json"
stderr " backup filename - export database to $RACEDB/racedb-data/filename"
stderr " restore filename - restore database from $RACEDB/racedb-data/filename"
stderr
stderr " Export and Import RaceDB to files on $(hostname)"
stderr " export - export database to /racedb-data/racedb-export-$DATE.json"
stderr " export filename - export database to filename"
stderr " export - - export database to <stdout> in json file format"
stderr " import filename - import new database from $RACEDB/racedb-data/filename"
stderr " import - - import new database from <stdin> json file format"
stderr
stderr " reader ip|name - updates racedb.env with the reader ip"
stderr
stderr "Use a webbrowser to login to RaceDB: http://localhost"
stderr
}
[ $# -eq 0 ] && usage && exit
CMD=$1
shift
if [ ${POSTGRESQL_RACEDB_RUNNING} -eq 1 ] ; then
stderr "RaceDB Containers running - ${ROLE}"
case $CMD in
stop) stop; exit 0 ;;
restart) restart; exit 0 ;;
*) ;;
esac
case "${ROLE}-${CMD}" in
restore_sql ) restore_sql "${*}"; start;;
hot_standby-failover) failover ; exit 0;;
failover-fallback) stop; fallback; start ; exit 0;;
failover-dumpall | primary-dumpall) dumpall; exit 0;;
failover-promote) stop; setrole primary; start; exit 0;;
*) ;;
esac
case $CMD in
hot_standby | standby | primary ) stderr "Containers running cannot change role, stop first";;
*);;
esac
else
stderr "RaceDB Containers NOT RUNNING - ${ROLE}"
case $CMD in
start | run) start; exit 0 ;;
restart) restart; exit 0 ;;
primary) setrole primary; start; exit 0 ;;
hot_standby | standby) setrole hot_standby; start; exit 0 ;;
restore) setrole restore; start; exit 0 ;;
*) ;;
esac
stderr "ROLE: $ROLE CMD: $CMD"
set -x
case "${ROLE}-${CMD}" in
#*-restore_sql ) primary_restore_sql "${*}"; start;;
#primary-restore_local | hot_standby-restore_local) primary_restore_local "${*}"; start;;
#primary-restore_host | hot_standby-restore_host) primary_restore_host "${*}"; start;;
hot_standby-failover | standby-failover) failover; exit 0;;
failover-fallback) fallback; exit 0;;
failover-primary | failover-promote) setrole primary; exit 0;;
esac
fi
exit
ROLECMD="$ROLE-$CMD"
stderr ROLE-CMD: $ROLECMD
set -x
case "$ROLECMD" in
primary-restore_local) ;;
primary-restore_remote) ;;
primary-standby) ;;
hot_standby-failover | standby-failover) ;;
hot_standby-promote | standby-promote) ;;
failover-demote) ;;
failover-primary) ;;
"standby-failover-fallback") fallback ;;
*) echo "Unknown: \"$ROLECMD\""
esac
exit
#case "$CMD" in
# "failover") failover ;;
# "fallback") fallback ;;
# #"master") master
# # ;;
# #"standby") standby
# # ;;
# "pull") pull ;;
# "run" | "start") run ;;
# "restart") restart ;;
# "bash") bash ;;
# "update") update ;;
# "logs" | "log") logs ;;
# "flogs" | "flog") flogs ;;
# "stop") stop ;;
# "images") images ;;
# "services") services ;;
# "ps") ps $1 ;;
# "manage") manage $@ ;;
# "backup") backupdata $@ ;;
# "restore") restoredata $@ ;;
# "import") importdata $@ ;;
# "export") exportdata $@ ;;
# "clean") cleanall ;;
# "build") build
# ;;
# "rebuild") build
# ;;
# "reader") reader $@ ;;
# *) echo "Unknown command."
# usage
# ;;
#esac