7 echo " ./builder <command> [-d|--dryrun] [-a|--allfiles] [-s|--short] ..."
8 echo " ./builder <-h|--help|help>"
17 echo " add <filesql> [<filesql2> [..]]"
18 echo " del <filesql> [<filesql2> [..]]"
19 echo " dump [dumpfile]"
20 echo " dumpall [dumpfile]"
29 if [ "$SHORT" = "y" ]; then
30 sed "s/#PFX#/$PFX/g" | psql -a $pg_args 2>&1 | egrep 'ERROR|^-- MESG'
32 sed "s/#PFX#/$PFX/g" | psql -a $pg_args
39 if [ "$ALL_FILES" = "y" ]; then
45 if [ "$1" = "" ]; then
59 while [ $# -gt 0 ]; do
64 echo "MOCKPSQL params: $@"
81 if [ -f $HOME/.brisk-db.conf ]; then
82 source $HOME/.brisk-db.conf
83 elif [ -f $HOME/.db.conf ]; then
94 if [ -f $HOME/.brisk_install ]; then
95 source $HOME/.brisk_install
99 test "$DBHOST" != "" && pg_args="$pg_args -h $DBHOST"
100 test "$DBUSER" != "" && pg_args="$pg_args -U $DBUSER"
101 test "$DBPORT" != "" && pg_args="$pg_args -p $DBPORT"
102 test "$DBBASE" != "" && pg_args="$pg_args $DBBASE"
104 MATCH_DROP='^drop|^alter table.* drop '
109 su root -c "su postgres -c \"echo \\\"DBUser passwd: $DBPASS\\\" ; createuser -S -D -R -P $DBUSER && createdb -E utf8 -O $DBUSER $DBBASE\""
114 su root -c "su postgres -c \"dropdb $DBBASE && dropuser $DBUSER\""
117 ( echo "-- MESG: clean start" ; one_or_all $2 | egrep -i "$MATCH_DROP" | tac ; echo "-- MESG: clean end" ; ) | sqlexe
120 ( echo "-- MESG: build start" ; one_or_all $2 | egrep -iv "$MATCH_DROP" ; echo "-- MESG: build end" ; ) | sqlexe
123 ( echo "-- MESG: clean start" ; one_or_all $2 | egrep -i "$MATCH_DROP" | tac ; echo "-- MESG: clean end" ; \
124 echo "-- MESG: build start" ; one_or_all $2 | egrep -iv "$MATCH_DROP" ; echo "-- MESG: build end" ; ) \
132 psql $pg_args -t -q -A -F '|' $@
135 if [ $# -eq 1 ]; then
136 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE
138 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE > $1
142 if [ $# -eq 1 ]; then
143 pg_dump -h $DBHOST -U $DBUSER $DBBASE
145 pg_dump -h $DBHOST -U $DBUSER $DBBASE > $1
149 ( echo "-- MESG: add start" ; cat "$@" | egrep -iv "$MATCH_DROP" ; echo "-- MESG: add end" ; ) | sqlexe
152 ( echo "-- MESG: del start" ; cat "$@" | egrep -i "$MATCH_DROP" | tac ; echo "-- MESG: del end" ; ) | sqlexe
154 "help"|"-h"|"--help")