-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-mqtt_sniffer.sh
executable file
·48 lines (45 loc) · 1.58 KB
/
install-mqtt_sniffer.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
#!/bin/sh
echo ===== install-mqtt_sniffer.sh: Specify a broker =====
echo Enter the IP address of the MQTT broker.
echo This is optional. If you enter an IP address, the installer
echo will run MQTT listener when installation is complete.
echo "IP address: \c"
read BROKER_IP
if [ $BROKER_IP ]
then
echo ===== install-mqtt_sniffer.sh: Specify a nodename =====
echo Enter the name of the node you wish to follow.
echo This is optional. If you enter a nodename, MQTT listener
echo will only listen for MQTT topics with that nodename.
echo If you do not enter a nodename, MQTT listener will
echo listen for all MQTT topics on the MQTT broker.
echo "Nodename: \c"
read NODENAME
fi
echo ===== install-mqtt_sniffer.sh: Installing dependencies =====
sudo apt update -y
sudo apt install -y python3-pip python3-protobuf
pip3 install paho-mqtt
if [ $? -ne 0 ]
then
echo ===== install-mqtt_sniffer.sh FAIL: Could not install dependencies =====
exit 1
fi
echo ===== install-mqtt_sniffer.sh: Dependencies successfully installed =====
if [ $BROKER_IP ]
then
echo ===== install-mqtt_sniffer.sh: Starting MQTT Listener =====
if [ $NODENAME ]
then
echo ">" python3 mqtt_sniffer.py -i $BROKER_IP -N $NODENAME
python3 mqtt_sniffer.py -i $BROKER_IP -N $NODENAME
else
echo ">" python3 mqtt_sniffer.py -i $BROKER_IP
python3 mqtt_sniffer.py -i $BROKER_IP
fi
else
echo ===== install-mqtt_sniffer.sh: Installation completed =====
echo Execute \`python3 mqtt_sniffer.py -i \<your-ip-address-here\>\`
echo to run.
echo Execute \`python3 mqtt_sniffer.py --help\' to view the Help message.
fi