-
Notifications
You must be signed in to change notification settings - Fork 5
/
create-test-env.sh
executable file
·42 lines (36 loc) · 1.26 KB
/
create-test-env.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
#!/usr/bin/env bash
set -eu
create_rem_directory() {
NAME=$1
BASE_PORT=$2
#clear place
rm -rf $NAME
mkdir $NAME
DIR=$(realpath $NAME)
for SRC in rem start-stop-daemon.py rem-server.py client network_topology.cfg; do
ln -sf ../$SRC $DIR/$SRC
done
cp rem.cfg-default $DIR/rem.cfg
cp setup_env-default.sh $DIR/setup_env.sh
sed -ibak "s|/usr/local/rem|$DIR|g" $DIR/rem.cfg
sed -ibak "/^network_topology/s|.*|network_topology = local://$DIR/network_topology.cfg|g" $DIR/rem.cfg
sed -ibak "/^network_hostname/s|.*|network_hostname = $NAME|g" $DIR/rem.cfg
sed -ibak "s|port[[:space:]]*=[[:space:]]*\([[:digit:]]*\)|port = ${BASE_PORT}\1|g" $DIR/rem.cfg
sed -ibak "s|allow_backup_rpc_method\s*=\s*no|allow_backup_rpc_method = yes|g" $DIR/rem.cfg
}
cd $(dirname $0)
cat <<CONFIG > network_topology.cfg
[servers]
local-01 = http://localhost:18104, http://localhost:18105
local-02 = http://localhost:28104, http://localhost:28105
CONFIG
cat <<TEST_CONFIG > tests.cfg
[tests]
servers =
local-01, local://$(pwd)/local-01/, localhost
local-02, local://$(pwd)/local-02/, localhost
notify_email = $(whoami)@localhost
alt_user = remtest
TEST_CONFIG
create_rem_directory "local-01" "1"
create_rem_directory "local-02" "2"