-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_Broker.sh
45 lines (35 loc) · 922 Bytes
/
setup_Broker.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
#!/bin/bash
# File name to be created/edited
FILENAME="config.conf"
# Create and edit the file using ex (part of Vim)
ex "$FILENAME" <<EOF
i
# add some debug output
#trace_output protocol
allow_anonymous true
# listen for MQTT-SN traffic on UDP port 1885
listener 1885 INADDR_ANY mqtts
ipv6 true
# listen to MQTT connections on tcp port 1886
listener 1886 INADDR_ANY
ipv6 true
.
wq
EOF
# Execute the command and store the output in a variable
output=$(ip -6 -o addr show eth0)
# Print the output
echo "The output of the command is:"
echo "$output"
# Loop to restart the broker_mqtts process
while true; do
# Run your command
broker_mqtts "$FILENAME"
# Optional: sleep for a period to avoid rapid restarts in case of immediate failure
sleep 5
# Check for a stop file
if [ -f "/tmp/stop_script" ]; then
echo "Stop file detected. Exiting the script."
break
fi
done