-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAIT3.sh
125 lines (105 loc) · 5 KB
/
AIT3.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
echo -e "\033[0;35m"
echo "|||__________________________________________________|||"
echo "||| |||"
echo "||| ELAGABAL APTOS AIT3 INSTALLING |||"
echo "||| DEVNET |||"
echo "||| AUTOMATED SCRIPT FOR COMMUNITY |||"
echo "|||__________________________________________________|||"
echo -e "\e[0m"
sleep 2
# set vars
if [ ! $NODENAME ]; then
read -p "Enter node name: " NODENAME
echo 'export NODENAME='$NODENAME >> $HOME/.bash_profile
fi
echo "export WORKSPACE=testnet" >> $HOME/.bash_profile
echo "export PUBLIC_IP=$(curl -s ifconfig.me)" >> $HOME/.bash_profile
source $HOME/.bash_profile
echo -e "\e[1m\e[32m1. Updating dependencies... \e[0m" && sleep 1
sudo apt update && sudo apt upgrade -y
echo -e "\e[1m\e[32m2. Installing required dependencies... \e[0m" && sleep 1
sudo apt-get install jq unzip -y
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.23.1/yq_linux_amd64 && chmod +x /usr/local/bin/yq
echo -e "\e[1m\e[32m3. Checking if Docker is installed... \e[0m" && sleep 1
if ! command -v docker &> /dev/null
then
echo -e "\e[1m\e[32m3.1 Installing Docker... \e[0m" && sleep 1
sudo apt-get install ca-certificates curl gnupg lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
fi
echo -e "\e[1m\e[32m4. Checking if Docker Compose is installed ... \e[0m" && sleep 1
docker compose version
if [ $? -ne 0 ]
then
echo -e "\e[1m\e[32m4.1 Installing Docker Compose v2.6.1 ... \e[0m" && sleep 1
mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
sudo chown $USER /var/run/docker.sock
fi
# download aptos-cli
wget -qO aptos-cli.zip https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v0.3.1/aptos-cli-0.3.1-Ubuntu-x86_64.zip
unzip -o aptos-cli.zip -d /usr/local/bin
chmod +x /usr/local/bin/aptos
rm aptos-cli.zip
echo -e "\e[1m\e[32m5. Installing Validator Node ... \e[0m" && sleep 1
mkdir ~/$WORKSPACE && cd ~/$WORKSPACE
# download configs
wget -qO docker-compose.yaml wget https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/aptos-node/docker-compose.yaml
wget -qO validator.yaml wget https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/aptos-node/validator.yaml
# generate keys
aptos genesis generate-keys --output-dir ~/$WORKSPACE
# configure validator
aptos genesis set-validator-configuration \
--local-repository-dir ~/$WORKSPACE \
--username $NODENAME \
--validator-host $PUBLIC_IP:6180
--owner-public-identity-file ~/$WORKSPACE/keys/public-keys.yaml \
--stake-amount 100000000000000
# generate root key
mkdir keys
aptos key generate --assume-yes --output-file keys/root
ROOT_KEY="0x"$(cat ~/$WORKSPACE/keys/root.pub)
# add layout file
sudo tee layout.yaml > /dev/null <<EOF
---
root_key: "D04470F43AB6AEAA4EB616B72128881EEF77346F2075FFE68E14BA7DEBD8095E"
users:
- $NODENAME
chain_id: 43
allow_new_validators: false
epoch_duration_secs: 7200
is_test: true
min_stake: 100000000000000
min_voting_threshold: 100000000000000
max_stake: 100000000000000000
recurring_lockup_duration_secs: 86400
required_proposer_stake: 100000000000000
rewards_apy_percentage: 10
voting_duration_secs: 43200
voting_power_increase_limit: 20
EOF
# download aptos framework
wget -qO framework.zip https://github.com/aptos-labs/aptos-core/releases/download/aptos-framework-v0.2.0/framework.zip
unzip -o framework.zip
rm framework.zip
# compile genesis blob and waypoint
aptos genesis generate-genesis --local-repository-dir ~/$WORKSPACE --output-dir ~/$WORKSPACE
# run docker compose
docker compose up -d
echo "=================================================="
echo -e "\e[1m\e[32mAptos Validator Node Started \e[0m"
echo -e "Please backup key files \e[1m\e[32m$NODENAME.yaml, validator-identity.yaml, validator-full-node-identity.yaml \e[0mlocated in: \e[1m\e[32m~/$WORKSPACE\e[0m"
echo "=================================================="
echo -e "\e[1m\e[32mVerify initial synchronization: \e[0m"
echo -e "\e[1m\e[39m curl 127.0.0.1:9101/metrics 2> /dev/null | grep aptos_state_sync_version | grep type \n \e[0m"
echo -e "\e[1m\e[32mTo view validator node logs: \e[0m"
echo -e "\e[1m\e[39m docker logs -f testnet-validator-1 --tail 50 \n \e[0m"
echo -e "\e[1m\e[32mTo restart: \e[0m"
echo -e "\e[1m\e[39m docker compose restart \n \e[0m"
echo -e "\e[1m\e[32mTo view keys: \e[0m"
echo -e "\e[1m\e[39m cat ~/$WORKSPACE/$NODENAME.yaml \n \e[0m"