[DRE-commits] [diaspora-installer] 01/04: check if database is empty for mysql as well

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Sun Aug 28 19:29:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository diaspora-installer.

commit 72ea40b0a26eaf54e8690255e3f27dcf48fae91d
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Mon Aug 29 00:28:48 2016 +0530

    check if database is empty for mysql as well
---
 debian/postinst | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/debian/postinst b/debian/postinst
index 56bd312..8688fa2 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -25,6 +25,15 @@ set -e
 #     installation fails and the `postinst' is called with `abort-upgrade',
 #     `abort-remove' or `abort-deconfigure'.
 
+check_db_status() {
+echo "Checking if the database is empty..."
+if [ "$DB" = "postgres" ]; then
+  test "$(LANG=C su postgres -c "psql diaspora_production -c \"\d\"")" = \
+"No relations found."
+else
+  test -z "$(sudo mysql --defaults-file=/etc/mysql/debian.cnf -e "show tables from diaspora_production")"
+fi
+}
 
 case "$1" in
     configure)
@@ -50,8 +59,7 @@ https://github.com/hyperic/sigar/issues/60 ..."
 	su diaspora -s /bin/sh -c "bundle install --path vendor/bundle --with ${BUNDLE_WITH} --without development test"
 
 	# Check if the db is already present
-	if [ "$(LANG=C su postgres -c "psql diaspora_production -c \"\d\"")" = \
-"No relations found." ]; then
+	if check_db_status ; then
 	echo "Initializing database..."
 		su diaspora -s /bin/sh -c 'bundle exec rake db:schema:load'
 	else

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/diaspora-installer.git



More information about the Pkg-ruby-extras-commits mailing list