#!/bin/bash
#
# cs_find_appconf
#
# (c) 2011 SUSE Linux GmbH, Germany. Author: L.Pinne.
# GNU Public License. No warranty.
#
# Version: 2012-02-12
#

EXE="$0"

CFG="/etc/ClusterTools2/cs_find_appconf"
test -s $CFG && source $CFG

test -z "${TEMP}" &&\
	TEMP="/dev/shm/cltl.$RANDOM"


function help() {
	echo "usage:    $(basename $0)"
	echo "  $(basename $0) [OPTION]"
	echo
	echo " --help           show help."
	echo " --version        show version."
}


function run_filefind {
	for d in $DIRS; do
		find $d -printf %m\\t%g\\t%u\\t%h"/"%f\\n >$SID1.orig.ff
		sed s/$SID1/$SID2/g <$SID1.orig.ff >$TEMP.2
		sed s/$SADM1/$SADM2/g <$TEMP.2 >$TEMP.3
		sed s/$DADM1/$DADM2/g <$TEMP.3 >$SID2.fake.ff
	done
	rm $TEMP.?
}


# main()

case $1 in
	-v|--version)
		echo -n "$(basename $EXE) "
		head -11 $EXE | grep "^# Version: "
		exit
	;;
	-h|--help)
		help
		exit
		;;
	*)
		run_filefind
		exit            
		;;
esac
#
