From: Matteo Nastasi (mop) Date: Sun, 13 Feb 2011 16:26:59 +0000 (+0100) Subject: one_or_all function added to be able to rebuild single .sql file and not all the... X-Git-Tag: 3.2.0~2 X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=brisk.git;a=commitdiff_plain;h=aef2c117e20cc46ba8b14d884d6979fea8c651bb one_or_all function added to be able to rebuild single .sql file and not all the archive --- diff --git a/sql/builder.sh b/sql/builder.sh index 89f3624..cdb8a31 100755 --- a/sql/builder.sh +++ b/sql/builder.sh @@ -26,6 +26,14 @@ sqlexe () { return 0 } +one_or_all() { + if [ "$1" = "" ]; then + cat sql.d/*.sql + else + cat "$1" + fi +} + # # MAIN # @@ -46,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