Fix database name fetch bug.

This commit is contained in:
BoHung Chiu 2023-09-26 22:23:48 +08:00
parent acbb318569
commit 03d88af847
2 changed files with 10 additions and 2 deletions

View File

@ -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"`

View File

@ -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"`