Author: misha680-guest
Date: 2010-10-06 04:09:43 +0000 (Wed, 06 Oct 2010)
New Revision: 5335

Modified:
   trunk/packages/openmrs/trunk/debian/postrm
Log:
almost working, will finish tomorrow

Modified: trunk/packages/openmrs/trunk/debian/postrm
===================================================================
--- trunk/packages/openmrs/trunk/debian/postrm  2010-10-06 03:21:43 UTC (rev 
5334)
+++ trunk/packages/openmrs/trunk/debian/postrm  2010-10-06 04:09:43 UTC (rev 
5335)
@@ -7,26 +7,36 @@
 
 case "$1" in
     purge)
+
        # are we using the default openmrs-runtime.properties location?
        if [ -f /etc/openmrs/openmrs-runtime.properties ]; then
-            CONNECTION_URL=$(cat /etc/openmrs/openmrs-runtime.properties | 
grep connection.url)
-           CONNECTION_URL_MYSQL=$(echo $CONNECTION_URL | grep mysql)
-           CONNECTION_URL_LOCALHOST3306=$(echo $CONNECTION_URL | grep 
localhost:3306)
-            # is the database mysql and local?
-            if ! [ "$CONNECTION_URL_MYSQL" = "" ] && ! [  
"$CONNECTION_URL_LOCALHOST3306" = "" ]; then
+           
+           # extract data from properties file
+            CONNECTION_URL=$(cat /etc/openmrs/openmrs-runtime.properties | 
grep connection.url || true)
+            CONNECTION_URL_DATABASE_NAME=$(echo $CONNECTION_URL | sed 
's...@.*localhost:3306/\([^?]*\)....@\1@' || true)
+           CONNECTION_URL_MYSQL=$(echo $CONNECTION_URL | grep mysql || true)
+           CONNECTION_URL_LOCALHOST3306=$(echo $CONNECTION_URL | grep 
localhost:3306 || true)
+           CONNECTION_USERNAME=$(cat /etc/openmrs/openmrs-runtime.properties | 
grep connection.username | sed 's/connection.username=//' || true)
+           CONNECTION_PASSWORD=$(cat /etc/openmrs/openmrs-runtime.properties | 
grep connection.password | sed 's/connection.password=//' || true)
+
+            if ! [ "$CONNECTION_URL_MYSQL" = "" ] && ! [  
"$CONNECTION_URL_LOCALHOST3306" = "" ] &&
+              ! [ "$CONNECTION_USERNAME" = "" ] && ! [ "$CONNECTION_PASSWORD" 
= "" ]; then
+
+                # confirm delete with user
                db_input high openmrs/confirm-delete-database || true
-               db_go || true
+               db_go
                db_get openmrs/confirm-delete-database
-               # does user wish to delete the database?
+
                if [ "$RET" = true ]; then
-                    DATABASE_NAME=$(echo $CONNECTION_URL | sed 
's...@.*localhost:3306/\([^?]*\)....@\1@')
-                    CONNECTION_USERNAME=$(cat 
/etc/openmrs/openmrs-runtime.properties | grep connection.username | sed 
's/connection.username=//')
-                   CONNECTION_PASSWORD=$(cat 
/etc/openmrs/openmrs-runtime.properties | grep connection.password | sed 
's/connection.password=//')
+
                    # we only drop the database, we cannot drop the user as the 
openmrs default user
                    # does not have permissions to drop users
-                   echo "drop database $DATABASE_NAME" | mysql 
--user=$CONNECTION_USERNAME --password=$CONNECTION_PASSWORD $DATABASE_NAME > 
/dev/null 2>&1 || true
+                   echo "drop database $DATABASE_NAME" | mysql 
--user=$CONNECTION_USERNAME --password=$CONNECTION_PASSWORD > /dev/null 2>&1 || 
true
+
                fi
+
             fi
+
         fi
 
         rm -rf /etc/openmrs


_______________________________________________
debian-med-commit mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/debian-med-commit

Reply via email to