]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
Schema: Introduce mg-schema-create
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 10 Dec 2015 12:29:32 +0000 (12:29 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 11 Dec 2015 17:02:44 +0000 (17:02 +0000)
There is a fair amount of option parsing clobber here that will be
relevant shortly.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
mg-schema-create [new file with mode: 0755]
mg-schema-test-database

diff --git a/mg-schema-create b/mg-schema-create
new file mode 100755 (executable)
index 0000000..54f1c76
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2015 Citrix Inc.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Usages:
+#
+#  ./mg-schema-create [<options>]
+#
+#  Database must already exist.  (Ie, mg-schema-create does not
+#  do CREATE DATABASE.)
+#
+#  When setting up a production database, mg-schema-create should
+#  be run *AS THE ROLE USER* who is to own all the resources.
+#
+# Options:
+#
+#  -q                            don't print progress messages
+
+set -e
+set -o posix
+set -o pipefail
+
+progress () { printf "%s\n" "$*"; }
+progress=progress
+quietopt=''
+
+while [ $# != 0 ]; do
+    arg=$1; shift
+    case "$arg" in
+    -q)
+        progress=:
+        quietopt=-q
+        ;;
+    *)
+        echo >&2 "bad usage ($arg)"; exit 127
+        ;;
+    esac
+done
+
+. ./cri-getconfig
+
+$progress "Populating database..."
+
+$(get_psql_cmd) $quietopt -f schema/initial.sql
+
+$progress "Database set up."
index c68b1d2c2767c2d36cfde7d3ca8ff0caae96a8b2..3616c4d783d5a697ffe28deb383a9c17010bb007 100755 (executable)
@@ -391,7 +391,7 @@ END
        psql_do <<END
                CREATE DATABASE $dbname;
 END
-       $(withtest get_psql_cmd) -q -f schema/initial.sql
+       withtest ./mg-schema-create -q
 
        printf ".\n"