# ***************************************
# *** Test Suite deployment & install ***
# ***************************************

# clean before deploying
make clean

# deploying locally
cc -I/usr/include/tirpc -x c $TSTPACKDIR/cleaner.c.src -ltirpc -lpthread -o $TSTPACKDIR/cleaner.bin

# deployment on client if needed
if [ "$LOCALIP" != "$CLIENTIP" ] || [ "$TSTPACKDIR" != "$CLIENTTSTPACKDIR" ]
then
	scp Makefile.clnt $CLIENTUSER@$CLIENTIP:$CLIENTDEPLOYDIR/Makefile
	ssh $CLIENTUSER@$CLIENTIP "mkdir $CLIENTTSTPACKDIR"
	scp -r $TSTPACKDIR/* $CLIENTUSER@$CLIENTIP:$CLIENTTSTPACKDIR
	ssh $CLIENTUSER@$CLIENTIP "cd $CLIENTDEPLOYDIR; make -f $CLIENTDEPLOYDIR/Makefile all"
	ssh $CLIENTUSER@$CLIENTIP "cc -I/usr/include/tirpc -x c $CLIENTTSTPACKDIR/cleaner.c.src -ltirpc -lpthread -o $CLIENTTSTPACKDIR/cleaner.bin"
fi

# deployment on server if needed
if [ "$LOCALIP" != "$SERVERIP" ] || [ "$TSTPACKDIR" != "$SERVERTSTPACKDIR" ]
then
	scp Makefile.svc $SERVERUSER@$SERVERIP:$SERVERDEPLOYDIR/Makefile
	ssh $SERVERUSER@$SERVERIP "mkdir $SERVERTSTPACKDIR"
	scp -r $TSTPACKDIR/* $SERVERUSER@$SERVERIP:$SERVERTSTPACKDIR
	ssh $SERVERUSER@$SERVERIP "cd $SERVERDEPLOYDIR; make -f $SERVERDEPLOYDIR/Makefile all"
	ssh $SERVERUSER@$SERVERIP "cc -I/usr/include/tirpc -x c $SERVERTSTPACKDIRcleaner.c.src -ltirpc -lpthread -o $SERVERTSTPACKDIR/cleaner.bin"
fi

exit 0
