-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·99 lines (77 loc) · 2.35 KB
/
install.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
#!/bin/bash
TEA_ID=$1
MACHINE_OWNER=$2
STARTUP_PROOF=$3
: ${TEA_ID:=""}
: ${MACHINE_OWNER:=""}
: ${STARTUP_PROOF:=""}
RESOURCE_DIR=$HOME/nitro-build
confirm_tea_id() {
echo "please enter your tea id...(hex encoded, ie. 0x0000000000000000000000000000000000000000000000000000000000000000)"
set +e
read -r TEA_ID </dev/tty
rc=$?
set -e
if [[ $TEA_ID =~ ^(0x)*[[:xdigit:]]{64}$ ]]; then
echo "tea id accepted"
else
error "Error reading from prompt (please re-run to type tea id)"
exit 1
fi
}
confirm_machine_owner() {
echo "please enter your machine owner layer1 account address...(ie. 0xbd6D4f56b59e45ed25c52Eab7EFf2c626e083db9)"
set +e
read -r MACHINE_OWNER </dev/tty
rc=$?
set -e
if [[ $MACHINE_OWNER =~ ^(0x)*[[:xdigit:]]{40}$ ]]; then
echo "machine id owner accepted"
else
error "Error reading from prompt (please re-run to type machine owner)"
exit 1
fi
}
confirm_startup_proof() {
echo "please enter your startup proof..."
read -r STARTUP_PROOF </dev/tty
echo "aws region accepted"
}
pre_settings() {
sudo yum -y install git || true
echo "begin to git clone resources..."
if [ ! -d "$RESOURCE_DIR" ]; then
git clone -b main https://github.com/tearust/nitro-build
cd $RESOURCE_DIR
else
cd $RESOURCE_DIR
git fetch origin
git reset --hard origin/main
fi
echo "clone resources completed"
source server.env
ENV_FILE=$RESOURCE_DIR/.env
if [[ -n "$TEA_ID" && -n "$MACHINE_OWNER" && -n "$LIBP2P_BOOTNODES" && -n "$NITRO_KEY_ID" ]]; then
echo "begin to init env file through command line arguments"
printf "TEA_ID=$TEA_ID\nMACHINE_OWNER=$MACHINE_OWNER\nLIBP2P_BOOTNODES=$LIBP2P_BOOTNODES\nNITRO_KEY_ID=$NITRO_KEY_ID\nSTARTUP_PROOF=$STARTUP_PROOF" > $ENV_FILE
else
if [ ! -f "$ENV_FILE" ]; then
echo "begin to init env file from prompt"
confirm_tea_id
echo "TEA_ID=$TEA_ID" > $ENV_FILE
confirm_machine_owner
echo "MACHINE_OWNER=$MACHINE_OWNER" >> $ENV_FILE
confirm_startup_proof
echo "LIBP2P_BOOTNODES=$LIBP2P_BOOTNODES\nNITRO_KEY_ID=$NITRO_KEY_ID\nSTARTUP_PROOF=$STARTUP_PROOF\n" >> $ENV_FILE
echo ""
fi
fi
}
set -e
echo "begin to pre settings..."
pre_settings
echo "pre settings completed"
echo "begin to install dependencies..."
./aws-prepare.sh "normal" $RESOURCE_DIR
echo "install dependencies completed"
newgrp docker