[DRE-commits] [diaspora-installer] 12/21: add an error message if database already exist

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Mon May 11 12:36:48 UTC 2015


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

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

commit a6339c385f4d11ba9a3b4fae24c3ac4bf4410c1e
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Mon May 11 15:41:36 2015 +0530

    add an error message if database already exist
---
 debian/diaspora-common.install  |  1 +
 debian/diaspora-common.postinst |  5 +----
 debian/postinst                 | 26 ++++++++++++++++----------
 messages.sh                     | 12 ++++++++++++
 4 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/debian/diaspora-common.install b/debian/diaspora-common.install
index 45cf63f..f61d885 100644
--- a/debian/diaspora-common.install
+++ b/debian/diaspora-common.install
@@ -3,6 +3,7 @@ grantpriv.sh usr/lib/diaspora-common/scripts
 set-env-nginx.sh usr/lib/diaspora-common/scripts
 set-env-diaspora.sh usr/lib/diaspora-common/scripts
 rake-tasks.sh usr/lib/diaspora-common/scripts
+messages.sh usr/lib/diaspora-common/scripts
 diaspora-common.conf /etc/diaspora
 diaspora.conf /etc
 database.yml usr/share/diaspora/config
diff --git a/debian/diaspora-common.postinst b/debian/diaspora-common.postinst
index 3df81c9..9a7841f 100755
--- a/debian/diaspora-common.postinst
+++ b/debian/diaspora-common.postinst
@@ -44,10 +44,7 @@ case "$1" in
 	            echo "Trying update from ${installed_diaspora_version}..."
                 fi
             else
-                echo "There is a PostgreSQl database 'diaspora_production', aborting installation..."
-                echo "You may drop the database and try reinstalling"
-                echo "Command to drop the database: su postgres -c 'dropdb diaspora_production'"
-                echo "WARNING: This will remove all the data in diaspora_production database."
+                {diaspora_scripts}/messages.sh staledb 
                 exit 1
             fi
 
diff --git a/debian/postinst b/debian/postinst
index 5feadf7..dc90f41 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -33,19 +33,25 @@ case "$1" in
 	cd ${diaspora_home}
         if su diaspora -s /bin/sh -c "psql  diaspora_production -c ''"
         then
-            installed_diaspora_version=`echo $2|cut -d+ -f1`
-            installed_diaspora_minor_version=`echo ${installed_diaspora_version} |cut -d. -f3,4`
-            diaspora_minor_version=`echo ${diaspora_version} |cut -d. -f3,4`
-            if test $(echo "${installed_diaspora_minor_version} < ${diaspora_minor_version}" |bc) -eq 1
+            if ! test -z $2
             then
-                echo "Running migrations..."
-                echo "Some migrations may take upto 2 hours in large pods..."
+                installed_diaspora_version=`echo $2|cut -d+ -f1`
+                installed_diaspora_minor_version=`echo ${installed_diaspora_version} |cut -d. -f3,4`
+                diaspora_minor_version=`echo ${diaspora_version} |cut -d. -f3,4`
+                if test $(echo "${installed_diaspora_minor_version} < ${diaspora_minor_version}" |bc) -eq 1
+                then
+                    echo "Running migrations..."
+                    echo "Some migrations may take upto 2 hours in large pods..."
 
-                # source diaspora variables	
-                . ${diaspora_conf}
-                su diaspora -s /bin/sh -c 'bundle exec rake db:migrate'
+                    # source diaspora variables	
+                    . ${diaspora_conf}
+                    su diaspora -s /bin/sh -c 'bundle exec rake db:migrate'
+                else
+                    echo "This version is already installed..."
+                fi
             else
-                echo "This version is already installed..."
+                {diaspora_scripts}/messages.sh staledb 
+                exit 1
             fi
         else
     	    echo "Download diaspora tarball from github.com..."
diff --git a/messages.sh b/messages.sh
new file mode 100644
index 0000000..b746f97
--- /dev/null
+++ b/messages.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+case "$1" in
+    staledb)
+        echo "There is a PostgreSQl database 'diaspora_production', aborting installation..."
+        echo "You may drop the database and try reinstalling"
+        echo "Command to drop the database: su postgres -c 'dropdb diaspora_production'"
+        echo "WARNING: This will remove all the data in diaspora_production database."
+        ;;
+    *)
+        ;;
+esac

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