-
Notifications
You must be signed in to change notification settings - Fork 55
/
processing.sh
executable file
·67 lines (53 loc) · 2.64 KB
/
processing.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
#!/bin/bash
echo "INFO: $0 start"
echo "INFO: loading .env file"
source .env
# Set file paths
DEST_PATH="./etc"
NETWORK_FILE="./storage/docker-generateconfig/network.yml"
echo "INFO: Create directories for all node types"
for NODE_TYPE in node-1 node-2 node-3 filenode coordinator consensusnode; do
mkdir -p "${DEST_PATH}/any-sync-${NODE_TYPE}"
done
echo "INFO: Create directory for aws credentials"
mkdir -p "${DEST_PATH}/.aws"
echo "INFO: Configure external listen host"
python ./docker-generateconfig/setListenIp.py "./storage/docker-generateconfig/nodes.yml" "./storage/docker-generateconfig/nodesProcessed.yml"
echo "INFO: Create config for clients"
cp "./storage/docker-generateconfig/nodesProcessed.yml" "${DEST_PATH}/client.yml"
echo "INFO: Generate network file"
yq eval '. as $item | {"network": $item}' --indent 2 ./storage/docker-generateconfig/nodesProcessed.yml > "${NETWORK_FILE}"
echo "INFO: Generate config files for 3 nodes"
for i in {0..2}; do
cat \
"${NETWORK_FILE}" \
docker-generateconfig/etc/common.yml \
storage/docker-generateconfig/account${i}.yml \
docker-generateconfig/etc/node-$((i+1)).yml \
> "${DEST_PATH}/any-sync-node-$((i+1))/config.yml"
done
echo "INFO: Generate config files for coordinator"
cat "${NETWORK_FILE}" docker-generateconfig/etc/common.yml storage/docker-generateconfig/account3.yml docker-generateconfig/etc/coordinator.yml \
> ${DEST_PATH}/any-sync-coordinator/config.yml
echo "INFO: Generate config files for filenode"
cat "${NETWORK_FILE}" docker-generateconfig/etc/common.yml storage/docker-generateconfig/account4.yml docker-generateconfig/etc/filenode.yml \
> ${DEST_PATH}/any-sync-filenode/config.yml
echo "INFO: Generate config files for consensusnode"
cat "${NETWORK_FILE}" docker-generateconfig/etc/common.yml storage/docker-generateconfig/account5.yml docker-generateconfig/etc/consensusnode.yml \
> ${DEST_PATH}/any-sync-consensusnode/config.yml
echo "INFO: Copy network file to coordinator directory"
cp "storage/docker-generateconfig/nodesProcessed.yml" "${DEST_PATH}/any-sync-coordinator/network.yml"
echo "INFO: Copy aws credentials config"
cp "docker-generateconfig/etc/aws-credentials" "${DEST_PATH}/.aws/credentials"
echo "INFO: Replace variables from .env file"
for PLACEHOLDER in $( perl -ne 'print "$1\n" if /^([A-z0-9_-]+)=/' .env ); do
perl -i -pe "s|%${PLACEHOLDER}%|${!PLACEHOLDER}|g" \
"${DEST_PATH}/"/.aws/credentials \
"${NETWORK_FILE}" \
"${DEST_PATH}/"/*/*.yml
done
echo "INFO: fix indent in yml files"
for FILE in $( find ${DEST_PATH}/ -name "*.yml" ); do
yq --inplace --indent=2 $FILE
done
echo "INFO: $0 done"