X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=sql%2Fbuilder.sh;h=cdb8a313ecc3c9911fe14aee12c6f39126de5415;hb=b9534a40010ce28590326b59d5270a96f5a7465b;hp=3bf9ecafacf3075f2ff1ccf100d0ac7699b9c8db;hpb=87a58bbb56440dc5e51e8dde854ed2b14e27098b;p=brisk.git diff --git a/sql/builder.sh b/sql/builder.sh index 3bf9eca..cdb8a31 100755 --- a/sql/builder.sh +++ b/sql/builder.sh @@ -1,14 +1,17 @@ #! /bin/bash -exit 0 # # all this part is from mopshop and we will use it to construct the brisk database # DBHOST=127.0.0.1 -DBUSER=mopshop -DBBASE=mopshop -DBPASS=sozopoco -PFX="msh_" +DBUSER=brisk +DBBASE=brisk +DBPASS=briskpass +PFX="bsk_" + +if [ -f $HOME/.brisk_install ]; then + . $HOME/.brisk_install +fi sqlexe () { local sht @@ -23,6 +26,14 @@ sqlexe () { return 0 } +one_or_all() { + if [ "$1" = "" ]; then + cat sql.d/*.sql + else + cat "$1" + fi +} + # # MAIN # @@ -43,12 +54,12 @@ elif [ "$1" = "destroy" ]; then echo "su root" su root -c "su postgres -c \"dropdb $DBBASE && dropuser $DBUSER\"" elif [ "$1" = "clean" ]; then - ( echo "-- MESG: clean start" ; cat sql.d/*.sql | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; ) | sqlexe $sht + ( echo "-- MESG: clean start" ; one_or_all $2 | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; ) | sqlexe $sht elif [ "$1" = "build" ]; then - ( echo "-- MESG: build start" ; cat sql.d/*.sql | grep -iv '^drop' ; echo "-- MESG: build end" ; ) | sqlexe $sht + ( echo "-- MESG: build start" ; one_or_all $2 | grep -iv '^drop' ; echo "-- MESG: build end" ; ) | sqlexe $sht elif [ "$1" = "rebuild" ]; then - ( echo "-- MESG: clean start" ; cat sql.d/*.sql | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; \ - echo "-- MESG: build start" ; cat sql.d/*.sql | grep -iv '^drop' ; echo "-- MESG: build end" ; ) \ + ( echo "-- MESG: clean start" ; one_or_all $2 | grep -i '^drop' | tac ; echo "-- MESG: clean end" ; \ + echo "-- MESG: build start" ; one_or_all $2 | grep -iv '^drop' ; echo "-- MESG: build end" ; ) \ | sqlexe $sht elif [ "$1" = "psql" ]; then psql -h $DBHOST -U $DBUSER $DBBASE