-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfusioninstall.sh
More file actions
461 lines (319 loc) · 14.8 KB
/
fusioninstall.sh
File metadata and controls
461 lines (319 loc) · 14.8 KB
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
#!/bin/bash
# -------------------------------------------------------------------------
# @Programa
# @name: fusioninstall.sh
# @versao: 1.1.1
# @Data 13 de Maio de 2021
# @Copyright: Verdanatech Soluções em TI, 2021
# --------------------------------------------------------------------------
# LICENSE
#
# fusioninstall.sh is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# fusioninstall.shis distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------------------------
#
# Variables Declaration
#
versionDate="Out 26, 2021"
TITULO="Verdanatech FusionInstall - v.1.1.1"
BANNER="http://www.verdanatech.com"
#
# Debian Links
#
FUSION_DEB_LINK="https://github.com/fusioninventory/fusioninventory-agent/releases/download/2.6/fusioninventory-agent_2.6-1_all.deb"
FUSIONTASK_DEB_LINK="https://github.com/fusioninventory/fusioninventory-agent/releases/download/2.6/fusioninventory-agent-task-collect_2.6-1_all.deb"
FUSIONNET_DEB_LINK="https://github.com/fusioninventory/fusioninventory-agent/releases/download/2.6/fusioninventory-agent-task-network_2.6-1_all.deb"
FUSIONESX_DEB_LINK="https://github.com/fusioninventory/fusioninventory-agent/releases/download/2.6/fusioninventory-agent-task-esx_2.6-1_all.deb"
#
# MAC Links
#
FUSION_MAC_LINK="https://github.com/fusioninventory/fusioninventory-agent/releases/download/2.6/FusionInventory-Agent-2.6-2.pkg.tar.gz"
clear
cd /tmp
echo -e " ------------------------------------------------ _ _ _ \n ----------------------------------------------- / \\ / \\ / \\ \n ---------------------------------------------- ( \033[31mi\033[0m | \033[32mF\033[0m | \033[32mS\033[0m ) \n ----------------------------------------------- \\_/ \\_/ \\_/ \n| __ __ _ _ _\n| \\ \\ / / | | | | | | \n| \\ \\ / ___ _ __ __| | __ _ _ __ __ _| |_ ___ ___| |__ \n| \\ \\/ / _ | '__/ _\` |/ _\` | '_ \\ / _\` | __/ _ \\/ __| '_ \\ \n| \\ | __| | | (_| | (_| | | | | (_| | || __| (__| | | | \n| \\/ \\___|_| \\__,_|\\__,_|_| |_|\\__,_|\\__\\___|\\___|_| |_| \n| \n| consulting, training and implementation \n| comercial@verdanatech.com \n| www.verdanatech.com \n| \033[1m+55 81 3091 42 52\033[0m \n ------------------------------------------------------------ \n| \033[32m$TITULO\033[0m \n ----------------------------------------------------------- \n"
sleep 5
cd /tmp/
#
# install fusioninventory-agent
#
#
# Functions
#
# Function setAgentConfig
function setAgentConfig(){
if [ $SO != Darwin ]
then
erroDescription="Error to set GLPi Server!"
GLPI_SERVER=$(whiptail --title "${TITULO}" --backtitle "${BANNER}" --inputbox "Enter the GLPi Server address: eg: https://empresa.verdanadesk.com." --fb 10 60 3>&1 1>&2 2>&3); [ $? -ne 0 ] && erroDetect
erroDescription="Error to set fusion TAG!"
FUSION_TAG=$(whiptail --title "${TITULO}" --backtitle "${BANNER}" --inputbox "Enter the fusion TAG to use." --fb 10 60 3>&1 1>&2 2>&3); [ $? -ne 0 ] && erroDetect
erroDescription="Error to set HTTP TRUSTED HOST!"
TRUST=$(whiptail --title "${TITULO}" --backtitle "${BANNER}" --inputbox "Enter the http_trust host or network in CIDR format. eg: 127.0.0.1/32 192.168.1.0/24." --fb 10 60 3>&1 1>&2 2>&3); [ $? -ne 0 ] && erroDetect
erroDescription="Error to create Agent Configuration!"
echo -e "server = '$GLPI_SERVER/plugins/fusioninventory/'\nlocal = /tmp\ntasks = inventory\ndelaytime = 300\nlazy = 1\nscan-homedirs = 0\nscan-profiles = 0\nhtml = 0\nbackend-collect-timeout = 30\nforce = 1\nadditional-content =\nno-p2p = 0\nno-ssl-check = 0\ntimeout = 180\nno-httpd = 0\nhttpd-port = 62354\nhttpd-trust = $TRUST\nforce = 1\nlogger = syslog\nlogfacility = LOG_DAEMON\ncolor = 0\ntag = $FUSION_TAG\ndebug = 0\n" > /etc/fusioninventory/agent.cfg; [ $? -ne 0 ] && erroDetect
else
clear
echo " - - - - - - - - - - - - - "
echo " Enter the GLPi Server address: eg: https://empresa.verdanadesk.com."
read GLPI_SERVER
echo "Enter the fusion TAG to use."
read FUSION_TAG
echo "Enter the http_trust host or network in CIDR format. eg: 127.0.0.1/32 192.168.1.0/24."
read TRUST
erroDescription="Error to create Agent Configuration!"
echo -e "server = '$GLPI_SERVER/plugins/fusioninventory/'\nlocal = /tmp\ntasks = inventory\ndelaytime = 300\nlazy = 1\nscan-homedirs = 0\nscan-profiles = 0\nhtml = 0\nbackend-collect-timeout = 30\nforce = 0\nadditional-content =\nno-p2p = 0\nno-ssl-check = 0\ntimeout = 180\nno-httpd = 0\nhttpd-port = 62354\nhttpd-trust = $TRUST\nforce = 1\nlogger = syslog\nlogfacility = LOG_DAEMON\ncolor = 0\ntag = $FUSION_TAG\ndebug = 0\n" > /opt/fusioninventory-agent/etc/agent.cfg; [ $? -ne 0 ] && erroDetect
fi
}
# Function erroDetect
function erroDetect(){
clear
echo -e "
\033[31m
-----------------------------------------------------------
# ERRO DETECTED!!! #
-----------------------------------------------------------\033[0m
There was an error.
An error was encountered in the installer and the process
was aborted.
- - -
\033[1m Error Description:\033[0m
*\033[31m $erroDescription \033[0m
- - -
\033[1mFor commercial support contact us:\033[0m
+55 81 3091 42 52
$comercialMail
$devMail
----------------------------------------------------------
\033[32mVerdanatech Solucoes em TI - http://www.verdanatech.com\033[0m
----------------------------------------------------------"
kill $$
}
# Function INSTALL
INSTALL ()
{
clear
# Discovery and test SO support
erroDescription="This System is not supported"
SO=$(uname); [ $SO != Darwin ] && [ $SO != Linux ] && erroDetect
# Test if the user is root
erroDescription="System administrator privilege is required"
[ $UID -ne 0 ] && erroDetect
# Test if the systen has which package
erroDescription="The whiptail package is required to run the fusioninstall.sh"
if [ $SO != Darwin ]
then
which whiptail; [ $? -ne 0 ] && erroDetect
# Discovery the system version and instanciate variables
erroDescription="Operating system not supported."
source /etc/os-release ; [ $? -ne 0 ] && erroDetect
case $ID in
debian)
case $VERSION_ID in
11 | 10 | 9 | 8)
clear
echo "System GNU/Linux $PRETTY_NAME detect..."
sleep 2
echo "Starting fusioninstall.sh by Verdanatech"
echo "-----------------"; sleep 1;
# Download and install fusioninventory-agent
erroDescription="Erro to get fusioninventory-agent"
wget -O fusioninventory-agent.deb $FUSION_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-agent.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
# Download and install fusioninventory-task
erroDescription="Erro to get fusioninventory-task"
wget -O fusioninventory-task.deb $FUSIONTASK_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-task.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
# Download and install fusioninventory-net
erroDescription="Erro to get fusioninventory-net"
wget -O fusioninventory-net.deb $FUSIONNET_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-net.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
# Download and install fusioninventory-esx
erroDescription="Erro to get fusioninventory-esx"
wget -O fusioninventory-esx.deb $FUSIONESX_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-esx.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
;;
*)
erroDescription="Operating system not supported."
erroDetect
;;
esac
;;
centos)
case $VERSION_ID in
7)
clear
echo "System GNU/Linux $PRETTY_NAME detect..."
sleep 1
echo "Starting fusioninstall.sh by Verdanatech"
echo "-----------------"; sleep 1
echo "-----------------"; sleep 1
# Add perl repository to resolv dependencies
erroDescription="Erro to add EPEL repository!"
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm; [ $? -ne 0 ] && erroDetect
# Add fusioninventory repository
erroDescription="Erro to create fusioninventory repository!"
echo -e "[trasher-fusioninventory-agent]
name=Copr repo for fusioninventory-agent owned by trasher
baseurl=https://copr-be.cloud.fedoraproject.org/results/trasher/fusioninventory-agent/epel-7-\$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/trasher/fusioninventory-agent/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
" > /etc/yum.repos.d/copr.fusion.repo; [ $? -ne 0 ] && erroDetect
# Install fusioninventory-agent
yum install -y fusioninventory-agent
;;
*)
erroDescription="Operating system not supported."
erroDetect
;;
esac
;;
rhel)
case $VERSION_ID in
"8.1")
clear
echo "System GNU/Linux $PRETTY_NAME detect..."
sleep 2
echo "Starting fusioninstall.sh by Verdanatech"
echo "-----------------"; sleep 1
# Add perl repository to resolv dependencies
erroDescription="Erro to add EPEL repository!"
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm; [ $? -ne 0 ] && erroDetect
# Add fusioninventory repository
erroDescription="Erro to create fusioninventory repository!"
echo -e "[trasher-fusioninventory-agent]
name=Copr repo for fusioninventory-agent owned by trasher
baseurl=https://copr-be.cloud.fedoraproject.org/results/trasher/fusioninventory-agent/epel-8-\$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/trasher/fusioninventory-agent/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
" > /etc/yum.repos.d/copr.fusion.repo; [ $? -ne 0 ] && erroDetect
# Install fusioninventory-agent
yum install -y fusioninventory-agent
;;
*)
erroDescription="Operating system not supported."
erroDetect
;;
esac
;;
ubuntu)
case $VERSION_ID in
"16.04" | "16.10" | "17.04" | "17.10" | "18.04" | "18.10" | "19.04" | "19.10" | "20.04" | "20.10" | 21.04 | 21.10 | 22.04 )
clear
echo "System GNU/Linux $PRETTY_NAME detect..."
sleep 2
echo "Starting fusioninstall.sh by Verdanatech"
echo "-----------------"; sleep 1;
# Download and install fusioninventory-agent
erroDescription="Erro to get fusioninventory-agent"
wget -O fusioninventory-agent.deb $FUSION_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-agent.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
# Download and install fusioninventory-task
erroDescription="Erro to get fusioninventory-task"
wget -O fusioninventory-task.deb $FUSIONTASK_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-task.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
# Download and install fusioninventory-net
erroDescription="Erro to get fusioninventory-net"
wget -O fusioninventory-net.deb $FUSIONNET_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-net.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
# Download and install fusioninventory-esx
erroDescription="Erro to get fusioninventory-esx"
wget -O fusioninventory-esx.deb $FUSIONESX_DEB_LINK; [ $? -ne 0 ] && erroDetect
dpkg -i fusioninventory-esx.deb
erroDescription="Error to resolve dependencies"
apt-get -f install -y; [ $? -ne 0 ] && erroDetect
;;
*)
erroDescription="Operating system not supported."
erroDetect
;;
esac
esac
else
#
# INSTALA MacOS
#
clear
echo "System MacOS detect..."
sleep 2
echo "Starting fusioninstall.sh by Verdanatech"
echo "-----------------"; sleep 1;
# Download and install fusioninventory-agent
erroDescription="Erro to get fusioninventory-agent"
curl -sSL $FUSION_MAC_LINK -o fusioninventory-agent.tar.gz ; [ $? -ne 0 ] && erroDetect
tar xfz fusioninventory-agent.tar.gz
installer -pkg FusionInventory-Agent-2.6-2.pkg -target / -lang en
fi
clear
echo "Configuring fusioninventory-agent..."
sleep 2
setAgentConfig
clear
echo "enable fusioninventory-agent to start with system"
sleep 1
erroDescription="Error to enable fusioninventory-agent with SystemCTL"
# enable stato with system
if [ $SO != Darwin ]
then
systemctl enable fusioninventory-agent; [ $? -ne 0 ] && erroDetect
sleep 1
erroDescription="Error to start fusioninventory-agent"
# Iniciando o serviço fusioninventory
systemctl start fusioninventory-agent; [ $? -ne 0 ] && erroDetect
fusioninventory-agent --force; [ $? -ne 0 ] && erroDetect
else
erroDescription="Error to start fusioninventory-agent"
# Iniciando o serviço fusioninventory
launchctl start org.fusioninventory.agent; [ $? -ne 0 ] && erroDetect
erroDescription="Error to start fusioninventory-agent"
# Iniciando o serviço fusioninventory
/opt/fusioninventory-agent/bin/fusioninventory-agent; [ $? -ne 0 ] && erroDetect
fi
}
INSTALL
clear
echo -e "
\033[32m
-----------------------------------------------------------
# Congratulations! #
-----------------------------------------------------------\033[0m
| |
|\033[34m Apparently, everything went well.\033[0m |
|\033[34m Know our services and products for you and your company.\033[0m |
|\033[34m Conheca nossos servicos e produtos.\033[0m |
-----------------------------------------------------------
|\033[32m https://www.verdanatech.com\033[0m |
-----------------------------------------------------------
"