#!/bin/bash
#
# ::copy::
# ::maintainer::

me=`id | sed -e 's/uid=//' -e 's/(.*//'`
if [ $# != 0 ]
then
	hosts=$*
else
	hosts=*
fi

for host in $hosts
do
	[ -d $host ] || continue

	echo -en "\n$host "
	ping -c 1 -w 1 $host 2>/dev/null >/dev/null || {
		echo "UNREACHABLE!"
		continue
	}
	echo

	#sudo scp -p $host/kusa.conf $host:/etc/kusa/.

	[ -f $host/port-from-original.sh ] && {
		sudo bash -c "
			scp -p $host/port-from-original.sh $host:/root/. ;
			scp -p port-functions.sh $host:/root/. ;
			ssh $host rm -f /root/update-from-original.sh ;
		"
	}
done

exit 0
