#!/bin/bash
#
# __copy1__
# __copy2__
#
CMD=`basename $0`

set -e
set -u

cfgfile="/etc/__TOOLKIT__/customfiles"
logfile="/etc/__TOOLKIT__/customfiles.log"
tarfile="/etc/__TOOLKIT__/customfiles.tar.gz"
tmpfile=`mktemp /tmp/$CMD-XXXXXXX.tmp`

[ -f $cfgfile ] || {
	echo "config file '$cfgfile' not found, exit"
	exit 1
}

cd /
sed -e 's/[ ,	]*#.*//' -e '/^[ ,	]*$/d' $cfgfile >$tmpfile
echo -n "saving custom files to $tarfile ... "
tar cvfz $tarfile `cat $tmpfile` >$logfile 2>&1 || {
	stat=$?
	echo -e "errors!\nsee $logfile for details" >&2
	exit $stat
}
echo "ok"

exit 0
