From 03d88af84705f31de9a2d32ea46d8186dd3e8c76 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Tue, 26 Sep 2023 22:23:48 +0800 Subject: [PATCH] Fix database name fetch bug. --- move_site.sh | 6 +++++- move_site_interactive.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/move_site.sh b/move_site.sh index 6b507d4..18de9d3 100644 --- a/move_site.sh +++ b/move_site.sh @@ -74,7 +74,11 @@ else echo "root_path: $root_path"; db_name=`$ssh_command "grep -w 'database' '$root_path/config/mongoid.yml' -m1|sed 's/database://g'| xargs"` if [ -z $db_name ]; then - exit_command 1; + mongo_uri=`$ssh_command "grep -w 'uri:' '$root_path/config/mongoid.yml' -m1|sed 's/uri://g'| xargs"` + db_name=`basename "$mongo_uri"|cut -d '?' -f1` + if [ -z $db_name ]; then + exit_command 1; + fi fi echo "Database name: $db_name"; date_str=`date "+%Y%m%d"` diff --git a/move_site_interactive.sh b/move_site_interactive.sh index 1552d9e..9a3bbe4 100644 --- a/move_site_interactive.sh +++ b/move_site_interactive.sh @@ -78,7 +78,11 @@ else echo "root_path: $root_path"; db_name=`$ssh_command "grep -w 'database' '$root_path/config/mongoid.yml' -m1|sed 's/database://g'| xargs"` if [ -z $db_name ]; then - exit_command 1; + mongo_uri=`$ssh_command "grep -w 'uri:' '$root_path/config/mongoid.yml' -m1|sed 's/uri://g'| xargs"` + db_name=`basename "$mongo_uri"|cut -d '?' -f1` + if [ -z $db_name ]; then + exit_command 1; + fi fi echo "Database name: $db_name"; date_str=`date "+%Y%m%d"`