# Source and target directories
SOURCE="/srv/www/common_live/images/products/"
TARGET="/srv/www/common_dev/images/products/"

if [ $UID -ne 0 ]
then
	echo "This script requires root privileges"
	exit 1;
fi

# Parse command line options
while getopts v o
do
	case "$o" in
	v) VERBOSE="-v";;
	esac
done

echo "Synchronizing images"
/usr/bin/rsync $VERBOSE -rtL --delete "$SOURCE" "$TARGET"

#find "$TARGET" | while read FILE;
#do
#	chown root "$FILE" && chgrp "VELLEMAN+dirweb" "$FILE"

#	if test -f "$FILE"; then
#		chmod 664 "$FILE"
#		if [ "${FILE#*.}" == "jpg" ]; then
#			/root/jpegoptim/jpegoptim "$FILE"
#		fi
#	elif test -d "$FILE"; then
#		chmod 2775 "$FILE"
#	fi
#done
