-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·231 lines (199 loc) · 6.34 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/bin/bash
# Check if the directory already exists
if [ -d "$HOME/telliot-feeds" ]; then
echo "The folder 'telliot-feeds' already exists. Please remove or rename it to save old configs."
exit 1
fi
echo
echo " ╔═════════════════════════════════════════════════════════════════╗"
echo " ║ This script will install Python, Telliot-feeds and Telliot-core ║"
echo " ║ (Optionally you can also choose to install the DVM) ║"
echo " ╚═════════════════════════════════════════════════════════════════╝"
echo "If installing in your main machine, please read the install.sh before install!"
echo "Note: You may need to give authorization for updates and Python during install."
echo
cd "$HOME/"
echo "Choose the environment to clone and install: "
echo "1 - Testnet/Main (Default)"
echo "2 - Staging (QA tests only)"
echo
read -p "Enter 1-testnet/main or 2-staging: " environment_choice
case $environment_choice in
1)
branch="testnet/main"
;;
2)
branch="staging"
;;
*)
echo "Invalid choice. Please enter 1 for testnet/main or 2 for staging."
exit 1
;;
esac
echo "You entered: $branch"
sleep 1
echo
read -p "Do you want to install DVM (Disputable Values Monitor), too? " install_dvm
# Treat empty response (just pressing Enter) as "yes"
install_dvm=${install_dvm:-yes}
case $install_dvm in
[Yy][Ee][Ss]|[Yy]) # Matches yes, Yes, YES, y, or Y
dvm="yes"
echo "Will install Telliot and DVM."
;;
[Nn][Oo]|[Nn]) # Matches no, No, NO, n, or N
dvm="no"
echo "Installing only Telliot."
;;
*)
echo "Invalid choice. Please enter 'y' or 'n'."
exit 1
;;
esac
echo "Cloning branch: $branch"
sleep 2
echo
branch="${branch/testnet\/main/testnet}"
echo updating system... apt-get, apt and git update.
sleep 3
sudo apt update
sudo apt-get update
sudo apt install git
# Clone the repository with the selected branch
echo "Cloning telliot-feeds..."
sleep 2
git clone -b "$branch" https://github.com/fetchoracle/telliot-feeds.git
if [ $? -eq 0 ]; then
echo "Telliot-feeds cloned successfully."
sleep 2
else
echo "Failed to clone telliot-feeds."
exit 1
fi
echo
echo "Moving to telliot-feeds folder..."
sleep 2
cd "$HOME/telliot-feeds" || { echo "Failed to change directory. Make sure to install it from HOME."; exit 1; }
echo
echo "Installing Python 3.9 and venv..."
sleep 2
current_distro=""
if command -v lsb_release &> /dev/null; then
current_distro=$(lsb_release -d | cut -f2)
else
echo "lsb_release command not found"
fi
echo "Current Distro Version: $current_distro"
supported_distros=("Ubuntu" "Debian")
supported_releases_ubuntu=("24.04" "22.04")
supported_releases_debian=("11")
current_distro_id=$(lsb_release -i | cut -f2)
current_distro_release=$(lsb_release -r | cut -f2)
found=false
for distro in "${supported_distros[@]}"; do
if [[ "$current_distro_id" != "$distro" ]]; then
continue
fi
if [[ "$distro" == "Ubuntu" ]]; then
for release in "${supported_releases_ubuntu[@]}"; do
if [[ "$current_distro_release" == "$release" ]]; then
found=true
break
fi
done
fi
if [[ "$distro" == "Debian" ]]; then
for release in "${supported_releases_debian[@]}"; do
if [[ "$current_distro_release" == "$release" ]]; then
found=true
break
fi
done
fi
if [[ "$found" == "true" ]]; then
break
fi
done
if [[ $current_distro != "" && "$found" == "false" ]]; then
echo "Current distribution is NOT in the list."
echo "Supported distributions and releases are:"
echo "Ubuntu: ${supported_releases_ubuntu[*]}"
echo "Debian: ${supported_releases_debian[*]}"
exit 1
fi
echo "Intalling python3.9 through deadsnakes PPA repository"
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install -y python3.9 python3.9-venv #python3-pip
# Create and activate the virtual environment
echo
echo "Creating and entering virtual environment..."
sleep 2
python3.9 -m venv venv
source venv/bin/activate
echo
echo "Installing telliot feeds"
sleep 2
pip install -e .
echo
echo "Creating copy of .env.example"
sleep 2
cp .env.example .env
if [ -f .env ]; then
echo ".env created successfully."
sleep 2
else
echo "Failed to create .env."
echo "Please, check telliot-feeds folder and rename .env.example to .env manually"
sleep 3
fi
echo
echo "Cloning telliot-core..."
sleep 2
git clone -b "$branch" https://github.com/fetchoracle/telliot-core.git
if [ $? -eq 0 ]; then
echo "Telliot-core cloned successfully."
sleep 2
else
echo "Failed to clone telliot-core."
exit 1
fi
echo
echo "Moving to telliot-core folder..."
sleep 2
cd "$HOME/telliot-feeds/telliot-core" || { echo "Failed to change directory."; exit 1; }
echo
echo "Installing telliot core"
sleep 2
pip install -e .
telliot config init
cd "$HOME/telliot-feeds/" || { echo "Failed to change directory."; exit 1; }
if [ "$dvm" = "yes" ]; then
echo
echo "Cloning DVM..."
sleep 2
git clone -b "$branch" https://github.com/fetchoracle/disputable-values-monitor.git
if [ $? -eq 0 ]; then
echo "DVM cloned successfully."
sleep 2
else
echo "Failed to clone DVM."
exit 1
fi
echo
echo "Moving to DVM folder..."
sleep 2
cd "$HOME/telliot-feeds/disputable-values-monitor" || { echo "Failed to change directory."; exit 1; }
echo
echo "Installing DVM"
sleep 2
pip install -e .
fi
echo
echo " ╔════════════════════════════════════════════════════════════╗"
echo -e " ║ \e[1mInstallation complete!\e[0m ║"
echo " ║ Telliot guide: https://tinyurl.com/mryzpw9v ║"
if [ "$dvm" = "yes" ]; then
echo " ║ DVM guide: https://tinyurl.com/bdey7ph9 ║"
fi
echo " ╚════════════════════════════════════════════════════════════╝"
exit 0