#!/bin/bash

# Author...: Ray, ABSLBS
# Date.....: 26.02.2024
# Purpose..: Cleanup Tomee

# Declare variables
path=`pwd`

[[ ! -z `ls $path/bin/*.log` ]] && rm -f $path/bin/*.log || echo "no log files found in $path/bin" 2> /dev/null
[[ ! -z `ls $path/logs/*` ]] && rm -f $path/logs/* || echo "no log files found in $path/logs" 2> /dev/null
[[ ! -z `ls $path/temp/*` ]] && rm -f $path/temp/* || echo "no log files found in $path/temp" 2> /dev/null
[[ ! -z `ls $path/work/*` ]] && rm -rf $path/work/* || echo "no directories found in $path/work" 2> /dev/null
[[ ! -z `ls $path/webapps/*.war` ]] && rm -f $path/webapps/*.war || echo "no war files found in $path/webapps" 2> /dev/null

find $path/webapps/ -maxdepth 1 ! -name "docs" ! -name "host-manager" ! -name "manager" ! -name "ROOT" ! -name "webapps" -type d ! -path '.' -exec rm -rf {} + 2> /dev/null

echo "Finished cleaning up $path folder."
