-
Notifications
You must be signed in to change notification settings - Fork 1
/
instala_tudo.sh
102 lines (87 loc) · 2.94 KB
/
instala_tudo.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
#! /usr/bin/bash
# Shield RaspLoRaWAN+: script de instalação das ferramentas e serviços
#
# Este script prepara a Raspberry Pi para utilizar o sheild RaspLoRaWAN+,
# instalando todas as ferramentas e serviços necessários para seu funcionamento.
#
# Autor: Pedro Bertoleti
# Data: Junho/2021
if (( $EUID != 0 )); then
echo "ERRO: esse script precisa ser executado como root. Utilize o comando 'sudo ./instala_tudo.sh'"
exit
fi
echo "##########################"
echo "# Etapa 1: dependencias #"
echo "##########################"
echo " "
echo " "
echo "- Dependencias: apt-get"
sudo apt-get update
# Verifica as dependencias (apt-get)
array_dep_cmd=("python3" \
"pip3" \
"mosquitto" \
"git" )
array_dep_aptget=("python3" \
"python3-pip" \
"mosquitto" \
"git" )
dep_idx=0
for dep_atual in "${array_dep_cmd[@]}"
do
if command -v $dep_atual >/dev/null 2>&1
then
echo "* Dependencia $dep_atual ja instalada."
else
echo "* Dependencia $dep_atual nao encontrada. Fazendo instalacao..."
sudo apt-get -y install ${array_dep_aptget[$dep_idx]}
fi
dep_idx=$(( $dep_idx+1 ))
done
# Instala a biblioteca Paho-MQTT (lib python)
echo " "
echo "- Dependencias: lib python paho-mqtt"
sudo pip3 install paho-mqtt
# Instala a biblioteca Paho-MQTT (lib C)
echo " "
echo "- Dependencias: lib C paho-mqtt"
LIB_PAHO_MQTT_C_1='/usr/local/lib/libpaho-mqtt3c.so'
LIB_PAHO_MQTT_C_2='/usr/lib/libpaho-mqtt3c.so'
LIB_PAHO_MQTT_C_3='/lib/libpaho-mqtt3c.so'
if [[ -s $LIB_PAHO_MQTT_C_1 ]] || [[ -s $LIB_PAHO_MQTT_C_2 ]] || [[ -s $LIB_PAHO_MQTT_C_3 ]]
then
echo "lib C paho-mqtt ja esta instalada."
else
echo "Instalando lib C paho-mqtt..."
sudo apt-get -y install libssl-dev doxygen
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make -j4
make html
sudo make install
fi
echo "#######################################################"
echo "# Etapa 2: compilacao do servico (comunicacao ESP32) #"
echo "#######################################################"
echo " "
echo " "
cd Raspberry/recebe_envia_dados_uart
make
mkdir /home/pi/recebe_envia_dados_uart
cp recebe_envia_dados_uart /home/pi/recebe_envia_dados_uart
cd ../..
echo "###############################################################"
echo "# Etapa 3: habilita o servico (comunicacao ESP32) no systemd #"
echo "###############################################################"
echo " "
echo " "
sudo cp Raspberry/unit_files/recebe_envia_esp32.service /etc/systemd/system/
sudo systemctl start recebe_envia_esp32.service
sudo systemctl enable recebe_envia_esp32.service
echo " "
echo " "
echo "########################################################################"
echo "# Fim da instalacao. Software do shiels Rasp LoRaWAN pronto para uso! #"
echo "########################################################################"
echo " "
echo " "