From 68ba3174ac36f9c885319d61eaff405a0ee5daca Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Tue, 23 Apr 2013 21:11:54 +0530 Subject: [PATCH] Improvments in demo management scripts --- tools/scripts/demo/demo.conf.txt | 8 +++---- tools/scripts/demo/load-pristine-drupal | 28 ++++++++++++++++++++++ tools/scripts/demo/load-pristine-joomla | 1 + tools/scripts/demo/load-pristine-wordpress | 23 +++++++++++++----- tools/scripts/demo/save-pristine-drupal | 26 ++++++++++++++++++++ tools/scripts/demo/save-pristine-wordpress | 23 ++++++++++++------ tools/scripts/demo/update-demo-all | 28 +++++++++++----------- 7 files changed, 106 insertions(+), 31 deletions(-) create mode 100755 tools/scripts/demo/load-pristine-drupal create mode 100755 tools/scripts/demo/save-pristine-drupal diff --git a/tools/scripts/demo/demo.conf.txt b/tools/scripts/demo/demo.conf.txt index 28beeff38f..b26d00c564 100644 --- a/tools/scripts/demo/demo.conf.txt +++ b/tools/scripts/demo/demo.conf.txt @@ -5,12 +5,12 @@ TMP_DUMP_FILE= CIVI_DEMO_DIR= # Define drupal-db-name and pristine path along with file-name -DRUPAL_DEMO_DBNAME= -DRUPAL_DEMO_PRISTINE= +DRUPAL_DEMO_CRM_DBNAME= +DRUPAL_DEMO_CRM_PRISTINE= # Define wordpress-db-name and pristine path along with file-name -WORDPRESS_DEMO_DBNAME= -WORDPRESS_DEMO_PRISTINE= +WORDPRESS_DEMO_CRM_DBNAME= +WORDPRESS_DEMO_CRM_PRISTINE= # Define wordpress-db-name and pristine path along with file-name JOOMLA_DEMO_DBNAME= diff --git a/tools/scripts/demo/load-pristine-drupal b/tools/scripts/demo/load-pristine-drupal new file mode 100755 index 0000000000..41675dd679 --- /dev/null +++ b/tools/scripts/demo/load-pristine-drupal @@ -0,0 +1,28 @@ +#!/usr/bin/env /bin/bash + +source `dirname $0`/demo.conf + +pushd . + +# load drupal demo pristines +if [ $DRUPAL_DEMO_CRM_DBNAME ]; then + mysqladmin -f drop $DRUPAL_DEMO_CRM_DBNAME + echo "Creating civicrm-drupal-demo db.." + mysqladmin create $DRUPAL_DEMO_CRM_DBNAME + if [ -f $DRUPAL_DEMO_CRM_PRISTINE ]; then + echo "Reloading civicrm-drupal-demo db from pristine.." + mysql $DRUPAL_DEMO_CRM_DBNAME < $DRUPAL_DEMO_CRM_PRISTINE + fi +fi + +if [ $DRUPAL_DEMO_CMS_DBNAME ]; then + mysqladmin -f drop $DRUPAL_DEMO_CMS_DBNAME + echo "Creating drupal-demo db.." + mysqladmin create $DRUPAL_DEMO_CMS_DBNAME + if [ -f $DRUPAL_DEMO_CMS_PRISTINE ]; then + echo "Reloading drupal-demo db from pristine.." + mysql $DRUPAL_DEMO_CMS_DBNAME < $DRUPAL_DEMO_CMS_PRISTINE + fi +fi + +popd diff --git a/tools/scripts/demo/load-pristine-joomla b/tools/scripts/demo/load-pristine-joomla index 6259c5ff4d..ee30724ccb 100755 --- a/tools/scripts/demo/load-pristine-joomla +++ b/tools/scripts/demo/load-pristine-joomla @@ -8,6 +8,7 @@ pushd . if [ $JOOMLA_DEMO_DBNAME ]; then if [ -f $JOOMLA_DEMO_PRISTINE ]; then mysqladmin -f drop $JOOMLA_DEMO_DBNAME + echo "Creating civicrm-joomla-demo db.." mysqladmin create $JOOMLA_DEMO_DBNAME echo "Reloading civicrm-joomla-demo from pristine.." mysql $JOOMLA_DEMO_DBNAME < $JOOMLA_DEMO_PRISTINE diff --git a/tools/scripts/demo/load-pristine-wordpress b/tools/scripts/demo/load-pristine-wordpress index 858d40edb3..42d7ea2c4f 100755 --- a/tools/scripts/demo/load-pristine-wordpress +++ b/tools/scripts/demo/load-pristine-wordpress @@ -4,13 +4,24 @@ source `dirname $0`/demo.conf pushd . -if [ $WORDPRESS_DEMO_DBNAME ]; then - # wordpress pristine - if [ -f $WORDPRESS_DEMO_PRISTINE ]; then - mysqladmin -f drop $WORDPRESS_DEMO_DBNAME +# load wordpress demo pristines +if [ $WORDPRESS_DEMO_CRM_DBNAME ]; then + mysqladmin -f drop $WORDPRESS_DEMO_CRM_DBNAME + echo "Creating civicrm-wordpress-demo db.." + mysqladmin create $WORDPRESS_DEMO_CRM_DBNAME + if [ -f $WORDPRESS_DEMO_CRM_PRISTINE ]; then echo "Reloading civicrm-wordpress-demo db from pristine.." - mysqladmin create $WORDPRESS_DEMO_DBNAME - mysql $WORDPRESS_DEMO_DBNAME < $WORDPRESS_DEMO_PRISTINE + mysql $WORDPRESS_DEMO_CRM_DBNAME < $WORDPRESS_DEMO_CRM_PRISTINE + fi +fi + +if [ $WORDPRESS_DEMO_CMS_DBNAME ]; then + mysqladmin -f drop $WORDPRESS_DEMO_CMS_DBNAME + echo "Creating wordpress-demo db.." + mysqladmin create $WORDPRESS_DEMO_CMS_DBNAME + if [ -f $WORDPRESS_DEMO_CMS_PRISTINE ]; then + echo "Reloading wordpress-demo db from pristine.." + mysql $WORDPRESS_DEMO_CMS_DBNAME < $WORDPRESS_DEMO_CMS_PRISTINE fi fi diff --git a/tools/scripts/demo/save-pristine-drupal b/tools/scripts/demo/save-pristine-drupal new file mode 100755 index 0000000000..784a02860c --- /dev/null +++ b/tools/scripts/demo/save-pristine-drupal @@ -0,0 +1,26 @@ +#!/usr/bin/env /bin/bash + +source `dirname $0`/demo.conf + +pushd . + +# drupal pristine +if [ "$1" == "cms" ] && [ $DRUPAL_DEMO_CMS_DBNAME ]; then + echo "Creating drupal-demo db dump.." + mysqldump $DRUPAL_DEMO_CMS_DBNAME > $TMP_DUMP_FILE + if [ -f $DRUPAL_DEMO_CMS_PRISTINE ]; then + echo "Creating drupal-demo db pristine from dump.." + cp $TMP_DUMP_FILE $DRUPAL_DEMO_CMS_PRISTINE + fi +elif [ -z "$1" ] && [ $DRUPAL_DEMO_CRM_DBNAME ]; then + echo "Creating civicrm-drupal-demo db dump.." + mysqldump $DRUPAL_DEMO_CRM_DBNAME > $TMP_DUMP_FILE + if [ -f $DRUPAL_DEMO_CRM_PRISTINE ]; then + echo "Creating civicrm-drupal-demo db pristine from dump.." + cp $TMP_DUMP_FILE $DRUPAL_DEMO_CRM_PRISTINE + fi +else + echo "Sorry i couldn't do anything.." +fi + +popd diff --git a/tools/scripts/demo/save-pristine-wordpress b/tools/scripts/demo/save-pristine-wordpress index 05f84aad84..5ae8bf7efc 100755 --- a/tools/scripts/demo/save-pristine-wordpress +++ b/tools/scripts/demo/save-pristine-wordpress @@ -4,14 +4,23 @@ source `dirname $0`/demo.conf pushd . -# creating wordpress pristine -if [ $WORDPRESS_DEMO_DBNAME ]; then - if [ -f $WORDPRESS_DEMO_PRISTINE ]; then - echo "Taking civicrm-wordpress-demo db dump.." - mysqldump $WORDPRESS_DEMO_DBNAME > $TMP_DUMP_FILE - echo "Creating civicrm-wordpress-demo pristine from dump.." - cp $TMP_DUMP_FILE $WORDPRESS_DEMO_PRISTINE +# wordpress pristine +if [ "$1" == "cms" ] && [ $WORDPRESS_DEMO_CMS_DBNAME ]; then + echo "Creating wordpress-demo db dump.." + mysqldump $WORDPRESS_DEMO_CMS_DBNAME > $TMP_DUMP_FILE + if [ -f $WORDPRESS_DEMO_CMS_PRISTINE ]; then + echo "Creating wordpress-demo db pristine from dump.." + cp $TMP_DUMP_FILE $WORDPRESS_DEMO_CMS_PRISTINE fi +elif [ -z "$1" ] && [ $WORDPRESS_DEMO_CRM_DBNAME ]; then + echo "Creating civicrm-wordpress-demo db dump.." + mysqldump $WORDPRESS_DEMO_CRM_DBNAME > $TMP_DUMP_FILE + if [ -f $WORDPRESS_DEMO_CRM_PRISTINE ]; then + echo "Creating civicrm-wordpress-demo db pristine from dump.." + cp $TMP_DUMP_FILE $WORDPRESS_DEMO_CRM_PRISTINE + fi +else + echo "Sorry i couldn't do anything.." fi popd diff --git a/tools/scripts/demo/update-demo-all b/tools/scripts/demo/update-demo-all index b7c8c643c4..96d882448c 100755 --- a/tools/scripts/demo/update-demo-all +++ b/tools/scripts/demo/update-demo-all @@ -12,18 +12,18 @@ cd $CIVI_DEMO_DIR/bin echo "cd $CIVI_DEMO_DIR/sql" cd $CIVI_DEMO_DIR/sql -if [ $DRUPAL_DEMO_DBNAME ]; then +if [ $DRUPAL_DEMO_CRM_DBNAME ]; then # drupal pristine echo "Reloading civicrm-drupal-demo db from generated.mysql .." - mysqladmin -f drop $DRUPAL_DEMO_DBNAME - mysqladmin create $DRUPAL_DEMO_DBNAME - mysql $DRUPAL_DEMO_DBNAME < civicrm.mysql - mysql $DRUPAL_DEMO_DBNAME < civicrm_generated.mysql + mysqladmin -f drop $DRUPAL_DEMO_CRM_DBNAME + mysqladmin create $DRUPAL_DEMO_CRM_DBNAME + mysql $DRUPAL_DEMO_CRM_DBNAME < civicrm.mysql + mysql $DRUPAL_DEMO_CRM_DBNAME < civicrm_generated.mysql echo "Taking civicrm-drupal-demo dump.." - mysqldump $DRUPAL_DEMO_DBNAME > $TMP_DUMP_FILE - if [ -f $DRUPAL_DEMO_PRISTINE ]; then + mysqldump $DRUPAL_DEMO_CRM_DBNAME > $TMP_DUMP_FILE + if [ -f $DRUPAL_DEMO_CRM_PRISTINE ]; then echo "Creating civicrm-drupal-demo pristine.." - cp $TMP_DUMP_FILE $DRUPAL_DEMO_PRISTINE + cp $TMP_DUMP_FILE $DRUPAL_DEMO_CRM_PRISTINE fi fi @@ -31,16 +31,16 @@ if [ ! -f $TMP_DUMP_FILE ]; then exit 1 fi -if [ $WORDPRESS_DEMO_DBNAME ]; then +if [ $WORDPRESS_DEMO_CRM_DBNAME ]; then # wordpress pristine - if [ -f $WORDPRESS_DEMO_PRISTINE ]; then + if [ -f $WORDPRESS_DEMO_CRM_PRISTINE ]; then echo "Creating civicrm-wordpress-demo pristine.." - cp $TMP_DUMP_FILE $WORDPRESS_DEMO_PRISTINE + cp $TMP_DUMP_FILE $WORDPRESS_DEMO_CRM_PRISTINE fi - mysqladmin -f drop $WORDPRESS_DEMO_DBNAME + mysqladmin -f drop $WORDPRESS_DEMO_CRM_DBNAME echo "Reloading civicrm-wordpress-demo from pristine.." - mysqladmin create $WORDPRESS_DEMO_DBNAME - mysql $WORDPRESS_DEMO_DBNAME < $TMP_DUMP_FILE + mysqladmin create $WORDPRESS_DEMO_CRM_DBNAME + mysql $WORDPRESS_DEMO_CRM_DBNAME < $TMP_DUMP_FILE fi if [ $JOOMLA_DEMO_DBNAME ]; then -- 2.25.1