-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·90 lines (67 loc) · 1.96 KB
/
deploy.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
#
# Copyright (C) 2021 Ilya Entin
#
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
echo "SCRIPT_DIR:" $SCRIPT_DIR
UP_DIR=$(dirname $SCRIPT_DIR)
echo "UP_DIR:" $UP_DIR
if [[ ( $@ == "--help") || $@ == "-h" || $# -lt 1 || $# -gt 2 ]]
then
echo "cd to the project root and run this script"
echo "'./deploy.sh <number of client terminals>'"
echo "If app was not built previously it will be built"
echo "here with default arguments."
echo "Script creates requested number of clients"
echo "of intermitten types, TCP or FIFO."
echo "Start the server in the project root terminal './serverX'"
echo "and each client in its terminal"
echo "'./clientX' or './clientX > /dev/null'"
exit 0
fi
#Kill all instances of xterm created in previous runs
pkill -f xterm
set -e
# clean Client* and Fifos directories
rm -f $UP_DIR/Fifos/*
export c
for (( c=1; c<=$1; c++ ))
do
rm -f $UP_DIR/Client$c/*
done
# create FIFO directory and client directories at the project root level
mkdir -p $UP_DIR/Fifos
for (( c=1; c<=$1; c++ ))
do
mkdir -p $UP_DIR/Client$c
done
# build binaries if needed
cd $SCRIPT_DIR
./compile.sh
for ((c=1; c<=$1; c++))
do
cp $SCRIPT_DIR/clientX $UP_DIR/Client$c
done
# create data directory links in every client directory
# copy scripts and ClientOptions.json
for (( c=1; c<=$1; c++ ))
do
cd $UP_DIR/Client$c
ln -sf $SCRIPT_DIR/data .
cp $SCRIPT_DIR/scripts/runShortSessions.sh .
cp /$SCRIPT_DIR/client_src/ClientOptions.json .
done
# now all client directories have the same ClientOptions.json for TCP client
# if you want to make some of the clients, e.g. 2, 4, 6 ... FIFO:
for (( c=1; c<=$1; c++ ))
do
if [[ $(($c%2)) -eq 0 ]]
then
cd $UP_DIR/Client$c;sed -i 's/"ClientType" : "TCP"/"ClientType" : "FIFO"/' ClientOptions.json
fi
done
# create client terminals
for (( c=1; c<=$1; c++ ))
do
cd $UP_DIR/Client$c; xterm -geometry 67x24 -bg white -fg black&
done