#!/bin/sh
#

FIXNSCRIPT_DONE=/etc/fixnscript_done

[ -f $FIXNSCRIPT_DONE ] && exit 0


PATH=/bin/:/sbin/:/usr/bin/:/usr/sbin/:$PATH

# $1: new script, $2: old script
function fix_netscript()
{
#	echo "<<  $1 , $2  >>"
	if [ -f "$1" -a -f "$2" ]; then
		diff -q $1 $2
		if [ $? -ne 0 ]; then
			cp -a $1 $2
			echo "Fix $2"
		fi
	fi
}


FIXNSCRIPT_CONF=/etc/fixnscript.conf
if [ ! -f $FIXNSCRIPT_CONF ]; then
	echo "there is not $FIXNSCRIPT_CONF."
	exit 0
fi

while read LBUFF
do
	SRC_FILE=$(echo $LBUFF | awk '{print $1}')
	DST_FILE=$(echo $LBUFF | awk '{print $2}')
	
	fix_netscript $SRC_FILE $DST_FILE

done < $FIXNSCRIPT_CONF

# make fixnscript done flag file
touch $FIXNSCRIPT_DONE

exit 0

