#!/bin/bash

LONG_DATE=`date +%Y%m%d%H%M%S`

TOMCAT=tomcat9
TOMCAT_HOME=/var/lib/${TOMCAT}
APACHE_CONF=/etc/apache2
SOURCE_DIR=/usr/share/dataone-cn-rest
JK_CONF=cn_jk.conf

systemctl stop ${TOMCAT}
/etc/init.d/apache2 stop

rm -rf ${TOMCAT_HOME}/webapps/cn
rm -f ${TOMCAT_HOME}/webapps/cn.*
rm -rf ${SOURCE_DIR}
rm -f ${TOMCAT_HOME}/conf/Catalina/localhost/cn.xml
rm -f ${TOMCAT_HOME}/conf/policy.d/54cn.policy

rm -f ${APACHE_CONF}/jk_mount/${JK_CONF}*

systemctl start ${TOMCAT}
/etc/init.d/apache2 start

## Update DateONE Version Info Doc
java -jar /usr/share/dataone-cn-version-tool/dataone-cn-version-tool.jar -F/usr/share/dataone-cn-version-tool/version-tool.properties -html > /var/www/cn-version.html

exit 0