From 4ecece8f33af737932847aec7c128d77ef81c194 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 28 Aug 2017 18:47:40 +0200
Subject: [PATCH] fix on upgrade scripts (to deploy new version of minerva)

---
 debian/scripts/common.sh | 2 +-
 debian/template/postinst | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/debian/scripts/common.sh b/debian/scripts/common.sh
index 951364c439..246724cb94 100644
--- a/debian/scripts/common.sh
+++ b/debian/scripts/common.sh
@@ -1,6 +1,6 @@
 #file with common script functions for postrm/prerm/postinst/preinst
 log(){
-	echo "$@" >>__LOG_FILE__
+	echo "[" $CURRENT_VERSION "]" "$@" >>__LOG_FILE__
 }
 LOG_FILE="__LOG_FILE__"
 
diff --git a/debian/template/postinst b/debian/template/postinst
index cc4aef4bd9..44228b77f9 100644
--- a/debian/template/postinst
+++ b/debian/template/postinst
@@ -14,6 +14,7 @@
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 log "Running postinst" $1 $2;
+invoke-rc.d $TOMCAT_PACKAGE status >> $LOG_FILE
 
 # we execute it here because if some packages are missing then dpkg will return non-zero exit code
 set -e
@@ -61,8 +62,10 @@ case "$1" in
 #we have to restart tomcat, because application was started on the old database and it might crash during deplyment
 #for instance in the new war file there was init script that uses some new database features, but they are not
 #availble when new war is deployed from debian package, so tomcat will catch SQL exception and stop deployment
+    invoke-rc.d $TOMCAT_PACKAGE stop || true
+    rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva
     ln -s /usr/share/minerva/minerva.war /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war 
-    invoke-rc.d $TOMCAT_PACKAGE restart
+    invoke-rc.d $TOMCAT_PACKAGE start
     ;;
     *)
         echo "postinst called with unknown argument \`$1'" >&2
-- 
GitLab