#! /bin/bash
# ARG @mac file

REMBODIR="/home/kwartz/rembo/global/hosts"

# supprime : de @mac
DIR=${1//:/};
LCDIR=`echo "$DIR" | tr '[:upper:]' '[:lower:]'`
if [ -f $REMBODIR/$LCDIR ]; then
	DIR=$LCDIR
fi

if [[ $2 =~ ^/tmp/job.pulse2.* ]]; then 
	[ -f "${REMBODIR}/$DIR/jobs.ini" ] && rm -f "${REMBODIR}/$DIR/jobs.ini"
	[ -f $2 ] && {
		touch "${REMBODIR}/$DIR/jobs.ini"
		cp $2 "${REMBODIR}/$DIR/jobs.ini"
	}
else
	[ -f "${REMBODIR}/$DIR/log.pulse" ] && rm -f "${REMBODIR}/$DIR/log.pulse"
	[ -f $2 ] && {
		touch "${REMBODIR}/$DIR/log.pulse"
		cp $2 "${REMBODIR}/$DIR/log.pulse"
	}
fi
exit 0
