4 # all this part is from mopshop and we will use it to construct the brisk database
7 if [ -f $HOME/.db.conf ]; then
17 if [ -f $HOME/.brisk_install ]; then
18 source $HOME/.brisk_install
26 if [ $sht -eq 1 ]; then
27 sed "s/#PFX#/$PFX/g" | psql -a -h $DBHOST -U $DBUSER $DBBASE 2>&1 | egrep 'ERROR|^-- MESG'
29 sed "s/#PFX#/$PFX/g" | psql -a -h $DBHOST -U $DBUSER $DBBASE
36 if [ "$1" = "" ]; then
48 if [ "$1" = "-s" ]; then
53 if [ "$1" = "create" ]; then
55 su root -c "su postgres -c \"echo \\\"DBUser passwd: $DBPASS\\\" ; createuser -S -D -R -P $DBUSER && createdb -E utf8 -O $DBUSER $DBBASE\""
56 elif [ "$1" = "destroy" ]; then
58 su root -c "su postgres -c \"dropdb $DBBASE && dropuser $DBUSER\""
59 elif [ "$1" = "clean" ]; then
60 ( echo "-- MESG: clean start" ; one_or_all $2 | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; ) | sqlexe $sht
61 elif [ "$1" = "build" ]; then
62 ( echo "-- MESG: build start" ; one_or_all $2 | grep -iv '^drop' ; echo "-- MESG: build end" ; ) | sqlexe $sht
63 elif [ "$1" = "rebuild" ]; then
64 ( echo "-- MESG: clean start" ; one_or_all $2 | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; \
65 echo "-- MESG: build start" ; one_or_all $2 | grep -iv '^drop' ; echo "-- MESG: build end" ; ) \
67 elif [ "$1" = "psql" ]; then
68 psql -h $DBHOST -U $DBUSER $DBBASE $@
69 elif [ "$1" = "piped" ]; then
70 psql -h $DBHOST -U $DBUSER $DBBASE -t -q -A -F '|' $@
71 elif [ "$1" = "dump" ]; then
73 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE
75 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE > $2
77 elif [ "$1" = "dumpall" ]; then
79 pg_dump -h $DBHOST -U $DBUSER $DBBASE
81 pg_dump -h $DBHOST -U $DBUSER $DBBASE > $2
83 elif [ "$1" = "add" ]; then
84 cat "$2" | psql -h $DBHOST -U $DBUSER $DBBASE
87 echo " ./builder create"
88 echo " ./builder destroy"
89 echo " ./builder clean"
90 echo " ./builder build"
91 echo " ./builder rebuild"
92 echo " ./builder psql"
93 echo " ./builder piped"
94 echo " ./builder add <filesql>"
95 echo " ./builder dump [dumpfile]"
96 echo " ./builder dumpall [dumpfile]"
98 echo " ./builder help"