Asaf Shakarchi has uploaded a new change for review. Change subject: core: Compatibility of dbfunctions.sh with MacOS. ......................................................................
core: Compatibility of dbfunctions.sh with MacOS. - New parameter (-c) to define the locale collate of the database to be created, default value is still "en_US.UTF8" while MacOS Postgresql package ships with default locale as "en_US". - md5sum alternative in MacOS is md5, new function md5calc uses the appropriate binary based on the binary existent. - mktemp syntax is different in MacOS, new function mkTempFile which handles both syntaxes. Change-Id: I97df4a9c8ea0c2ca0fdf861932a97afb978e56c4 Signed-off-by: Asaf Shakarchi <[email protected]> --- M backend/manager/dbscripts/create_db.sh M backend/manager/dbscripts/create_db_devel.sh M backend/manager/dbscripts/dbcustomfunctions.sh M backend/manager/dbscripts/dbfunctions.sh M backend/manager/dbscripts/upgrade/03_00_0420_encrypt_pm_passwd.sh 5 files changed, 20 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/13233/1 diff --git a/backend/manager/dbscripts/create_db.sh b/backend/manager/dbscripts/create_db.sh index 3a28160..d7fe19b 100755 --- a/backend/manager/dbscripts/create_db.sh +++ b/backend/manager/dbscripts/create_db.sh @@ -8,13 +8,15 @@ set_defaults usage() { - printf "Usage: ${ME} [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] [-u USERNAME] [-l LOGFILE] [-v]\n" + printf "Usage: ${ME} [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] [-c LOCALE] [-u USERNAME] [-l LOGFILE] [-v]\n" printf "\n" printf "\t-s SERVERNAME - The database servername for the database (def. ${SERVERNAME})\n" printf "\t-p PORT - The database port for the database (def. ${PORT})\n" printf "\t-d DATABASE - The database name (def. ${DATABASE})\n" + printf "\t-c LOCALE - The locale of the database. (def. ${LOCALE})\n" printf "\t-u USERNAME - The admin username for the database.\n" printf "\t-l LOGFILE - The logfile for capturing output (def. ${LOGFILE})\n" + printf "\t-le " printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" printf "\n" @@ -28,13 +30,14 @@ fi } -while getopts :hs:d:u:p:l:f:v option; do +while getopts :hs:d:c:u:p:l:f:v option; do case $option in s) SERVERNAME=$OPTARG;; p) PORT=$OPTARG;; d) DATABASE=$OPTARG;; u) USERNAME=$OPTARG;; l) LOGFILE=$OPTARG;; + c) LOCALE=$OPTARG;; v) VERBOSE=true;; h) ret=0 && usage;; \?) ret=1 && usage;; @@ -45,7 +48,7 @@ #try to drop the database first (if exists) dropdb --username=${USERNAME} --host=${SERVERNAME} --port=${PORT} ${DATABASE} -e > /dev/null -createdb --username=${USERNAME} --host=${SERVERNAME} --port=${PORT} ${DATABASE} -e -E UTF8 --lc-collate en_US.UTF8 --lc-ctype en_US.UTF8 -T template0 > /dev/null +createdb --username=${USERNAME} --host=${SERVERNAME} --port=${PORT} ${DATABASE} -e -E UTF8 --lc-collate ${LOCALE} --lc-ctype ${LOCALE} -T template0 > /dev/null if [ $? -ne 0 ] then printf "Failed to create database ${DATABASE}\n" diff --git a/backend/manager/dbscripts/create_db_devel.sh b/backend/manager/dbscripts/create_db_devel.sh index 46177bc..16f7f45 100755 --- a/backend/manager/dbscripts/create_db_devel.sh +++ b/backend/manager/dbscripts/create_db_devel.sh @@ -7,13 +7,15 @@ DATABASE="engine" USERNAME="postgres" PORT="5432" +LOCALE="us_EN.UTF8" usage() { - printf "Usage: ${ME} [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] [-u USERNAME] [-l LOGFILE] [-v]\n" + printf "Usage: ${ME} [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] [-c LOCALE] [-u USERNAME] [-l LOGFILE] [-v]\n" printf "\n" printf "\t-s SERVERNAME - The database servername for the database (def. ${SERVERNAME})\n" printf "\t-p PORT - The database port for the database (def. ${PORT})\n" printf "\t-d DATABASE - The database name (def. ${DATABASE})\n" + printf "\t-c LOCALE - The locale collate of the database. (def. ${LOCALE})\n" printf "\t-u USERNAME - The admin username for the database.\n" printf "\t-l LOGFILE - The logfile for capturing output (def. ${LOGFILE})\n" printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" @@ -24,11 +26,12 @@ } -while getopts hs:d:u:p:l:f:v option; do +while getopts hs:d:c:u:p:l:f:v option; do case $option in s) SERVERNAME=$OPTARG;; p) PORT=$OPTARG;; d) DATABASE=$OPTARG;; + c) LOCALE=$OPTARG;; u) USERNAME=$OPTARG;; l) LOGFILE=$OPTARG;; v) VERBOSE=true;; @@ -39,7 +42,7 @@ done printf "Running original create_db script...\n" -./create_db.sh -s $SERVERNAME -p $PORT -d $DATABASE -u $USERNAME; +./create_db.sh -s $SERVERNAME -p $PORT -d $DATABASE -c $LOCALE -u $USERNAME; if [ $? -ne 0 ] then printf "Failed to create database ${DATABASE}\n" diff --git a/backend/manager/dbscripts/dbcustomfunctions.sh b/backend/manager/dbscripts/dbcustomfunctions.sh index 181f162..f1e1804 100755 --- a/backend/manager/dbscripts/dbcustomfunctions.sh +++ b/backend/manager/dbscripts/dbcustomfunctions.sh @@ -15,6 +15,7 @@ USERNAME="" VERBOSE=false LOGFILE="$ME.log" + LOCALE="us_EN.UTF8" LC_ALL="C" export LC_ALL diff --git a/backend/manager/dbscripts/dbfunctions.sh b/backend/manager/dbscripts/dbfunctions.sh index 73e15d3..7e8692e 100755 --- a/backend/manager/dbscripts/dbfunctions.sh +++ b/backend/manager/dbscripts/dbfunctions.sh @@ -1,5 +1,6 @@ #!/bin/bash +source ./sysfunctions.sh # $1 - the command to execute # $2 - the database to use # $3 - db hostname (default 'localhost' or '') @@ -9,7 +10,7 @@ local dbname=${2} local dbhost=${3} local dbport=${4} - local filename=$(mktemp) + local filename=$(mkTempFile) printf "${command}\n" > $filename @@ -82,7 +83,7 @@ drop_sps() { # common stored procedures are executed first (for new added functions to be valid) execute_file "common_sp.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null - local drop_all_functions=$(mktemp) + local drop_all_functions=$(mkTempFile) CMD="select * from generate_drop_all_functions_syntax();" execute_command "$CMD" ${DATABASE} ${SERVERNAME} ${PORT} > "${drop_all_functions}" @@ -268,7 +269,8 @@ files=$(get_files "upgrade" 3) md5sum_file=.${DATABASE}.scripts.md5 md5sum_tmp_file=${md5sum_file}.tmp - md5sum $files create_*views.sql *_sp.sql > ${md5sum_tmp_file} + md5sumResult=$(md5calc $files create_*views.sql *_sp.sql) + echo $md5sumResult > ${md5sum_tmp_file} diff -s -q ${md5sum_file} ${md5sum_tmp_file} >& /dev/null result=$? @@ -321,7 +323,7 @@ files=$(get_files "upgrade" 1) for file in $(ls -1 $files); do before=$(get_db_time) - checksum=$(md5sum $file | cut -d " " -f1) + checksum=$(md5calc $file) # upgrade/dd_dd_dddd* => dddddddd ver="${file:8:2}${file:11:2}${file:14:4}" if [ "$ver" -gt "$current" ] ; then diff --git a/backend/manager/dbscripts/upgrade/03_00_0420_encrypt_pm_passwd.sh b/backend/manager/dbscripts/upgrade/03_00_0420_encrypt_pm_passwd.sh index f2a1052..d6af214 100755 --- a/backend/manager/dbscripts/upgrade/03_00_0420_encrypt_pm_passwd.sh +++ b/backend/manager/dbscripts/upgrade/03_00_0420_encrypt_pm_passwd.sh @@ -16,7 +16,7 @@ execute_command "${CMD}" "${DATABASE}" ${SERVERNAME} ${PORT} > /dev/null # get all hosts that have PM configured (vds_id and pm_password) -filename=$(mktemp) +filename=$(mkTempFile) CMD="select vds_id,vds_name,pm_password from vds_static where pm_enabled = true;" execute_command "${CMD}" "${DATABASE}" ${SERVERNAME} ${PORT} > ${filename} while read line -- To view, visit http://gerrit.ovirt.org/13233 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I97df4a9c8ea0c2ca0fdf861932a97afb978e56c4 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Asaf Shakarchi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
