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 " res <filesql> [<filesql2> [..]]"
20 echo " dump [dumpfile]"
21 echo " dumpall [dumpfile]"
30 if [ "$SHORT" = "y" ]; then
31 sed "s/#PFX#/$PFX/g" | psql -a $pg_args 2>&1 | egrep 'ERROR|^-- MESG'
33 sed "s/#PFX#/$PFX/g" | psql -a $pg_args
40 if [ "$ALL_FILES" = "y" ]; then
46 if [ "$1" = "" ]; then
60 while [ $# -gt 0 ]; do
65 echo "MOCKPSQL params: $@"
82 if [ -f $HOME/.brisk-db.conf ]; then
83 source $HOME/.brisk-db.conf
84 elif [ -f $HOME/.db.conf ]; then
95 if [ -f $HOME/.brisk_install ]; then
96 source $HOME/.brisk_install
100 test "$DBHOST" != "" && pg_args="$pg_args -h $DBHOST"
101 test "$DBUSER" != "" && pg_args="$pg_args -U $DBUSER"
102 test "$DBPORT" != "" && pg_args="$pg_args -p $DBPORT"
103 test "$DBBASE" != "" && pg_args="$pg_args $DBBASE"
105 MATCH_DROP='^drop|^alter table.* drop |^delete '
110 su root -c "su postgres -c \"echo \\\"DBUser passwd: $DBPASS\\\" ; createuser -S -D -R -P $DBUSER && createdb -E utf8 -O $DBUSER $DBBASE\""
115 su root -c "su postgres -c \"dropdb $DBBASE && dropuser $DBUSER\""
118 ( echo "-- MESG: clean start" ; one_or_all $2 | egrep -i "$MATCH_DROP" | tac ; echo "-- MESG: clean end" ; ) | sqlexe
121 ( echo "-- MESG: build start" ; one_or_all $2 | egrep -iv "$MATCH_DROP" ; echo "-- MESG: build end" ; ) | sqlexe
124 ( echo "-- MESG: clean start" ; one_or_all $2 | egrep -i "$MATCH_DROP" | tac ; echo "-- MESG: clean end" ; \
125 echo "-- MESG: build start" ; one_or_all $2 | egrep -iv "$MATCH_DROP" ; echo "-- MESG: build end" ; ) \
133 psql $pg_args -t -q -A -F '|' $@
136 if [ $# -eq 1 ]; then
137 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE
139 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE > $1
143 if [ $# -eq 1 ]; then
144 pg_dump -h $DBHOST -U $DBUSER $DBBASE
146 pg_dump -h $DBHOST -U $DBUSER $DBBASE > $1
150 ( echo "-- MESG: add start" ; cat "$@" | egrep -iv "$MATCH_DROP" ; echo "-- MESG: add end" ; ) | sqlexe
153 ( echo "-- MESG: del start" ; cat "$@" | egrep -i "$MATCH_DROP" | tac ; echo "-- MESG: del end" ; ) | sqlexe
156 ( echo "-- MESG: res start" ; cat "$@" | egrep -i "$MATCH_DROP" | tac ; cat "$@" | egrep -iv "$MATCH_DROP" ; echo "-- MESG: del end" ; ) | sqlexe
158 "help"|"-h"|"--help")