-
Notifications
You must be signed in to change notification settings - Fork 2
/
blobber-host-update.sh
104 lines (93 loc) · 6.56 KB
/
blobber-host-update.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
echo "This script requires sudo privileges. Please enter your password:"
exec sudo "$0" "$@" # This re-executes the script with sudo
fi
# setup variables
export PROJECT_ROOT=/var/0chain/blobber
export BLOCK_WORKER_URL=0chainblockworker
export BLOBBER_HOST_OLD_URL=0chainblobberhostoldurl
export BLOBBER_HOST_NEW_URL=0chainblobberhostnewurl
# export BLOBBER_ID=0chainblobberid
# echo -e "\n\e[93m===============================================================================================================================================================================
# Check if blob_wallet.json wallet file exists or not.
# =============================================================================================================================================================================== \e[39m"
# pushd ${PROJECT_ROOT} > /dev/null;
# if [[ -f blob_wallet.json ]] ; then
# echo "blob_wallet.json is present"
# else
# echo "Didn't found blob_wallet.json file. Kindly place the file at location ${PROJECT_ROOT}/blob_wallet.json and rerun the script again"
# exit 1
# fi
# popd > /dev/null;
echo -e "\n\e[93m===============================================================================================================================================================================
Downloading zbox binary.
=============================================================================================================================================================================== \e[39m"
pushd ${PROJECT_ROOT} > /dev/null;
echo "generating config.yaml file"
echo "block_worker: https://mainnet.zus.network/dns" > config.yaml
echo "signature_scheme: bls0chain" >> config.yaml
echo "min_submit: 20" >> config.yaml
echo "min_confirmation: 20" >> config.yaml
echo "confirmation_chain_length: 3" >> config.yaml
echo "max_txn_query: 5" >> config.yaml
echo "query_sleep_time: 5" >> config.yaml
sleep 5s
if [[ -f bin/zbox ]] ; then
echo "zbox binary already present"
sudo chmod +x bin/zbox
else
ubuntu_version=$(lsb_release -rs | cut -f1 -d'.')
if [[ ${ubuntu_version} -eq 18 ]]; then
echo "Ubuntu 18 is not supported"
exit 1
elif [[ ${ubuntu_version} -eq 20 || ${ubuntu_version} -eq 22 ]]; then
wget https://github.com/0chain/zcnwebappscripts/raw/as-deploy/0chain/zwallet-binary/zbox
mkdir bin || true
sudo mv zbox ${PROJECT_ROOT}/bin/
sudo chmod +x bin/zbox
else
echo "Didn't found any Ubuntu version with 20/22."
exit 1
fi
fi
popd > /dev/null;
echo -e "\n\e[93m===============================================================================================================================================================================
Put down all the running container in order to avoid data corruption.
=============================================================================================================================================================================== \e[39m"
pushd ${PROJECT_ROOT} > /dev/null;
docker-compose -f docker-compose.yml down
popd > /dev/null;
echo -e "\n\e[93m===============================================================================================================================================================================
Updating blobber url into docker-compose.yml
=============================================================================================================================================================================== \e[39m"
pushd ${PROJECT_ROOT} > /dev/null;
sed -i "s|${BLOBBER_HOST_OLD_URL}|${BLOBBER_HOST_NEW_URL}|g" docker-compose.yml
echo "docker-compose file updated."
sleep 1s
popd > /dev/null;
echo -e "\n\e[93m===============================================================================================================================================================================
Updating blobber url into Caddyfile
=============================================================================================================================================================================== \e[39m"
pushd ${PROJECT_ROOT} > /dev/null;
sed -i "s|${BLOBBER_HOST_OLD_URL}|${BLOBBER_HOST_NEW_URL}|g" Caddyfile
echo "Caddyfile updated."
sleep 1s
popd > /dev/null;
echo -e "\n\e[93m===============================================================================================================================================================================
Starting all the containers with applied changes
=============================================================================================================================================================================== \e[39m"
pushd ${PROJECT_ROOT} > /dev/null;
docker-compose -f docker-compose.yml up -d
popd > /dev/null;
# echo -e "\n\e[93m===============================================================================================================================================================================
# Updating URL on mainnet chain
# =============================================================================================================================================================================== \e[39m"
# pushd ${PROJECT_ROOT} > /dev/null;
# ./bin/zbox bl-update --blobber_id ${BLOBBER_ID} --url https://${BLOBBER_HOST_NEW_URL}/ --wallet ./blob_wallet.json --configDir . --config ./config.yaml
# popd > /dev/null;
echo -e "\n\e[93m===============================================================================================================================================================================
Blobber must be available on the new url now.
=============================================================================================================================================================================== \e[39m"
echo "Blobber host url updation completed."
echo "Blobber is available on url --> https://${BLOBBER_HOST_NEW_URL}/_stats"