[DRE-commits] [diaspora-installer] 14/15: move db initialization to initdb.sh

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Tue Sep 27 13:55:08 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 1005b57ab3913e86f6d8fdb0aaaf7039a5b46268
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Tue Sep 27 18:26:12 2016 +0530

    move db initialization to initdb.sh
---
 debian/diaspora-common.install |  1 +
 debian/postinst                | 21 ++-------------------
 initdb.sh                      | 22 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/debian/diaspora-common.install b/debian/diaspora-common.install
index 445acd6..3c8e341 100644
--- a/debian/diaspora-common.install
+++ b/debian/diaspora-common.install
@@ -10,3 +10,4 @@ grantpriv.sh usr/lib/diaspora-common/scripts
 rake-tasks.sh usr/lib/diaspora-common/scripts
 set-env-diaspora.sh usr/lib/diaspora-common/scripts
 set-env-nginx.sh usr/lib/diaspora-common/scripts
+initdb.sh usr/lib/diaspora-common/scripts
diff --git a/debian/postinst b/debian/postinst
index a57f30a..50d47f8 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -25,16 +25,6 @@ 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 ${DB_NAME} -c \"\d\"")" = \
-"No relations found."
-else
-  test -z "$(sudo mysql --defaults-file=/etc/mysql/debian.cnf -e "show tables from ${DB_NAME}")"
-fi
-}
-
 case "$1" in
     configure)
         # Source varibales
@@ -59,15 +49,8 @@ https://github.com/hyperic/sigar/issues/60 ..."
 	echo "Installing gems with rubygems ..."
 	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 check_db_status ; then
-	echo "Initializing database..."
-		su diaspora -s /bin/sh -c 'bundle exec rake db:schema:load'
-	else
-		echo "diaspora_production database is not empty, skipping database setup"
-		echo "Running migrations..."
-	        su diaspora -s /bin/sh -c 'bundle exec rake db:migrate'
-	fi
+	# Initialize database
+        /usr/lib/diaspora-common/scripts/initdb.sh
 
 	echo "Precompiling assets..."
 	su diaspora -s /bin/sh -c 'bundle exec rake tmp:cache:clear assets:precompile'
diff --git a/initdb.sh b/initdb.sh
new file mode 100755
index 0000000..c1ecdd3
--- /dev/null
+++ b/initdb.sh
@@ -0,0 +1,22 @@
+check_db_status() {
+  echo "Checking if the database is empty..."
+  if [ "$DB" = "postgres" ]; then
+    test "$(LANG=C su postgres -c "psql ${DB_NAME} -c \"\d\"")" = \
+"No relations found."
+  else
+    test -z "$(sudo mysql --defaults-file=/etc/mysql/debian.cnf -e "show tables from ${DB_NAME}")"
+  fi
+}
+
+
+# Check if the db is already present
+if check_db_status ; then
+echo "Initializing database..."
+	su diaspora -s /bin/sh -c 'bundle exec rake db:schema:load'
+else
+	echo "diaspora_production database is not empty, skipping database setup"
+	echo "Running migrations..."
+        su diaspora -s /bin/sh -c 'bundle exec rake db:migrate'
+fi
+
+

-- 
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