#!/usr/bin/env /bin/bash
+set -e
+set -x
source `dirname $0`/setup.conf
+source `dirname $0`/setup.lib.sh
# someone might want to use empty password for development,
# let's make it possible - we asked before.
echo; echo "Dropping civicrm_* tables from database $DBNAME"
# mysqladmin -f -u $DBUSER $PASSWDSECTION $DBARGS drop $DBNAME
-MYSQLCMD="mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME"
+MYSQLCMD=$(mysql_cmd)
+MYSQLADMCMD=$(mysqladmin_cmd)
+MYSQLDUMP=$(mysqldump_cmd)
echo "SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DBNAME}' AND TABLE_TYPE = 'VIEW'" \
| $MYSQLCMD \
| grep '^\(civicrm_\|log_civicrm_\)' \
| awk -v NOFOREIGNCHECK='SET FOREIGN_KEY_CHECKS=0;' 'BEGIN {print NOFOREIGNCHECK}{print "drop table " $1 ";"}' \
| $MYSQLCMD
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm.mysql
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm_data.mysql
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm_sample.mysql
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME < zipcodes.mysql
+$MYSQLCMD < civicrm.mysql
+$MYSQLCMD < civicrm_data.mysql
+$MYSQLCMD < civicrm_sample.mysql
+$MYSQLCMD < zipcodes.mysql
php GenerateData.php
# run the cli script to build the menu and the triggers
cd $CIVISOURCEDIR
"$PHP5PATH"php bin/cli.php -e System -a flush --triggers 1 --session 1
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME -e "DROP TABLE zipcodes; UPDATE civicrm_domain SET config_backend = NULL; UPDATE civicrm_setting SET value = NULL WHERE name = 'userFrameworkResourceURL' OR name = 'imageUploadURL';"
+$MYSQLCMD -e "DROP TABLE zipcodes; UPDATE civicrm_domain SET config_backend = NULL; UPDATE civicrm_setting SET value = NULL WHERE name = 'userFrameworkResourceURL' OR name = 'imageUploadURL';"
cd $CIVISOURCEDIR/sql
-mysqldump -cent --skip-triggers -u $DBUSER $PASSWDSECTION $DBARGS $DBNAME > civicrm_generated.mysql
+$MYSQLDUMP -cent --skip-triggers $DBNAME > civicrm_generated.mysql
#cat civicrm_sample_report.mysql >> civicrm_generated.mysql
cat civicrm_sample_custom_data.mysql >> civicrm_generated.mysql
#cat civicrm_devel_config.mysql >> civicrm_generated.mysql
cat civicrm_dummy_processor.mysql >> civicrm_generated.mysql
-mysqladmin -f -u$DBUSER $PASSWDSECTION $DBARGS drop $DBNAME
-mysqladmin -u$DBUSER $PASSWDSECTION $DBARGS create $DBNAME
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm.mysql
-mysql -u$DBUSER $PASSWDSECTION $DBARGS $DBNAME < civicrm_generated.mysql
+$MYSQLADMCMD -f drop $DBNAME
+$MYSQLADMCMD create $DBNAME
+$MYSQLCMD < civicrm.mysql
+$MYSQLCMD < civicrm_generated.mysql
popd
--- /dev/null
+function _mysql_vars() {
+ # someone might want to use empty password for development,
+ # let's make it possible - we asked before.
+ if [ -z $DBPASS ]; then # password still empty
+ PASSWDSECTION=""
+ else
+ PASSWDSECTION="-p$DBPASS"
+ fi
+
+ HOSTSECTTION=""
+ if [ ! -z "$DBHOST" ]; then
+ HOSTSECTION="-h $DBHOST"
+ fi
+
+ PORTSECTION=""
+ if [ ! -z "$DBPORT" ]; then
+ PORTSECTION="-P $DBPORT"
+ fi
+}
+
+function mysql_cmd() {
+ _mysql_vars
+ echo "mysql -u$DBUSER $PASSWDSECTION $HOSTSECTION $PORTSECTION $DBARGS $DBNAME"
+}
+
+function mysqladmin_cmd() {
+ _mysql_vars
+ echo "mysqladmin -u$DBUSER $PASSWDSECTION $HOSTSECTION $PORTSECTION $DBARGS"
+}
+
+function mysqldump_cmd() {
+ _mysql_vars
+ echo "mysqldump -u$DBUSER $PASSWDSECTION $HOSTSECTION $PORTSECTION $DBARGS"
+}
\ No newline at end of file
#!/usr/bin/env bash
set -e
+set -x
CALLEDPATH=`dirname $0`
fi
source "$CALLEDPATH/setup.conf"
+source "$CALLEDPATH/setup.lib.sh"
if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
echo; echo Usage: setup.sh [schema file] [database data file] [database name] [database user] [database password] [database host] [database port] [additional args]; echo
else
PHP_MYSQL_HOSTPORT="$DBHOST:$DBPORT"
fi
- "$PHP5PATH"php -d mysql.default_host="$PHP_MYSQL_HOSTPORT" -d mysql.default_user=$DBUSER -d mysql.default_password=$DBPASS GenCode.php $SCHEMA '' $GENCODE_CMS
-fi
-
-# someone might want to use empty password for development,
-# let's make it possible - we asked before.
-if [ -z $DBPASS ]; then # password still empty
- PASSWDSECTION=""
-else
- PASSWDSECTION="-p$DBPASS"
-fi
-
-HOSTSECTTION=""
-if [ ! -z "$DBHOST" ]; then
- HOSTSECTION="-h $DBHOST"
-fi
-
-PORTSECTION=""
-if [ ! -z "$DBPORT" ]; then
- PORTSECTION="-P $DBPORT"
+ "$PHP5PATH"php -d mysql.default_host="$PHP_MYSQL_HOSTPORT" -d mysql.default_user=$DBUSER -d mysql.default_password=$DBPASS GenCode.php $SCHEMA '' ${GENCODE_CMS}
fi
cd "$CALLEDPATH/../sql"
echo; echo "Dropping civicrm_* tables from database $DBNAME"
# mysqladmin -f -u $DBUSER $PASSWDSECTION $DBARGS drop $DBNAME
-MYSQLCMD="mysql -u$DBUSER $PASSWDSECTION $HOSTSECTION $PORTSECTION $DBARGS $DBNAME"
+MYSQLCMD=$(mysql_cmd)
echo "SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA='${DBNAME}' AND TABLE_TYPE = 'VIEW'" \
| $MYSQLCMD \
| grep '^\(civicrm_\|log_civicrm_\)' \