-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsshStart.sh
executable file
·57 lines (45 loc) · 2.31 KB
/
sshStart.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# ./sshStart i0901995 172.20.2.111 172.20.2.14 172.20.2.15
projectDir="/home/$1/Z/Distribuidos/P2PDistribuidos/"
warDir="P2P/P2P.war"
tomcatDir="tomcat"
tomcat=$projectDir$tomcatDir
# We clean OLD logs
#rm -r $tomcat/logs/*
# We copy the new War to the shared folder
cp $projectDir$warDir $tomcat/webapps/P2P.war
# We run tomcat in main machine
# We copy tomcat server to local machine, we shutdown the server and we run it again
mkdir -p /home/$1/tomcat && cp -a $tomcat/. /home/$1/tomcat/ && /home/$1/tomcat/bin/shutdown.sh && sleep 1 && rm -Rf /home/$1/tomcat/logs/* && /home/$1/tomcat/bin/startup.sh
ssh $1@$3 "mkdir -p /home/$1/tomcat && cp -a $tomcat/. /home/$1/tomcat/ && JRE_HOME=/opt/jdk1.8.0_60 /home/$1/tomcat/bin/shutdown.sh && sleep 1 && rm -Rf /home/$1/tomcat/logs/* && JRE_HOME=/opt/jdk1.8.0_60 /home/$1/tomcat/bin/startup.sh &"
ssh $1@$4 "mkdir -p /home/$1/tomcat && cp -a $tomcat/. /home/$1/tomcat/ && JRE_HOME=/opt/jdk1.8.0_60 /home/$1/tomcat/bin/shutdown.sh && sleep 1 && rm -Rf /home/$1/tomcat/logs/* && JRE_HOME=/opt/jdk1.8.0_60 /home/$1/tomcat/bin/startup.sh &"
# We launch our P2P network
echo -e "InicializaciOn de la red P2P...\n"
echo -e "###################################################\n"
sleep 1
curl -v http://localhost:8080/P2P/inicializar?ip=$2\&port=8080
curl -v http://$3:8080/P2P/inicializar?ip=$3\&port=8080
curl -v http://$4:8080/P2P/inicializar?ip=$4\&port=8080
echo -e "###################################################\n"
echo -e "MAquinas Inicializadas correctamente!\n"
echo -e "Inicializando equipos P2P...\n"
echo -e "###################################################\n"
curl http://localhost:8080/P2P/Peer?port=8080\&numPeer=0
sleep 1
curl http://localhost:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=1
sleep 1
curl http://localhost:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=2
sleep 1
curl http://$3:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=0
sleep 1
curl http://$3:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=1
sleep 1
curl http://$3:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=2
sleep 1
curl http://$4:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=0
sleep 1
curl http://$4:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=1
sleep 1
curl http://$4:8080/P2P/Peer?ip=$2\&port=8080\&toPeer=0\&numPeer=2
sleep 1
echo -e "Equipos P2P Inicializados\n"