#!/bin/bash

# List of installed OOB RPMs

echo "Uninstalling OOB RPMS"

OOBRPMLIST="purge-workflows remote-purge-workflows distribution-workflows content-processing-workflows ami-resourcetype envivio-resourcetype cacs-resourcetype variable-functions-resourcetype verimatrix-resourcetype verimatrix-create-key utilities-resourcetype oob-configurations"

for arpm in $OOBRPMLIST
  do
   echo "Removing $arpm"
   rpm -e --nodeps --allmatches $arpm
  done


echo "Reseting original files"
mv /etc/vsftpd/vsftpd.conf_ORIG /etc/vsftpd/vsftpd.conf
chown nobody:nobody /etc/vsftpd/vsftpd.conf
mv /opt/tandbergtv/cms/conf/site/dist-templates.xml_ORIG /opt/tandbergtv/cms/conf/site/dist-templates.xml
chown nobody:nobody /opt/tandbergtv/cms/conf/site/dist-templates.xml
mv /opt/tandbergtv/cms/jboss/server/standard/deploy/adiserver.ear/adi.properties_ORIG /opt/tandbergtv/cms/jboss/server/standard/deploy/adiserver.ear/adi.properties
chown nobody:nobody /opt/tandbergtv/cms/jboss/server/standard/deploy/adiserver.ear/adi.properties
mv /opt/tandbergtv/cms/workflow/preferences/distribution.xml_ORIG /opt/tandbergtv/cms/workflow/preferences/distribution.xml
chown nobody:nobody /opt/tandbergtv/cms/workflow/preferences/distribution.xml
mv /opt/tandbergtv/watchpoint/tomcat/webapps/filemanager/WEB-INF/classes/com/tandbergtv/workflow/webservice/filesubsystem/ftpconfiguration.txt_ORIG /opt/tandbergtv/watchpoint/tomcat/webapps/filemanager/WEB-INF/classes/com/tandbergtv/workflow/webservice/filesubsystem/ftpconfiguration.txt
chown nobody:nobody /opt/tandbergtv/watchpoint/tomcat/webapps/filemanager/WEB-INF/classes/com/tandbergtv/workflow/webservice/filesubsystem/ftpconfiguration.txt
mv /opt/tandbergtv/watchpoint/tomcat/webapps/watchfolder/WEB-INF/classes/watchfolder.properties_ORIG /opt/tandbergtv/watchpoint/tomcat/webapps/watchfolder/WEB-INF/classes/watchfolder.properties
chown nobody:nobody /opt/tandbergtv/watchpoint/tomcat/webapps/watchfolder/WEB-INF/classes/watchfolder.properties
mv /opt/tandbergtv/watchpoint/tomcat/webapps/watchfolder/WEB-INF/classes/watchfolder.xml_ORIG /opt/tandbergtv/watchpoint/tomcat/webapps/watchfolder/WEB-INF/classes/watchfolder.xml
chown nobody:nobody /opt/tandbergtv/watchpoint/tomcat/webapps/watchfolder/WEB-INF/classes/watchfolder.xml


if [ -e "/var/ftp" ]
then
	echo "Remove ftp directory (Y/n)?"
	read RESPONSE
	if [[ -z $RESPONSE || "$RESPONSE" != [Nn]* ]]
	then
		rm -rf /var/ftp
	fi
fi

if [ -e "/content/data/ingest" ]
then
        echo "Remove ingest directory (Y/n)?"
        read RESPONSE
        if [[ -z $RESPONSE || "$RESPONSE" != [Nn]* ]]
        then
                rm -rf /content/data/ingest
        fi
fi

if [ -e "/content/data/failed" ]
then
        echo "Remove failed ingest directory (Y/n)?"
        read RESPONSE
        if [[ -z $RESPONSE || "$RESPONSE" != [Nn]* ]]
        then
                rm -rf /content/data/failed
        fi
fi

if [ -e "/content/data/temp" ]
then
        echo "Remove temp ingest directory (Y/n)?"
        read RESPONSE
        if [[ -z $RESPONSE || "$RESPONSE" != [Nn]* ]]
        then
                rm -rf /content/data/temp
        fi
fi

