#!/bin/bash # Máquinas da equipe IntEvol # Érica, Pergentino, Matheus, Augusto e Bárbara (nessa ordem) machines=( paru parati badejo tuvira ) remotedir=$HOME/test-3.2/ prop=/tmp/peer.properties sdf=/tmp/peer.sdf PEERPACK=peer-3.2-RC-1.tar.gz port=2020 num_machines=${#machines[*]} end=$((num_machines - 1)) update_distribution() { machine=$1 echo "-> creating remotedir $remotedir$machine..." ssh $machine "mkdir -p $remotedir$machine" # echo "-> sending $PEERPACK file to $machine:$remotedir$machine..." # scp $PEERPACK $machine:$remotedir$machine # echo "-> untaring $PEERPACK at $machine@$remotedir/$machine..." # ssh $machine "cd $remotedir$machine; tar zxvf $PEERPACK" } create_peer_properties() { machine=$1 domain=".lsd.ufcg.edu.br" echo "peer.name = $machine$domain peer.port = 3082 peer.label = $machine$domain peer.email = euzinha@adm.com peer.description = Descrição do peer peer.corepeerport=3082 peer.corepeername=atum.lsd.ufcg.edu.br" > $prop } create_sdf() { machine=$1 port=$2 # if [ "$i" -eq 0 ] # then # machinesgdf=( paru parati badejo tuvira ) # else # machinesgdf=( paru$i parati$i badejo$i tuvira$i ) # fi echo > $sdf echo "gumdefaults: type: ualinux remExec : ssh -x \$machine \$command copyFrom : scp \$machine:\$remotefile \$localfile copyTo : scp \$localfile \$machine:\$remotefile port: $port" >> $sdf for j in `seq 0 3` do if [ "$j" -eq 0 ] then gum=$machine$domain else gum=$machine$j$domain fi echo "gum: name: $gum" >> $sdf done # for j in `seq 0 $z` # do # echo "gum: # name: ${machinesgdf[j]}$domain" >> $sdf # done } for i in `seq 0 $end` do machine=${machines[i]} echo "Configurando ambiente em [ $machine ]..." update_distribution $machine $prop echo $prop create_peer_properties $machine echo "-> replacing $remotedir$machine/peer/peer.properties file" scp $prop $machine:$remotedir$machine/peer/peer.properties create_sdf $machine $port echo "-> Sending $sdf file ..." scp $sdf $machine:$remotedir$machine/peer/peer.sdf echo "-> Starting user agents ..." ssh $machine "$remotedir$machine/peer/bin/uaadmin init $remotedir$machine/peer/peer.sdf" echo "-> Iniciando peer em $machine ..." ssh $machine "$remotedir$machine/peer/bin/peer stop" ssh $machine "$remotedir$machine/peer/bin/peer start; $remotedir$machine/peer/bin/peer setgums $remotedir$machine/peer/peer.sdf" & port=$((port +1)) done