4 # all this part is from mopshop and we will use it to construct the brisk database
12 if [ -f $HOME/.brisk_install ]; then
13 . $HOME/.brisk_install
20 if [ $sht -eq 1 ]; then
21 sed "s/#PFX#/$PFX/g" | psql -a -h $DBHOST -U $DBUSER $DBBASE 2>&1 | egrep 'ERROR|^-- MESG'
23 sed "s/#PFX#/$PFX/g" | psql -a -h $DBHOST -U $DBUSER $DBBASE
33 if [ -f $HOME/.db.conf ]; then
37 if [ "$1" = "-s" ]; then
42 if [ "$1" = "create" ]; then
44 su root -c "su postgres -c \"echo \\\"DBUser passwd: $DBPASS\\\" ; createuser -S -D -R -P $DBUSER && createdb -E utf8 -O $DBUSER $DBBASE\""
45 elif [ "$1" = "destroy" ]; then
47 su root -c "su postgres -c \"dropdb $DBBASE && dropuser $DBUSER\""
48 elif [ "$1" = "clean" ]; then
49 ( echo "-- MESG: clean start" ; cat sql.d/*.sql | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; ) | sqlexe $sht
50 elif [ "$1" = "build" ]; then
51 ( echo "-- MESG: build start" ; cat sql.d/*.sql | grep -iv '^drop' ; echo "-- MESG: build end" ; ) | sqlexe $sht
52 elif [ "$1" = "rebuild" ]; then
53 ( echo "-- MESG: clean start" ; cat sql.d/*.sql | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; \
54 echo "-- MESG: build start" ; cat sql.d/*.sql | grep -iv '^drop' ; echo "-- MESG: build end" ; ) \
56 elif [ "$1" = "psql" ]; then
57 psql -h $DBHOST -U $DBUSER $DBBASE
58 elif [ "$1" = "dump" ]; then
60 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE
62 pg_dump -a --inserts -h $DBHOST -U $DBUSER $DBBASE > $2
64 elif [ "$1" = "dumpall" ]; then
66 pg_dump -h $DBHOST -U $DBUSER $DBBASE
68 pg_dump -h $DBHOST -U $DBUSER $DBBASE > $2
70 elif [ "$1" = "add" ]; then
71 cat "$2" | psql -h $DBHOST -U $DBUSER $DBBASE
74 echo " ./builder create"
75 echo " ./builder destroy"
76 echo " ./builder clean"
77 echo " ./builder build"
78 echo " ./builder rebuild"
79 echo " ./builder psql"
80 echo " ./builder add <filesql>"
81 echo " ./builder dump [dumpfile]"
82 echo " ./builder dumpall [dumpfile]"
84 echo " ./builder help"