-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetupHomeAuto-arm64.sh
378 lines (326 loc) · 14.5 KB
/
SetupHomeAuto-arm64.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
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
#!/bin/bash
# portainer config
PORTAINER_IMAGE="portainer/portainer-ce:linux-arm64"
PORTAINER_SERVICE_NAME=portainer
PORTAINER_SERVICE_DESCRIPTION="Portainer Container Manager"
PORTAINER_SERVICE_USER=portainer
PORTAINER_PORTS=(9000)
PORTAINER_VOLUME_NAMES=("/opt/portainer" "portainer-data:/data" "/var/run/docker.sock:/var/run/docker.sock" "/etc/timezone:/etc/timezone:ro" "/etc/localtime:/etc/localtime:ro")
PORTAINER_VOLUME_PATHS=("/opt/portainer" "/opt/portainer/data")
PORTAINER_ENVIRONMENT_VARIABLES=()
PORTAINER_DEVICES=()
# deCONZ config
DECONZ_IMAGE="deconzcommunity/deconz:latest"
DECONZ_SERVICE_NAME=deconz
DECONZ_SERVICE_DESCRIPTION="deCONZ Zigbee Utility"
DECONZ_SERVICE_USER=deconz
DECONZ_PORTS=(8000 4430 5900)
DECONZ_VOLUME_NAMES=("deconz-data:/opt/deconz" "/etc/timezone:/etc/timezone:ro" "/etc/localtime:/etc/localtime:ro")
DECONZ_VOLUME_PATHS=("/opt/deconz")
DECONZ_VNC_PASSWORD=$(< /dev/urandom tr -dc \!\@\#\$\%\^\&\*\(\)\{\}\;\:\'\~\|\\_A-Z-a-z-0-9 | head -c8)
DECONZ_ENVIRONMENT_VARIABLES=("DECONZ_VNC_MODE=1" "DECONZ_VNC_PORT=${DECONZ_PORTS[2]}" "DECONZ_VNC_PASSWORD=$DECONZ_VNC_PASSWORD" "DECONZ_WEB_PORT=${DECONZ_PORTS[0]}" "DECONZ_WS_PORT=${DECONZ_PORTS[1]}")
DECONZ_DEVICES=("/dev/zigbee:/dev/ttyACM0")
# OpenHAB config
OPENHAB_IMAGE="openhab/openhab:3.4.0-snapshot-alpine"
OPENHAB_SERVICE_NAME=openhab
OPENHAB_SERVICE_DESCRIPTION="OpenHAB Home Automation"
OPENHAB_SERVICE_USER=openhab
OPENHAB_PORTS=(8080)
OPENHAB_VOLUME_NAMES=("/opt/openhab" "openhab-conf:/openhab/conf" "openhab-userdata:/openhab/userdata" "openhab-addons:/openhab/addons" "openhab-java:/openhab/.java" "/etc/timezone:/etc/timezone:ro" "/etc/localtime:/etc/localtime:ro")
OPENHAB_VOLUME_PATHS=("/opt/openhab" "/opt/openhab/conf" "/opt/openhab/userdata" "/opt/openhab/addons" "/opt/openhab/.java")
OPENHAB_ENVIRONMENT_VARIABLES=("CRYPTO_POLICY=unlimited")
OPENHAB_DEVICES=(/dev/zwave)
# SEPIA config
SEPIA_IMAGE="sepia/home:latest"
SEPIA_SERVICE_NAME=sepia
SEPIA_SERVICE_DESCRIPTION="SEPIA Home"
SEPIA_SERVICE_USER=sepia
SEPIA_PORTS=(20741)
SEPIA_VOLUME_NAMES=("sepia-home-data:/home/admin/sepia-home-data" "/etc/timezone:/etc/timezone:ro" "/etc/localtime:/etc/localtime:ro")
SEPIA_VOLUME_PATHS=("/opt/sepia")
SEPIA_ENVIRONMENT_VARIABLES=()
SEPIA_DEVICES=()
# SEPIA-STT config
SEPIA_STT_IMAGE="sepia/stt-server:vosk_aarch64"
SEPIA_STT_SERVICE_NAME=sepia-stt
SEPIA_STT_SERVICE_DESCRIPTION="SEPIA Speech-To-Text"
SEPIA_STT_SERVICE_USER=sepia
SEPIA_STT_PORTS=(20741)
SEPIA_STT_VOLUME_NAMES=("/etc/timezone:/etc/timezone:ro" "/etc/localtime:/etc/localtime:ro")
SEPIA_STT_VOLUME_PATHS=()
SEPIA_STT_ENVIRONMENT_VARIABLES=()
SEPIA_STT_DEVICES=()
# Mosquitto config
MOSQUITTO_IMAGE="eclipse-mosquitto:latest"
MOSQUITTO_SERVICE_NAME=mosquitto
MOSQUITTO_SERVICE_DESCRIPTION="Eclipse Mosquitto"
MOSQUITTO_SERVICE_USER=mqtt
MOSQUITTO_PORTS=(1883 9001)
MOSQUITTO_VOLUME_NAMES=("/opt/mosquitto" "mosquitto-config:/mosquitto/config" "mosquitto-data:/mosquitto/data" "mosquitto-log:/mosquitto/log" "/etc/timezone:/etc/timezone:ro" "/etc/localtime:/etc/localtime:ro")
MOSQUITTO_VOLUME_PATHS=("/opt/mosquitto" "/opt/mosquitto/config" "/opt/mosquitto/data" "/opt/mosquitto/log")
SEPIA_STT_ENVIRONMENT_VARIABLES=()
MOSQUITTO_DEVICES=()
# Zigbee2MQTT config
ZIGBEE2MQTT_IMAGE="zigbee2mqtt/zigbee2mqtt-edge-aarch64:latest"
ZIGBEE2MQTT_SERVICE_NAME=zigbee2mqtt
ZIGBEE2MQTT_SERVICE_DESCRIPTION="Zigbee2MQTT Broker"
ZIGBEE2MQTT_SERVICE_USER=mqtt
ZIGBEE2MQTT_PORTS=(8008)
ZIGBEE2MQTT_VOLUME_NAMES=("/opt/zigbee2mqtt" "zigbee2mqtt-app-data:/app/data" "/run/udev:/run/udev:ro")
ZIGBEE2MQTT_VOLUME_PATHS=("/opt/zigbee2mqtt" "/opt/zigbee2mqtt/data")
ZIGBEE2MQTT_ENVIRONMENT_VARIABLES=()
ZIGBEE2MQTT_DEVICES=()
# Other variables
NC='\033[0m' # No Color
# Function that creates the services
function create_service () {
PORTS=""
for i in ${SERVICE_PORTS[@]}; do PORTS+=" -p ${i}:${i} \\\\\n";done
PORTS=${PORTS%\\\n}
VOLUMES=""
for i in ${VOLUME_NAMES[@]}
do
if [[ ${i} == *":"* ]]
then
VOLUMES+=" -v ${i} \\\\\n"
fi
done
VOLUMES=${VOLUMES%\\\n}
ENV_VARS=""
for i in ${ENVIRONMENT_VARIABLES[@]}; do ENV_VARS+=" -e ${i} \\\\\n";done
ENV_VARS=${ENV_VARS%\\\n}
DEVICES=""
for i in ${SERVICE_DEVICES[@]}; do DEVICES+=" --device=${i} \\\\\n";done
DEVICES=${DEVICES%\\\n}
echo -en "\033[0;96mCreating shared folders: $NC"
COUNTER=0
for i in ${VOLUME_PATHS[@]}
do
sudo mkdir -p ${i} 1> /dev/null
sudo chown -R $SERVICE_USER:$SERVICE_USER ${i} 1> /dev/null
if [[ $i == *"/opt/"* ]] && [[ ${VOLUME_NAMES[COUNTER]} == *":"* ]]
then
VOL=(${VOLUME_NAMES[$COUNTER]//:/ })
if [[ ${VOL[0]} != *"/"* ]]
then
sudo docker volume create --opt type=none --opt device=$i --opt o=bind ${VOL[0]} 1> /dev/null
fi
fi
let COUNTER++
done
echo -e "\033[1;92mComplete!$NC"
echo -en "\033[0;96mCreating $SERVICE_DESCRIPTION service container: $NC"
sudo docker pull $IMAGE 1> /dev/null
sudo rm -rf /lib/systemd/system/$SERVICE_NAME.service 1> /dev/null
sudo tee -a /lib/systemd/system/$SERVICE_NAME.service > /dev/null <<EOT
[Unit]
Description=$SERVICE_DESCRIPTION
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker run --rm --name=%n \\
EOT
rm ./temp.service
if [[ ! -z "$PORTS" ]]
then
echo -e "$PORTS" >> ./temp.service
fi
if [[ ! -z "$VOLUMES" ]]
then
echo -e "$VOLUMES" >> ./temp.service
fi
if [[ ! -z "$ENV_VARS" ]]
then
echo -e "$ENV_VARS" >> ./temp.service
fi
if [[ ! -z "$DEVICES" ]]
then
echo -e "$DEVICES" >> ./temp.service
fi
sudo bash -c "cat ./temp.service >> /lib/systemd/system/$SERVICE_NAME.service"
sudo tee -a /lib/systemd/system/$SERVICE_NAME.service > /dev/null <<EOT
$IMAGE
ExecStop=/usr/bin/docker stop -t 2 %n ; /usr/bin/docker rm -f %n
[Install]
WantedBy=multi-user.target
EOT
echo -e "\033[1;92mComplete!$NC"
}
# install basics
echo -en "\033[0;96mInstalling base software and configuring calendar: $NC"
sudo apt -y install vim chromium-browser docker.io &> /dev/null
sudo usermod -a -G docker $USER 1> /dev/null
echo -e "\033[1;92mComplete!$NC"
# unpack IOTstack tools (Placed here for convenience and curiosity)
# tar -xzf IOTstack.tgz
# Create permanent links to usb serial devices for z-wave and zigbee communications.
# THESE DEVICE IDS ARE FOR DECONZ CONBEE2 USB ZIGBEE DEVICE
# https://www.amazon.com/Controller-SmartStart-Raspberry-Compatible-SmartThings/dp/B089GSFKYW/ref=sr_1_3?crid=2CW0BPKW4M11Y&keywords=z-stick&qid=1657250929&sprefix=z-stick%2Caps%2C105&sr=8-3&ufe=app_do%3Aamzn1.fos.fa474cd8-6dfc-4bad-a280-890f5a4e2f90
# AND AEOTEC Z-STICK USB Z-WAVE DEVICES
# https://www.amazon.com/dresden-elektronik-ConBee-Universal-Gateway/dp/B07PZ7ZHG5/ref=sr_1_3?crid=VMC4ZP3TQEXW&keywords=conbee+2&qid=1657250972&sprefix=conbee+2%2Caps%2C93&sr=8-3
# YOU WILL NEED TO DETERMINE THE APPROPRIATE UDEVADM COMMANDS TO REVEAL YOUR USB DEVICE IDS
echo -en "\033[0;96mAdding static device names for z-wave and zigbee adapters: $NC"
sudo bash -c 'echo "SUBSYSTEM==\"tty\", ATTRS{idVendor}==\"1cf1\", ATTRS{idProduct}==\"0030\", ATTRS{serial}==\"DE2469919\", SYMLINK+=\"zigbee\"" > /etc/udev/rules.d/99-usb-serial.rules' 1> /dev/null
sudo bash -c 'echo "SUBSYSTEM==\"tty\", ATTRS{idVendor}==\"0658\", ATTRS{idProduct}==\"0200\", SYMLINK+=\"zwave\"" >> /etc/udev/rules.d/99-usb-serial.rules' 1> /dev/null
echo -e "\033[1;92mComplete!$NC"
echo -e "\033[0;96mSetting up container services. THIS WILL TAKE A FEW MINUTES. $NC"
# install docker and portainer
SERVICE_NAME=$PORTAINER_SERVICE_NAME
SERVICE_DESCRIPTION=$PORTAINER_SERVICE_DESCRIPTION
SERVICE_USER=$PORTAINER_SERVICE_USER
SERVICE_PORTS=(${PORTAINER_PORTS[@]})
VOLUME_NAMES=(${PORTAINER_VOLUME_NAMES[@]})
VOLUME_PATHS=(${PORTAINER_VOLUME_PATHS[@]})
SERVICE_DEVICES=(${PORTAINER_DEVICES[@]})
IMAGE=$PORTAINER_IMAGE
echo -en "\033[0;96mCreating $SERVICE_USER: $NC"
sudo useradd -r -s /sbin/nologin $SERVICE_USER 1> /dev/null
sudo usermod -a -G $SERVICE_USER $SERVICE_USER 1> /dev/null
echo -e "\033[1;92mComplete!$NC"
SERVICE_USER_UID=$(id -u $SERVICE_USER)
SERVICE_USER_GID=$(id -g $SERVICE_USER)
PORTAINER_ENVIRONMENT_VARIABLES+=("USER_ID=$SERVICE_USER_UID")
PORTAINER_ENVIRONMENT_VARIABLES+=("GROUP_ID=$SERVICE_USER_GID")
ENVIRONMENT_VARIABLES=(${PORTAINER_ENVIRONMENT_VARIABLES[@]})
create_service
# sudo ln -s /lib/systemd/system/portainer.service /etc/systemd/system/portainer.service
# install deconz for conbee2 zigbee stick
SERVICE_NAME=$DECONZ_SERVICE_NAME
SERVICE_DESCRIPTION=$DECONZ_SERVICE_DESCRIPTION
SERVICE_USER=$DECONZ_SERVICE_USER
SERVICE_PORTS=(${DECONZ_PORTS[@]})
VOLUME_NAMES=(${DECONZ_VOLUME_NAMES[@]})
VOLUME_PATHS=(${DECONZ_VOLUME_PATHS[@]})
SERVICE_DEVICES=(${DECONZ_DEVICES[@]})
IMAGE=$DECONZ_IMAGE
echo -en "\033[0;96mCreating $SERVICE_USER: $NC"
sudo useradd -r -s /sbin/nologin $SERVICE_USER 1> /dev/null
sudo usermod -a -G $SERVICE_USER $SERVICE_USER 1> /dev/null
sudo usermod -a -G dialout $SERVICE_USER 1> /dev/null
echo -e "\033[1;92mComplete!$NC"
SERVICE_USER_UID=$(id -u $SERVICE_USER)
SERVICE_USER_GID=$(id -g $SERVICE_USER)
DECONZ_ENVIRONMENT_VARIABLES+=("DECONZ_UID=$SERVICE_USER_UID")
DECONZ_ENVIRONMENT_VARIABLES+=("DECONZ_GID=$SERVICE_USER_GID")
ENVIRONMENT_VARIABLES=(${DECONZ_ENVIRONMENT_VARIABLES[@]})
create_service
# sudo ln -s /lib/systemd/system/deconz.service /etc/systemd/system/deconz.service
# install openHAB
SERVICE_NAME=$OPENHAB_SERVICE_NAME
SERVICE_DESCRIPTION=$OPENHAB_SERVICE_DESCRIPTION
SERVICE_USER=$OPENHAB_SERVICE_USER
SERVICE_PORTS=(${OPENHAB_PORTS[@]})
VOLUME_NAMES=(${OPENHAB_VOLUME_NAMES[@]})
VOLUME_PATHS=(${OPENHAB_VOLUME_PATHS[@]})
SERVICE_DEVICES=(${OPENHAB_DEVICES[@]})
IMAGE=$OPENHAB_IMAGE
echo -en "\033[0;96mCreating $SERVICE_USER: $NC"
sudo useradd -r -s /sbin/nologin $SERVICE_USER 1> /dev/null
sudo usermod -a -G $SERVICE_USER $SERVICE_USER 1> /dev/null
echo -e "\033[1;92mComplete!$NC"
SERVICE_USER_UID=$(id -u $SERVICE_USER)
SERVICE_USER_GID=$(id -g $SERVICE_USER)
OPENHAB_ENVIRONMENT_VARIABLES+=("USER_ID=$SERVICE_USER_UID")
OPENHAB_ENVIRONMENT_VARIABLES+=("GROUP_ID=$SERVICE_USER_GID")
ENVIRONMENT_VARIABLES=(${OPENHAB_ENVIRONMENT_VARIABLES[@]})
create_service
# sudo ln -s /lib/systemd/system/openhab.service /etc/systemd/system/openhab.service
# install Sepia
SERVICE_NAME=$SEPIA_SERVICE_NAME
SERVICE_DESCRIPTION=$SEPIA_SERVICE_DESCRIPTION
SERVICE_USER=$SEPIA_SERVICE_USER
SERVICE_PORTS=(${SEPIA_PORTS[@]})
VOLUME_NAMES=(${SEPIA_VOLUME_NAMES[@]})
VOLUME_PATHS=(${SEPIA_VOLUME_PATHS[@]})
SERVICE_DEVICES=(${SEPIA_DEVICES[@]})
IMAGE=$SEPIA_IMAGE
sudo bash -c 'echo "vm.max_map_count=262144" >> /etc/sysctl.conf'
echo -en "\033[0;96mCreating $SERVICE_USER: $NC"
sudo useradd -r -s /sbin/nologin $SERVICE_USER 1> /dev/null
sudo usermod -a -G $SERVICE_USER $SERVICE_USER 1> /dev/null
echo -e "\033[1;92mComplete!$NC"
SERVICE_USER_UID=$(id -u $SERVICE_USER)
SERVICE_USER_GID=$(id -g $SERVICE_USER)
SEPIA_ENVIRONMENT_VARIABLES+=("USER_ID=$SERVICE_USER_UID")
SEPIA_ENVIRONMENT_VARIABLES+=("GROUP_ID=$SERVICE_USER_GID")
ENVIRONMENT_VARIABLES=(${SEPIA_ENVIRONMENT_VARIABLES[@]})
create_service
# sudo ln -s /lib/systemd/system/sepia.service /etc/systemd/system/sepia.service
# install Sepia-STT
SERVICE_NAME=$SEPIA_STT_SERVICE_NAME
SERVICE_DESCRIPTION=$SEPIA_STT_SERVICE_DESCRIPTION
SERVICE_USER=$SEPIA_STT_SERVICE_USER
SERVICE_PORTS=(${SEPIA_STT_PORTS[@]})
VOLUME_NAMES=(${SEPIA_STT_VOLUME_NAMES[@]})
VOLUME_PATHS=(${SEPIA_STT_VOLUME_PATHS[@]})
SERVICE_DEVICES=(${SEPIA_STT_DEVICES[@]})
IMAGE=$SEPIA_STT_IMAGE
SEPIA_STT_ENVIRONMENT_VARIABLES+=("USER_ID=$SERVICE_USER_UID")
SEPIA_STT_ENVIRONMENT_VARIABLES+=("GROUP_ID=$SERVICE_USER_GID")
ENVIRONMENT_VARIABLES=(${SEPIA_STT_ENVIRONMENT_VARIABLES[@]})
create_service
# sudo ln -s /lib/systemd/system/sepia-stt.service /etc/systemd/system/sepia-stt.service
# setup Mosquitto for MQTT broker for zigbee
SERVICE_NAME=$MOSQUITTO_SERVICE_NAME
SERVICE_DESCRIPTION=$MOSQUITTO_SERVICE_DESCRIPTION
SERVICE_USER=$MOSQUITTO_SERVICE_USER
SERVICE_PORTS=(${MOSQUITTO_PORTS[@]})
VOLUME_NAMES=(${MOSQUITTO_VOLUME_NAMES[@]})
VOLUME_PATHS=(${MOSQUITTO_VOLUME_PATHS[@]})
SERVICE_DEVICES=(${MOSQUITTO_DEVICES[@]})
IMAGE=$MOSQUITTO_IMAGE
# get current user id and group id's for service creation
echo -en "\033[0;96mCreating $SERVICE_USER: $NC"
sudo useradd -r -s /sbin/nologin $SERVICE_USER 1> /dev/null
sudo usermod -a -G $SERVICE_USER $SERVICE_USER 1> /dev/null
echo -e "\033[1;92mComplete!$NC"
SERVICE_USER_UID=$(id -u $SERVICE_USER)
SERVICE_USER_GID=$(id -g $SERVICE_USER)
MOSQUITTO_ENVIRONMENT_VARIABLES+=("USER_ID=$SERVICE_USER_UID")
MOSQUITTO_ENVIRONMENT_VARIABLES+=("GROUP_ID=$SERVICE_USER_GID")
ENVIRONMENT_VARIABLES=(${MOSQUITTO_ENVIRONMENT_VARIABLES[@]})
create_service
# sudo ln -s /lib/systemd/system/mosquitto.service /etc/systemd/system/mosquitto.service
# create zigbee2mqtt broker
SERVICE_NAME=$ZIGBEE2MQTT_SERVICE_NAME
SERVICE_DESCRIPTION=$ZIGBEE2MQTT_SERVICE_DESCRIPTION
SERVICE_USER=$ZIGBEE2MQTT_SERVICE_USER
SERVICE_PORTS=(${ZIGBEE2MQTT_PORTS[@]})
VOLUME_NAMES=(${ZIGBEE2MQTT_VOLUME_NAMES[@]})
VOLUME_PATHS=(${ZIGBEE2MQTT_VOLUME_PATHS[@]})
SERVICE_DEVICES=(${ZIGBEE2MQTT_DEVICES[@]})
IMAGE=$ZIGBEE2MQTT_IMAGE
ZIGBEE2MQTT_ENVIRONMENT_VARIABLES+=("USER_ID=$SERVICE_USER_UID")
ZIGBEE2MQTT_ENVIRONMENT_VARIABLES+=("GROUP_ID=$SERVICE_USER_GID")
ENVIRONMENT_VARIABLES=(${ZIGBEE2MQTT_ENVIRONMENT_VARIABLES[@]})
create_service
# sudo ln -s /lib/systemd/system/zigbee2mqtt.service /etc/systemd/system/zigbee2mqtt.service
# enabling all new services
sudo systemctl daemon-reload 1> /dev/null
sudo systemctl enable portainer.service 1> /dev/null
sudo systemctl enable deconz.service 1> /dev/null
sudo systemctl enable openhab.service 1> /dev/null
sudo systemctl enable sepia.service 1> /dev/null
sudo systemctl enable sepia-stt.service 1> /dev/null
sudo systemctl enable mosquitto.service 1> /dev/null
sudo systemctl enable zigbee2mqtt.service 1> /dev/null
echo -e "\033[0;93mPortainer is running on port(s): \033[1;31m${PORTAINER_PORTS[*]}"
echo -e "\033[0;93mDeCONZ is running on port(s): \033[1;31m${DECONZ_PORTS[*]}"
echo -e "\033[0;93mOpenHAB is running on port(s): \033[1;31m${OPENHAB_PORTS[*]}"
echo -e "\033[0;93mSEPIA Home is running on port(s): \033[1;31m${SEPIA_PORTS[*]}"
echo -e "\033[0;93mSEPIA-STT Home is running on port(s): \033[1;31m${SEPIA_STT_PORTS[*]}"
echo -e "\033[0;93mEclipse Mosquitto is running on port(s): \033[1;31m${MOSQUITTO_PORTS[*]}"
echo -e "\033[0;93mZigbee2MQTT is running on port(s): \033[1;31m${ZIGBEE2MQTT_PORTS[*]}$NC"
# set hostname
read -p "Enter this Pi's hostname:" NEWHOSTNAME
sudo sed -i -e "s/$HOSTNAME/$NEWHOSTNAME/g" /etc/hosts &> /dev/null
sudo sed -i -e "s/$HOSTNAME/$NEWHOSTNAME/g" /etc/hostname &> /dev/null
#sudo hostname $NEWHOSTNAME
# complete and reboot
echo Setup is complete.
read -p "Reboot system? [Y/n] " REBOOT_COMMAND
if [ $REBOOT_COMMAND = "Y" ] || [ $REBOOT_COMMAND = "y" ]
then
sudo reboot &> /dev/null
fi