Eli Mesika has uploaded a new change for review. Change subject: core: unlock_entity.sh fails if pwd is not... ......................................................................
core: unlock_entity.sh fails if pwd is not... unlock_entity.sh script fails if executed from a directory other than /usr/share/ovirt-engine/dbscripts Actually, that's true for all shell scripts under dbscripts dir. Code was changed to change to the dbscripts directory when a script starts and restore the original directory upon script completion. Change-Id: Iceeb2f28ce17dd117ecc2cded79077a9aca5e512 Signed-off-by: Eli Mesika <[email protected]> --- M backend/manager/dbscripts/backup.sh M backend/manager/dbscripts/create_db.sh M backend/manager/dbscripts/create_db_devel.sh M backend/manager/dbscripts/fkvalidator.sh M backend/manager/dbscripts/refreshStoredProcedures.sh M backend/manager/dbscripts/restore.sh M backend/manager/dbscripts/unlock_entity.sh M backend/manager/dbscripts/upgrade.sh 8 files changed, 34 insertions(+), 28 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/81/11081/1 diff --git a/backend/manager/dbscripts/backup.sh b/backend/manager/dbscripts/backup.sh index 0ab4433..d847060 100755 --- a/backend/manager/dbscripts/backup.sh +++ b/backend/manager/dbscripts/backup.sh @@ -5,13 +5,9 @@ ################################################################################ #include db general functions -if [ -e ./dbfunctions.sh ]; then - source ./dbfunctions.sh - source ./dbcustomfunctions.sh -else - printf "backup script should be run from database scripts directory\n" - exit 1 -fi +pushd $(dirname ${0}) +source ./dbfunctions.sh +source ./dbcustomfunctions.sh #setting defaults set_defaults @@ -30,7 +26,7 @@ printf "\t-h - This help text.\n" printf "\n" printf "for more options please run pg_dump --help" - + popd exit 0 } @@ -90,6 +86,7 @@ if [ $? -eq 0 ];then echo "Backup of database $DATABASE to $file completed." + popd exit 0 else usage diff --git a/backend/manager/dbscripts/create_db.sh b/backend/manager/dbscripts/create_db.sh index 5bdcda0..9d34906 100755 --- a/backend/manager/dbscripts/create_db.sh +++ b/backend/manager/dbscripts/create_db.sh @@ -1,5 +1,6 @@ #!/bin/bash #include db general functions +pushd $(dirname ${0}) source ./dbfunctions.sh source ./dbcustomfunctions.sh @@ -17,7 +18,7 @@ printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" printf "\n" - + popd exit $ret } @@ -47,6 +48,7 @@ if [ $? -ne 0 ] then printf "Failed to create database ${DATABASE}\n" + popd exit 1; fi createlang --host=${SERVERNAME} --port=${PORT} --dbname=${DATABASE} --echo --username=${USERNAME} plpgsql >& /dev/null @@ -75,4 +77,5 @@ printf "Running upgrade scripts...\n" run_upgrade_files +popd exit $? diff --git a/backend/manager/dbscripts/create_db_devel.sh b/backend/manager/dbscripts/create_db_devel.sh index 5cc703b..13f20b9 100755 --- a/backend/manager/dbscripts/create_db_devel.sh +++ b/backend/manager/dbscripts/create_db_devel.sh @@ -1,5 +1,6 @@ #!/bin/bash #include db general functions +pushd $(dirname ${0}) source ./dbfunctions.sh SERVERNAME="localhost" @@ -18,7 +19,7 @@ printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" printf "\n" - + popd exit $ret } @@ -42,10 +43,12 @@ if [ $? -ne 0 ] then printf "Failed to create database ${DATABASE}\n" + popd exit 1; fi printf "Setting development configuration values ...\n" execute_file "config_devel.sql" ${DATABASE} ${SERVERNAME} ${PORT}> /dev/null ret=$? printf "Development setting done.\n" +popd exit $? diff --git a/backend/manager/dbscripts/fkvalidator.sh b/backend/manager/dbscripts/fkvalidator.sh index 403743d..ff08a4a 100755 --- a/backend/manager/dbscripts/fkvalidator.sh +++ b/backend/manager/dbscripts/fkvalidator.sh @@ -20,6 +20,7 @@ #!/bin/bash #include db general functions +pushd $(dirname ${0}) source ./dbfunctions.sh source ./dbcustomfunctions.sh @@ -39,7 +40,7 @@ printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" printf "\n" - + popd exit $ret } @@ -72,10 +73,12 @@ if [ "${answer}" = "n" ]; then echo "Please contact support for further assistance." + popd exit 1 fi fi validate_db_fks ${FIXIT} +popd exit $? diff --git a/backend/manager/dbscripts/refreshStoredProcedures.sh b/backend/manager/dbscripts/refreshStoredProcedures.sh index 1dd96a2..669432e 100755 --- a/backend/manager/dbscripts/refreshStoredProcedures.sh +++ b/backend/manager/dbscripts/refreshStoredProcedures.sh @@ -1,5 +1,6 @@ #!/bin/bash #include db general functions +pushd $(dirname ${0}) source ./dbfunctions.sh source ./dbcustomfunctions.sh @@ -16,7 +17,7 @@ printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" printf "\n" - + popd exit $ret } @@ -47,4 +48,5 @@ refresh_sps printf "Done.\n" +popd exit 0 diff --git a/backend/manager/dbscripts/restore.sh b/backend/manager/dbscripts/restore.sh index ccb10f9..caa7eae 100755 --- a/backend/manager/dbscripts/restore.sh +++ b/backend/manager/dbscripts/restore.sh @@ -5,13 +5,9 @@ ################################################################################ #include db general functions -if [ -e ./dbfunctions.sh ]; then - source ./dbfunctions.sh - source ./dbcustomfunctions.sh -else - printf "backup script should be run from database scripts directory\n" - exit 1 -fi +pushd $(dirname ${0}) +source ./dbfunctions.sh +source ./dbcustomfunctions.sh #setting defaults set_defaults @@ -35,7 +31,7 @@ printf "\t3) Edit JBOSS standalone.xml to run the new restored database instance\n" printf "\t4) Verify that all tasks in the application are completed\n" printf "\t5) Restart JBOSS\n" - + popd exit 0 } @@ -81,6 +77,7 @@ echo "Upgrading restored database..." ./upgrade.sh -s ${SERVERNAME} -p ${PORT} -d ${DATABASE} -u ${USERNAME} -c fi + popd exit 0 else usage diff --git a/backend/manager/dbscripts/unlock_entity.sh b/backend/manager/dbscripts/unlock_entity.sh index f846f10..e464d90 100755 --- a/backend/manager/dbscripts/unlock_entity.sh +++ b/backend/manager/dbscripts/unlock_entity.sh @@ -1,5 +1,6 @@ #!/bin/bash #include db general functions +pushd $(dirname ${0}) source ./dbfunctions.sh source ./dbcustomfunctions.sh @@ -22,6 +23,7 @@ printf "\t-h - This help text.\n" printf "\n" + popd exit $ret } @@ -55,6 +57,7 @@ if [ "${answer}" = "n" ]; then echo "Please contact support for further assistance." + popd exit 1 fi fi @@ -67,4 +70,5 @@ usage fi +popd exit $? diff --git a/backend/manager/dbscripts/upgrade.sh b/backend/manager/dbscripts/upgrade.sh index 355012a..345a4d0 100755 --- a/backend/manager/dbscripts/upgrade.sh +++ b/backend/manager/dbscripts/upgrade.sh @@ -31,13 +31,9 @@ ################################################################################ #include db general functions -if [ -e ./dbfunctions.sh ]; then - source ./dbfunctions.sh - source ./dbcustomfunctions.sh -else - printf "upgrade script should be run from database scripts directory\n" - exit 1 -fi +pushd $(dirname ${0}) +source ./dbfunctions.sh +source ./dbcustomfunctions.sh #setting defaults set_defaults @@ -55,7 +51,7 @@ printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" printf "\n" - + popd exit $ret } @@ -84,4 +80,5 @@ ret=$? printf "Done.\n" +popd exit $ret -- To view, visit http://gerrit.ovirt.org/11081 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iceeb2f28ce17dd117ecc2cded79077a9aca5e512 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
