From 0fd8e6e64816e3e963464e6472d29591f6b47e7f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 15:37:17 +0530 Subject: [PATCH] Improved commenting --- src/modules/site/migrate/ee_mod_migrate_data.sh | 12 +++++++++++- src/modules/site/migrate/ee_mod_migrate_setup.sh | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index f9bd1c9d..a9fa32d4 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -7,6 +7,8 @@ function ee_mod_migrate_data() ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." + # For Wordpress site we will migrate wp-config.php from parent folder of webroot + # For MySQL site we will migrate ee-config.php from parent folder of webroot if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then EE_SITE_CONFIG=wp-config.php elif [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then @@ -22,6 +24,7 @@ function ee_mod_migrate_data() EE_MIGRATE_CMD1="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" fi + # Copy webroot using sftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" @@ -30,6 +33,7 @@ function ee_mod_migrate_data() EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi + # Copy webroot using ftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" @@ -40,10 +44,16 @@ function ee_mod_migrate_data() fi fi + # eval: Execute arguments as a shell command. + # Why eval?: direct executing Varibale as command adding some extra characters to command + # Like quote is command is not working, that is why used eval + # For more info: help eval + eval $EE_MIGRATE_CMD1 \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ]; then + # In case of Wordpress site, If site don't have wp-config.php then try to copy wp-config.php from parent folder of webroot + # In case of MySQL site, try to copy ee-config.php from parent folder of webroot, (Hope remote server is using EE :P) eval $EE_MIGRATE_CMD2 &>> $EE_COMMAND_LOG fi - } diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 36911ec8..a3a06821 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -2,7 +2,7 @@ function ee_mod_migrate_setup() { - # Copy data + # Copy data from backup to webroot ee_lib_echo "Copying data from /ee-backup to webroot, please wait..." cp -a /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ \ || ee_lib_error "Unable to copy backup data to site webroot, exit status = " $? @@ -34,7 +34,6 @@ function ee_mod_migrate_setup() rm /var/www/$EE_DOMAIN/htdocs/ee-config.php fi if [ "$EE_MYSQL_PATH" != "" ]; then - EE_DB_NAME=$(grep DB_NAME /var/www/$EE_DOMAIN/ee-config.php | cut -d"'" -f4) # Import database ee_lib_echo "Importing database, please wait..."