5 # all this part is from mopshop and we will use it to construct the brisk database
17 if [ $sht -eq 1 ]; then
18 sed "s/#PFX#/$PFX/g" | psql -a -h $DBHOST -U $DBUSER $DBBASE 2>&1 | egrep 'ERROR|^-- MESG'
20 sed "s/#PFX#/$PFX/g" | psql -a -h $DBHOST -U $DBUSER $DBBASE
30 if [ -f $HOME/.db.conf ]; then
34 if [ "$1" = "-s" ]; then
39 if [ "$1" = "create" ]; then
41 su root -c "su postgres -c \"echo \\\"DBUser passwd: $DBPASS\\\" ; createuser -S -D -R -P $DBUSER && createdb -E utf8 -O $DBUSER $DBBASE\""
42 elif [ "$1" = "destroy" ]; then
44 su root -c "su postgres -c \"dropdb $DBBASE && dropuser $DBUSER\""
45 elif [ "$1" = "clean" ]; then
46 ( echo "-- MESG: clean start" ; cat sql.d/*.sql | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; ) | sqlexe $sht
47 elif [ "$1" = "build" ]; then
48 ( echo "-- MESG: build start" ; cat sql.d/*.sql | grep -iv '^drop' ; echo "-- MESG: build end" ; ) | sqlexe $sht
49 elif [ "$1" = "rebuild" ]; then
50 ( echo "-- MESG: clean start" ; cat sql.d/*.sql | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; \
51 echo "-- MESG: build start" ; cat sql.d/*.sql | grep -iv '^drop' ; echo "-- MESG: build end" ; ) \
53 elif [ "$1" = "psql" ]; then
54 psql -h $DBHOST -U $DBUSER $DBBASE
55 elif [ "$1" = "dump" ]; then
57 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE
59 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE > $2
61 elif [ "$1" = "dumpall" ]; then
63 pg_dump -h $DBHOST -U $DBUSER $DBBASE
65 pg_dump -h $DBHOST -U $DBUSER $DBBASE > $2
67 elif [ "$1" = "add" ]; then
68 cat "$2" | psql -h $DBHOST -U $DBUSER $DBBASE
71 echo " ./builder create"
72 echo " ./builder destroy"
73 echo " ./builder clean"
74 echo " ./builder build"
75 echo " ./builder rebuild"
76 echo " ./builder psql"
77 echo " ./builder add <filesql>"
78 echo " ./builder dump [dumpfile]"
79 echo " ./builder dumpall [dumpfile]"
81 echo " ./builder help"