-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-run-avail-full-node.sh
86 lines (79 loc) · 3.23 KB
/
auto-run-avail-full-node.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
#!/bin/bash
echo -e "\e[1;33m"
echo " s "
echo " x8h. x8. :8 "
echo ":88888> .x8888x. .88 uL .. "
echo " `8888 `8888f :888ooo .@88b @88R "
echo " 8888 8888' -*8888888 '"Y888k/"*P "
echo " 8888 8888 8888 Y888L "
echo " 8888 8888 8888 8888 "
echo " 8888 8888 8888 `888N "
echo " 8888 8888 .8888Lu= .u./"888& "
echo "-n88888x>"88888x- ^%888* d888" Y888*"
echo " `%888" 4888!` 'Y" ` "Y Y" "
echo " `" "" "
echo -e "\e[0m"
sleep 2;
# set vars
AVAIL_TAG="v1.8.0.4"
if [ ! $AVAIL_NODE_NAME ]; then
read -p "Enter node name: " AVAIL_NODE_NAME
echo 'export AVAIL_NODE_NAME='$AVAIL_NODE_NAME >> $HOME/.bash_profile
fi
source $HOME/.bash_profile
echo -e '================================================='
echo -e "Your node name: \e[1;33m$AVAIL_NODE_NAME\e[0m"
echo -e "Your p2p port: \e[1;33m30333\e[0m"
echo -e "Your rpc port: \e[1;33m9944\e[0m"
echo -e "Your prometheus port: \e[1;33m9615\e[0m"
echo '================================================='
sleep 2;
echo -e "\e[1;33m1. Updating packages... \e[0m" && sleep 1;
# update
sudo apt update && sudo apt upgrade -y
echo -e "\e[1;33m2. Installing dependencies... \e[0m" && sleep 1;
# packages
sudo apt install build-essential --assume-yes git clang curl libssl-dev protobuf-compiler -y
# install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
rustup default stable
rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
sleep 1;
echo -e "\e[1;33m3. Download and build binaries... \e[0m" && sleep 1;
# download binary
git clone https://github.com/availproject/avail.git
cd avail
mkdir -p data
git checkout $AVAIL_TAG
cargo build --release -p data-avail
. $HOME/.bash_profile
sudo cp $HOME/avail/target/release/data-avail /usr/local/bin
# create service
sudo tee /etc/systemd/system/availd.service > /dev/null <<EOF
[Unit]
Description=Avail Validator
After=network-online.target
[Service]
User=$USER
ExecStart=$(which data-avail) -d `pwd`/data --chain goldberg --port 30333 --rpc-port 9944 --rpc-cors=all --rpc-external --rpc-methods=unsafe --prometheus-port 9615 --prometheus-external --ws-port 9944 --ws-external --validator --name $AVAIL_NODE_NAME
Restart=on-failure
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
echo -e "\e[1;33m4. Starting service... \e[0m" && sleep 1;
# start service
sudo systemctl daemon-reload
sudo systemctl enable availd
sudo systemctl restart availd
echo -e "\e[1;33m=============== SETUP FINISHED ===================\e[0m"
echo -e "\e[1;33mView the logs from the running service, use: journalctl -f -u availd.service\e[0m"
echo -e "\e[1;33mCheck if the node is running, enter: sudo systemctl status availd.service\e[0m"
echo -e "\e[1;33mStop your Avail node, use: sudo systemctl stop availd.service\e[0m"
echo -e "\e[1;33mStart your Avail node, enter: sudo systemctl start availd.service\e[0m"
echo -e "\e[1;33mAfter modifying the availd.service file, reload the service using: sudo systemctl daemon-reload\e[0m"
echo -e "\e[1;33mRestart the service, use: sudo systemctl restart availd.service\e[0m"