#!/bin/sh
#
# Configuration script for Stats.
#
# Denora (c) 2004-2013 Nomad Team
# Contact us at info@denorastats.org
#
# This program is free but copyrighted software; see the file COPYING for
# details.
#
# Based on the original code of Anope by Anope Team.
# Based on the original code of Thales by Lucas.
#
###########################################################################

SRC= ; DEST= ; MODE= ; USER= ; GROUP= ; export SRC DEST MODE USER GROUP
while [ $# -gt 0 ] ; do
	case $1 in
		-m)	MODE=$2; shift; shift;;
		-u)	USER=$2; shift; shift;;
		-g)	GROUP=$2; shift; shift;;
		-c)	shift;;
		*)	SRC="$DEST"; DEST="$1"; shift;;
	esac
done
if [ ! "$DEST" ] ; then
	echo >&2 "Usage: $0 [-c] [-m mode] [-u user] [-g group] source dest"
	exit 1
fi
if [ -d "$DEST" ] ; then
	DEST="$DEST/$SRC"
fi
/bin/cp -p "$SRC" "$DEST"
if [ "$MODE" ] ; then
	/bin/chmod $MODE "$DEST"
fi
if [ "$USER" ] ; then
	/bin/chown "$USER" "$DEST"
fi
if [ "$GROUP" ] ; then
	/bin/chgrp "$GROUP" "$DEST"
fi
