Eli Mesika has posted comments on this change.
Change subject: core: adding utility for db objects owner change
......................................................................
Patch Set 2:
(5 comments)
....................................................
File packaging/setup/dbutils/changedbowner.sh
Line 1: #!/bin/sh
I prefer to leave it as bash and do needed adjustments later on
Line 2: ################################################################
Line 3: # This script change the ownership of objects in the ${DATABASE}
Line 4: # database from ${FROM_USER} to ${TO_USER}
Line 5: ################################################################
Line 17: printf "\t-s SERVERNAME - The database servername for the database
(def. ${SERVERNAME})\n"
Line 18: printf "\t-p PORT - The database port for the database
(def. ${PORT})\n"
Line 19: printf "\t-d DATABASE - The database name
(def. ${DATABASE})\n"
Line 20: printf "\t-f FROM_USER - The current owner for the database
\n"
Line 21: printf "\t-f TO_USER - The new owner for the database
\n"
Change to :
usage() {
cat << _EOF_
Usage: ${ME} [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] -f FROM_USER -t
TO_USER
-s SERVERNAME - The database servername for the database (def.
${SERVERNAME})
-p PORT - The database port for the database (def. ${PORT})
-d DATABASE - The database name (def. ${DATABASE})
-f FROM_USER - The current owner for the database
-f TO_USER - The new owner for the database
-h - This help text.
_EOF_
popd>/dev/null
exit $ret
}
Not working for me , get the following error :
./changedbowner.sh: line 70: warning: here-document at line 15 delimited by
end-of-file (wanted `_EOF_')
./changedbowner.sh: line 71: syntax error: unexpected end of file
Line 22: printf "\t-h - This help text.\n"
Line 23: printf "\n"
Line 24: popd>/dev/null
Line 25: exit $ret
Line 43: fi
Line 44:
Line 45: # Change all schema objects ownership
Line 46: echo "Changing database ${DATABASE} objects ownership"
Line 47: pg_dump -s -h "${SERVERNAME}" -p ${PORT} -U postgres "${DATABASE}" |
grep -i 'owner to' | sed "s/OWNER TO ${FROM_USER};/OWNER TO ${TO_USER};/i" |
psql -h "${SERVERNAME}" -p ${PORT} -U ${FROM_USER} "${DATABASE}"
Agree
Line 48:
Line 49: if [[ $PIPESTATUS -ne 0 ]]; then
Line 50: echo "Failed to change DB ${DATABASE} objects ownership."
Line 51: popd>/dev/null
Line 44:
Line 45: # Change all schema objects ownership
Line 46: echo "Changing database ${DATABASE} objects ownership"
Line 47: pg_dump -s -h "${SERVERNAME}" -p ${PORT} -U postgres "${DATABASE}" |
grep -i 'owner to' | sed "s/OWNER TO ${FROM_USER};/OWNER TO ${TO_USER};/i" |
psql -h "${SERVERNAME}" -p ${PORT} -U ${FROM_USER} "${DATABASE}"
Line 48:
Its not export/import , the export is done only to extract the ownership info
as SQL commands that should apply to the DB
Line 49: if [[ $PIPESTATUS -ne 0 ]]; then
Line 50: echo "Failed to change DB ${DATABASE} objects ownership."
Line 51: popd>/dev/null
Line 52: exit 1
Line 45: # Change all schema objects ownership
Line 46: echo "Changing database ${DATABASE} objects ownership"
Line 47: pg_dump -s -h "${SERVERNAME}" -p ${PORT} -U postgres "${DATABASE}" |
grep -i 'owner to' | sed "s/OWNER TO ${FROM_USER};/OWNER TO ${TO_USER};/i" |
psql -h "${SERVERNAME}" -p ${PORT} -U ${FROM_USER} "${DATABASE}"
Line 48:
Line 49: if [[ $PIPESTATUS -ne 0 ]]; then
So, what to use instead???
I want to fail on any command that fails in the pipe chain
Line 50: echo "Failed to change DB ${DATABASE} objects ownership."
Line 51: popd>/dev/null
Line 52: exit 1
Line 53: fi
--
To view, visit http://gerrit.ovirt.org/18682
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I56c59c0fe749389bd110bcd1a39faae74e71174b
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches