#!/bin/bash 

echo ""

case "$1" in
  start)
	# On a besoin de mgr
	./vm_start.sh "__mgr.testbed.aaa" || {
		echo "Echec au demarrage de mgr, abandon."
		exit 1
	}

	# On a besoin ensuite de rtmgr
	./vm_start.sh "iop-iopmgr.testbed.aaa" || {
		echo "Echec au demarrage de iopmgr, abandon."
		exit 1
	}
	
	# Maintenant on peut demarrer les autres VM en paralelle
	./vm_start.sh "iop-fdrelay.iop.testbed.aaa" &
	sleep 3
	#./vm_start.sh "eap-supauth2.eap.testbed.aaa" &
	#sleep 3
	
	# Done
	#wait
	;;
  pause)
	# On arrete toutes ces machines en sauvant leur etat
	./vm_pause.sh "__mgr.testbed.aaa" &
	./vm_pause.sh "iop-iopmgr.testbed.aaa" &
	./vm_pause.sh "iop-fdrelay.iop.testbed.aaa" &
	wait
	;;
  stop)
	# On arrete toutes ces machines en envoyant un shutdown
	./vm_stop.sh "__mgr.testbed.aaa" &
	./vm_stop.sh "iop-iopmgr.testbed.aaa" &
	./vm_stop.sh "iop-fdrelay.iop.testbed.aaa" &
	wait
	;;
  *)
	echo "Usage: $0 [start|pause|stop]"
	exit 1
esac

exit 0
