-
Notifications
You must be signed in to change notification settings - Fork 0
/
nkn-arm-fastdeploy
105 lines (105 loc) · 4.31 KB
/
nkn-arm-fastdeploy
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
clear
echo "============================================================================================="
echo " WELCOME TO NKNx FAST DEPLOY!"
echo "============================================================================================="
echo
echo "This script will automatically provision a node as you configured it in your snippet."
echo "So grab a coffee, lean back or do something else - installation will take about 5 minutes."
echo -e "============================================================================================="
echo
echo "Hardening your OS..."
echo "---------------------------"
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update
apt-get -qq upgrade -y
echo "Installing necessary libraries..."
echo "---------------------------"
apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes make curl git unzip whois
apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes ufw
apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes unzip jq
apt_install_res=$?
installres(){
echo '--------reinstallres------'
sudo apt-get update -y -q
sudo apt-get upgrade -y -q
sudo apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes make curl git unzip whois
sudo apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes ufw
sudo apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes unzip jq
apt_install_res=$?
}
while [ $apt_install_res -ne 0 ]
do
sleep 5
installres
echo 'res is:'$apt_install_res
done
ufw allow 30001 > /dev/null 2>&1
ufw allow 30002 > /dev/null 2>&1
ufw allow 30003 > /dev/null 2>&1
ufw allow 30004 > /dev/null 2>&1
ufw allow 30005 > /dev/null 2>&1
ufw allow 30010/tcp > /dev/null 2>&1
ufw allow 30011/udp > /dev/null 2>&1
ufw allow 30020/tcp > /dev/null 2>&1
ufw allow 30021/udp > /dev/null 2>&1
ufw allow 32768:65535/tcp > /dev/null 2>&1
ufw allow 32768:65535/udp > /dev/null 2>&1
ufw allow 22 > /dev/null 2>&1
ufw --force enable > /dev/null 2>&1
useradd nknx
mkdir -p /home/nknx/.ssh
mkdir -p /home/nknx/.nknx
adduser nknx sudo
chsh -s /bin/bash nknx
PASSWORD=$(mkpasswd -m sha-512 oggvPpVNOUE8)
usermod --password $PASSWORD nknx > /dev/null 2>&1
cd /home/nknx
echo "Installing NKN Commercial..."
echo "---------------------------"
wget --quiet --continue --show-progress https://commercial.nkn.org/downloads/nkn-commercial/linux-armv7.zip > /dev/null 2>&1
unzip -qq linux-armv7.zip
cd linux-armv7
cat >config.json <<EOF
{
"nkn-node": {
"args": "--sync light",
"noRemotePortCheck": true
}
}
EOF
./nkn-commercial -b NKNEv1nwLjcZuCcYbFKckFSsBogL94ZpinTY -c /home/nknx/linux-armv7/config.json -d /home/nknx/nkn-commercial -u nknx install > /dev/null 2>&1
chown -R nknx:nknx /home/nknx
chmod -R 755 /home/nknx
echo "Waiting for wallet generation..."
echo "---------------------------"
while [ ! -f /home/nknx/nkn-commercial/services/nkn-node/wallet.json ]; do sleep 10; done
echo "Chain download skipped."
echo "---------------------------"
echo "Applying finishing touches..."
echo "---------------------------"
addr=$(jq -r .Address /home/nknx/nkn-commercial/services/nkn-node/wallet.json)
pwd=$(cat /home/nknx/nkn-commercial/services/nkn-node/wallet.pswd)
chown -R nknx:nknx /home/nknx
chmod -R 755 /home/nknx
sleep 2
clear
echo
echo
echo
echo
echo " -----------------------"
echo " | NKNx FAST-DEPLOY |"
echo " -----------------------"
echo
echo "============================================================================================="
echo " NKN ADDRESS OF THIS NODE: $addr"
echo " PASSWORD FOR THIS WALLET IS: $pwd"
echo "============================================================================================="
echo " ALL MINED NKN WILL GO TO: NKNEv1nwLjcZuCcYbFKckFSsBogL94ZpinTY"
echo "============================================================================================="
echo
echo "You can now disconnect from your terminal. The node will automatically appear in NKNx after 1 minute."
echo
echo
echo
echo