# IBM Confidential
# OCO Source Materials
# 5724-V51
#
# (c) Copyright IBM Corp. 2000, 2008 All Rights Reserved.
#
# The source code for this program is not published or otherwise
# divested of its trade secrets, irrespective of what has been
# deposited with the U.S. Copyright Office.

#!/bin/bash

#	Copyright 2007, IBM Corporation


#      Do ghost items cleanings for all collaboration areas of the current company


#
# Usage of the file
if [[ $# -ne 0 ]]
then
 echo "Usage "
 echo "docleanall.sh "
 exit 0
fi




curdir="`pwd`"
echo "DIRECTORY NOW IS $curdir"

# get src connection descriptor
. ${TOP}/src/db/schema/util/set_db.sh
#. ${TOP}/bin/read_config_file.sh $TOP/etc/default/common.properties
#${MKDIR} ${_CCD_CONF_TMP_DIR}
#tmpfile=${_CCD_CONF_TMP_DIR}sanitycheck.master.sh.out
#${RM} $tmpfile

CleanAllFile="Cleanall_`date |awk '{print "cleanreport_item_ca_"$2"_"$3"_"$6"_"$4}'|sed s/":"//g`.txt";export CleanAllFile


# Be sure we're in original working directory
cd $curdir
echo "DIRECTORY NOW IS `pwd`"


if [ "$TOP" ]
then
mkdir ${TOP}/logs >>/dev/null 2>&1
mkdir ${TOP}/logs/ghostItemsCleanings >>/dev/null 2>&1
else
mkdir logs >>/dev/null 2>&1
mkdir logs/ghostItemsCleanings >>/dev/null 2>&1
fi



# Do the item-workflow collab areas
./docleanall.oldArgs.sh --db="${DB_SERVICE_NAME}" --dbuser="${DB_USER_NAME}"  --dbpassword="${DB_USER_PWD}"  2>&1 >${CleanAllFile}

# Do the category-workflow collab areas
# 9/21/07 disable category workflow ghost items checks for the time being

if [ "$TOP" ]
then
# 9/21/07 - don't need these since done by inner proc; also have bad names
#rm ${TOP}/logs/ghostItemsCleanings/lastreportall.txt
#echo "`date |awk '{print "lastReport_"$2"_"$3"_"$6"_"$4}'|sed s/":"//g`" >> ${TOP}/logs/ghostItemsCleanings/lastreportall.txt
mv ${CleanAllFile}  ${TOP}/logs/ghostItemsCleanings
else
#rm logs/ghostItemsCleanings/lastreportall.txt
#echo "`date |awk '{print "lastReport_"$2"_"$3"_"$6"_"$4}'|sed s/":"//g`" >> logs/ghostItemsCleanings/lastreportall.txt
mv ${CleanAllFile} logs/ghostItemsCleanings
fi



exit $?

