#!/usr/bin/env bash
# * ##########################################################################
# *
# *              //===//   //=====   //===//   //       //   //===//
# *             //    //  //        //    //  //       //   //    //
# *            //===//   //=====   //===//   //       //   //===<<
# *           //   \\         //  //        //       //   //    //
# *          //     \\  =====//  //        //=====  //   //===//   Version III
# *
# *             ###################################################
# *           ======  D E M O N S T R A T I O N   S Y S T E M  ======
# *             ###################################################
# *
# * ############# An Efficient RSerPool Prototype Implementation #############
# *
# * Copyright (C) 2002-2026 by Thomas Dreibholz
# *
# * This program is free software: you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation, either version 3 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program.  If not, see <http://www.gnu.org/licenses/>.
# *
# * Contact: dreibh.iem.uni-due.de

if [ $# -lt 3 ] ; then
   echo >&2 "Usage: PlanetLabScenario-StartAll [Delay after PRs] [Delay after PEs] [Delay between PUs] {PE parameters}"
   exit 1
fi

PR_DELAY=$1
PE_DELAY=$2
PU_DELAY=$3
shift ; shift ; shift

./ComponentControl ./PlanetLabScenario.config PR 1 start -identifier=0x10000 -asap=[::]:3001 -enrp=[::]:4001
./ComponentControl ./PlanetLabScenario.config PR 2 start -identifier=0x10001 -asap=[::]:3002 -enrp=[::]:4002
sleep $PR_DELAY
./ComponentControl ./PlanetLabScenario.config PE 1 start -identifier=0x100 $@
./ComponentControl ./PlanetLabScenario.config PE 2 start -identifier=0x101 $@
sleep $PE_DELAY
./ComponentControl ./PlanetLabScenario.config PU 1 start -identifier=0x1 -caption=PoolUser-1
sleep $PU_DELAY
./ComponentControl ./PlanetLabScenario.config PU 2 start -identifier=0x2 -caption=PoolUser-2
