This repository was archived by the owner on Mar 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhmcon-setup.sh
executable file
·651 lines (545 loc) · 18 KB
/
hmcon-setup.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
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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#!/bin/bash
VERSION=0.18
USER=hmcon
PREFIX=/opt/hmcon
VAR=$PREFIX/var
ETC=$PREFIX/etc
ASK_TO_REBOOT=0
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
whiptail --msgbox "Hmcon Setup $VERSION" 20 72
command -v git >/dev/null 2>&1 || { apt-get install git; }
mkdir -p $ETC >/dev/null 2>&1
mkdir -p $VAR/log >/dev/null 2>&1
mkdir -p $VAR/firmware >/dev/null 2>&1
mkdir -p $PREFIX/lib >/dev/null 2>&1
mkdir -p $PREFIX/bin >/dev/null 2>&1
echo "{\"version\":\"$VERSION\"}" > $PREFIX/hmcon.json
echo "$PREFIX/lib/" > /etc/ld.so.conf.d/hm.conf
echo "PATH=\$PATH:$PREFIX/bin" > /etc/profile.d/hm.sh
echo "export PATH" >> /etc/profile.d/hm.sh
chmod a+x /etc/profile.d/hm.sh
/etc/profile.d/hm.sh
if [ -f "/etc/init.d/rfd" ]; then
/etc/init.d/rfd stop
fi
if [ -f "/etc/init.d/hs485d" ]; then
/etc/init.d/hs485d stop
fi
if [ -f "/etc/init.d/hm-manager" ]; then
/etc/init.d/hm-manager stop
fi
if id -u "$USER" >/dev/null 2>&1; then
usermod -s /bin/false -d $PREFIX $USER
else
echo "Adding user $USER"
useradd -r -s /bin/false -d $PREFIX $USER
fi
ARCH=`arch`
mkdir -p $PREFIX/src/occu >/dev/null 2>&1
if [ -d "$PREFIX/src/occu/.git" ]; then
cd $PREFIX/src/occu
echo "Pull https://github.com/eq-3/occu"
git checkout master
git pull
else
echo "Clone https://github.com/eq-3/occu"
git clone https://github.com/eq-3/occu $PREFIX/src/occu
fi
echo "Checking libs"
if [[ "$ARCH" == "arm"* ]]; then
SRC=$PREFIX/src/occu/arm-gnueabihf/packages-eQ-3
apt-get install libusb-1.0-0
else
SRC=$PREFIX/src/occu/X86_32_Debian_Wheezy/packages-eQ-3
if [[ "$ARCH" == "x86_64" ]]; then
apt-get install libc6:i386 libstdc++6:i386
apt-get install libusb-1.0-0:i386
else
apt-get install libusb-1.0-0
fi
fi
cp -R $PREFIX/src/occu/firmware $PREFIX/
cp $SRC/LinuxBasis/bin/eq3configcmd $PREFIX/bin/
cp $SRC/LinuxBasis/lib/libeq3config.so $PREFIX/lib/
rfd() {
mkdir -p $VAR/rfd/devices >/dev/null 2>&1
mkdir -p $PREFIX/bin >/dev/null 2>&1
# use rfd from 2.27.7 occu (classic rfd without HmIP Support - not crRFD, no multimacd)
cd $PREFIX/src/occu
echo "checking out OCCU 2.27.7"
git checkout 532edbdf01dae7a595323a318711e14853124539 .
cp $SRC/RFD/bin/rfd $PREFIX/bin/
cp $SRC/RFD/bin/SetInterfaceClock $PREFIX/bin/
cp $SRC/RFD/bin/avrprog $PREFIX/bin/
echo "checking out OCCU head"
git reset --hard
# Install libs
cp -R $SRC/RFD/lib $PREFIX/
ldconfig
# Config file
rfdInterface() {
i=0
ADD=1
while [ $ADD -gt 0 ];
do
opt=$(whiptail --radiolist test 20 60 4 "HM-MOD-RPI-PCB" "HM-MOD-RPI-PCB" "HM-MOD-RPI-PCB" "HM-CFG-USB-2" "HM-CFG-USB-2" "HM-CFG-USB-2" "HM-CFG-LAN" "HM-CFG-LAN" "HM-CFG-LAN" "HM-LGW-O-TW-W-EU" "HM-LGW-O-TW-W-EU" "HM-LGW-O-TW-W-EU" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
case $opt in
"HM-MOD-RPI-PCB")
#prepare additional snippet for rfd init script
SetupGPIO="# export GPIO
if [ ! -d /sys/class/gpio/gpio18 ] ; then
echo 18 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio18/direction
fi
"
# disable serial console (code from raspi-config)
echo "disabling serial-console"
if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
SYSTEMD=1
elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
SYSTEMD=0
else
echo "[Warning] Unrecognised init system"
fi
if [ $SYSTEMD -eq 0 ]; then
sed -i /etc/inittab -e "s|^.*:.*:respawn:.*ttyAMA0|#&|"
fi
sed -i /boot/cmdline.txt -e "s/console=ttyAMA0,[0-9]\+ //"
sed -i /boot/cmdline.txt -e "s/console=serial0,[0-9]\+ //"
ASK_TO_REBOOT=1
# allow hmcon gpio access when using HM-MOD-RPI-PCB
# if group gpio doesn't exist, creat it and create a corresponding udev-rule
if ! grep gpio /etc/group >/dev/null 2>&1; then
groupadd gpio
UDEVFILE=99-rfd-gpio.rules
echo "creating new udev-rule for gpio"
cat > /etc/udev/rules.d/$UDEVFILE <<- EOM
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio; chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio; chown -R root:gpio /sys/devices/platform/soc/*.gpio/gpio && chmod -R 770 /sys/devices/platform/soc/*.gpio/gpio'"
EOM
if grep "SUBSYSTEM==\"gpio\"" --exclude=$UDEVFILE /etc/udev/rules.d/* >/dev/null 2>&1; then
echo ""
echo "[WARNING] Another udev-rule for the gpios is already in place and may conflict with the one added here.\r"
echo "[WARNING] The rule in question is: "
grep "SUBSYSTEM==\"gpio\"" --exclude=$UDEVFILE /etc/udev/rules.d/*
echo "[WARNING] Check rfd.log for errors"
fi
udevadm control --reload-rules
fi
echo "adding user hmcon to gpio and dialout group"
usermod -a -G gpio,dialout $USER
cat >> $ETC/rfd.conf <<- EOM
[Interface $i]
Type = CCU2
ComPortFile = /dev/ttyAMA0
AccessFile = /dev/null
ResetFile = /sys/class/gpio/gpio18/value
EOM
i=`expr $i + 1`
;;
"HM-CFG-USB-2")
SERIAL=$(whiptail --inputbox "\n\nEnter Serial Number" 20 60 "" --title "HM-CFG-USB-2 Serial" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
continue;
fi
cat >> $ETC/rfd.conf <<- EOM
[Interface $i]
Type = USB Interface
Serial Number = $SERIAL
EOM
# Add UDEV Rule to prevent occupation of USB Interface
# FIXME ugly world writeable. Should be USER=\"$USER\" instead of MODE=\"0666\" - but this didn't work with ubuntu
echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"1b1f\", ATTR{idProduct}==\"c00f\", MODE:=\"0666\"" > /etc/udev/rules.d/homematic.rules
echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"1b1f\", ATTR{idProduct}==\"c010\", MODE:=\"0666\"" >> /etc/udev/rules.d/homematic.rules
i=`expr $i + 1`
;;
"HM-CFG-LAN")
SERIAL=$(whiptail --inputbox "\n\nEnter Serial Number" 20 60 --title "HM-CFG-LAN Serial" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
continue;
fi
KEY=$(whiptail --inputbox "\n\nEnter Encryption Key" 20 60 --title "HM-CFG-LAN Key" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
continue;
fi
cat >> $ETC/rfd.conf <<- EOM
[Interface $i]
Type = Lan Interface
Serial Number = $SERIAL
Encryption Key = $KEY
EOM
i=`expr $i + 1`
;;
"HM-LGW-O-TW-W-EU")
SERIAL=$(whiptail --inputbox "\n\nEnter Serial Number" 20 60 --title "HM-LGW-O-TW-W-EU Serial" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
continue;
fi
KEY=$(whiptail --inputbox "\n\nEnter Encryption Key" 20 60 --title "HM-LGW-O-TW-W-EU Key" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
continue;
fi
cat >> $ETC/rfd.conf <<- EOM
[Interface $i]
Type = HMLGW2
Description = HM-LGW-O-TW-W-EU
Serial Number = $SERIAL
Encryption Key = $KEY
EOM
i=`expr $i + 1`
;;
esac
fi
whiptail --yesno "Add another rf interface" 20 60 2
if [ $? -eq 0 ]; then # yes
ADD=1
else
ADD=0
fi
done
}
if [ -f "$ETC/rfd.conf" ]; then
whiptail --yesno "Keep existing rfd.conf" 20 60 2
if [ $? -eq 0 ]; then # yes
NEWRFDCONF=0
else
NEWRFDCONF=1
fi
else
NEWRFDCONF=1
fi
if [[ "$NEWRFDCONF" -gt 0 ]]; then
cat > $ETC/rfd.conf <<- EOM
Listen Port = 2001
Log Destination = File
Log Filename = $VAR/log/rfd.log
Log Identifier = rfd
Log Level = 1
Persist Keys = 1
# PID File = $VAR/rfd/rfd.pid
# UDS File = $VAR/rfd/socket_rfd
Device Description Dir = $PREFIX/firmware/rftypes
Device Files Dir = $VAR/rfd/devices
Key File = $VAR/rfd/keys
Address File = $ETC/rfd/ids
Firmware Dir = $PREFIX/firmware
User Firmware Dir = $VAR/firmware
XmlRpcHandlersFile = $VAR/RFD.handlers
Replacemap File = $PREFIX/firmware/rftypes/replaceMap/rfReplaceMap.xml
EOM
rfdInterface
fi
whiptail --yesno "Install startscript /etc/init.d/rfd" 20 60 2
if [ $? -eq 0 ]; then # yes
cat > /etc/init.d/rfd <<- EOM
#! /bin/sh
### BEGIN INIT INFO
# Provides: rfd
# Required-Start: \$remote_fs \$syslog
# Required-Stop: \$remote_fs \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: HomeMatic rfd
# Description: HomeMatic BidCoS-RF interface process
### END INIT INFO
# Author: Sebastian 'hobbyquaker' Raff <[email protected]>
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/opt/hm/bin
DESC="HomeMatic BidCoS-RF interface process"
NAME=rfd
DAEMON=$PREFIX/bin/\$NAME
DAEMON_ARGS="-f $ETC/rfd.conf -d"
PIDFILE=$VAR/rfd/\$NAME.pid
SCRIPTNAME=/etc/init.d/\$NAME
USER=$USER
[ -x "\$DAEMON" ] || exit 0
. /lib/init/vars.sh
. /lib/lsb/init-functions
$SetupGPIO
case "\$1" in
start)
log_daemon_msg "Starting \$DESC" "\$NAME"
start-stop-daemon --start --quiet -c \$USER --exec \$DAEMON -- \$DAEMON_ARGS
;;
stop)
log_daemon_msg "Stopping \$DESC" "\$NAME"
start-stop-daemon -K -q -u \$USER -n \$NAME
;;
status)
status_of_proc "\$DAEMON" "\$NAME" && exit 0 || exit \$?
;;
*)
echo "Usage: \$SCRIPTNAME {start|stop|status}" >&2
exit 3
;;
esac
:
EOM
chmod a+x /etc/init.d/rfd
update-rc.d rfd defaults
else
ADD=0
fi
}
hs485d() {
mkdir -p $VAR/hs485d/devices >/dev/null 2>&1
mkdir -p $PREFIX/bin >/dev/null 2>&1
# Install binaries
mkdir -p $PREFIX/bin >/dev/null 2>&1
cp -R $SRC/HS485D/bin $PREFIX/
# Install libs
cp -Rn $SRC/HS485D/lib $PREFIX/
echo "$PREFIX/lib/" > /etc/ld.so.conf.d/hm.conf
ldconfig
if [ -f "$ETC/hs485d.conf" ]; then
whiptail --yesno "Keep existing hs485d.conf" 20 60 2
if [ $? -eq 0 ]; then # yes
NEWHS485DCONF=0
else
NEWHS485DCONF=1
fi
else
NEWHS485DCONF=1
fi
if [[ "$NEWHS485DCONF" -gt 0 ]]; then
SERIAL=$(whiptail --inputbox "\n\nEnter Serial Number" 20 60 "" --title "HMW LAN GW Serial" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
return;
fi
KEY=$(whiptail --inputbox "\n\nEnter Encryption Key" 20 60 "" --title "HMW LAN GW Serial" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
return;
fi
IP=$(whiptail --inputbox "\n\nEnter IP Address" 20 60 "" --title "HMW LAN GW Serial" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
return;
fi
cat > $ETC/hs485d.conf <<- EOM
Listen Port = 2000
Log Filename = $VAR/log/hs485d.log
Log Identifier = hs485d
Log Level = 1
# PID File = $VAR/hs485d/hs485d.pid
Device Description Dir = $PREFIX/firmware/hs485types
Device Files Dir = $VAR/hs485d/devices
Firmware Dir = $PREFIX/firmware
User Firmware Dir = $VAR/firmware
XmlRpcHandlersFile = $VAR/HS485D.handlers
[Interface 0]
Type = HMWLGW
Serial Number = $SERIAL
Encryption Key = $KEY
#IP Address = $IP
EOM
fi
whiptail --yesno "Install startscript /etc/init.d/hs485d" 20 60 2
if [ $? -eq 0 ]; then # yes
cat > /etc/init.d/hs485d <<- EOM
#! /bin/sh
### BEGIN INIT INFO
# Provides: hs485d
# Required-Start: \$remote_fs \$syslog
# Required-Stop: \$remote_fs \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: HomeMatic hs485d
# Description: HomeMatic BidCoS-RF interface process
### END INIT INFO
# Author: Sebastian 'hobbyquaker' Raff <[email protected]>
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/opt/hm/bin
DESC="HomeMatic BidCoS-RF interface process"
NAME=hs485d
DAEMON=$PREFIX/bin/\$NAME
DAEMON_ARGS="-f $ETC/hs485d.conf -g -i 0"
PIDFILE=$VAR/hs485d/\$NAME.pid
SCRIPTNAME=/etc/init.d/\$NAME
USER=$USER
[ -x "\$DAEMON" ] || exit 0
. /lib/init/vars.sh
. /lib/lsb/init-functions
case "\$1" in
start)
log_daemon_msg "Starting \$DESC" "\$NAME"
start-stop-daemon --start --quiet --background -c \$USER --exec \$DAEMON -- \$DAEMON_ARGS
;;
stop)
log_daemon_msg "Stopping \$DESC" "\$NAME"
start-stop-daemon -K -q -u \$USER -n \$NAME
;;
status)
status_of_proc "\$DAEMON" "\$NAME" && exit 0 || exit \$?
;;
*)
echo "Usage: \$SCRIPTNAME {start|stop|status}" >&2
exit 3
;;
esac
:
EOM
chmod a+x /etc/init.d/hs485d
update-rc.d hs485d defaults
else
ADD=0
fi
}
whiptail --yesno "Install rfd?" 20 60 2
if [ $? -eq 0 ]; then # yes
RF=1
rfd
else
RF=0
fi
whiptail --yesno "Install hs485d?" 20 60 2 --defaultno
if [ $? -eq 0 ]; then # yes
WIRED=1
hs485d
else
WIRED=0
fi
manager() {
command -v node >/dev/null 2>&1 || { echo >&2 "Error: Homematic Manager install failed. node required, but it's not installed."; return 0; }
command -v npm >/dev/null 2>&1 || { echo >&2 "Error: Homematic Manager install failed. npm required, but it's not installed."; return 0; }
cd $PREFIX
npm cache clean
npm install homematic-manager
ln -s $PREFIX/node_modules/.bin/hm-manager $PREFIX/bin/hm-manager >/dev/null 2>&1
INPUT=$(whiptail --inputbox "\n\nHomematic Manager Webserver Port" 20 60 "8081" --title "Homematic Manager Port" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
PORT=${INPUT:-8081}
nc -z localhost $PORT
if [ $? -eq 0 ]; then
echo "Warning Port $PORT seems to be already in use!"
fi
if [ $WIRED -eq 1 ]; then
cat > $PREFIX/etc/hm-manager.json <<- EOM
{
"webServerPort": $PORT,
"rpcListenIp": "127.0.0.1",
"rpcListenPort": "2015",
"rpcListenPortBin": "2016",
"daemons": {
"RF": {
"type": "BidCos-RF",
"ip": "127.0.0.1",
"port": 2001,
"protocol": "binrpc"
},
"Wired": {
"type": "BidCos-Wired",
"ip": "127.0.0.1",
"port": 2000,
"protocol": "binrpc"
}
},
"language": "de"
}
EOM
else
cat > $PREFIX/etc/hm-manager.json <<- EOM
{
"webServerPort": $PORT,
"rpcListenIp": "127.0.0.1",
"rpcListenPort": "2015",
"rpcListenPortBin": "2016",
"daemons": {
"RF": {
"type": "BidCos-RF",
"ip": "127.0.0.1",
"port": 2001,
"protocol": "binrpc"
}
},
"language": "de"
}
EOM
fi
chown $USER $PREFIX/etc/hm-manager.json
else
return;
fi
whiptail --yesno "Install startscript /etc/init.d/hm-manager?" 20 60 2
if [ $? -eq 0 ]; then # yes
cat > /etc/init.d/hm-manager <<- EOM
#! /bin/sh
### BEGIN INIT INFO
# Provides: hm-manager
# Required-Start: \$remote_fs \$syslog
# Required-Stop: \$remote_fs \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Homematic Manager
# Description: Homematic Webinterface
### END INIT INFO
# Author: Sebastian 'hobbyquaker' Raff <[email protected]>
PATH=/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin:/opt/hm/bin
DESC="Homematic Webinterface"
NAME=hm-manager
DAEMON=$PREFIX/bin/\$NAME
DAEMON_ARGS=""
PIDFILE=$VAR/hm-manager/\$NAME.pid
SCRIPTNAME=/etc/init.d/\$NAME
USER=$USER
[ -x "\$DAEMON" ] || exit 0
. /lib/init/vars.sh
. /lib/lsb/init-functions
sudo -u \$USER $PREFIX/node_modules/.bin/\$NAME \$1
:
EOM
chmod a+x /etc/init.d/hm-manager
update-rc.d hm-manager defaults
else
ADD=0
fi
}
whiptail --yesno "Install Homematic Manager?" 20 60 2
if [ $? -eq 0 ]; then # yes
manager
fi
# FIXME ugly. what if $PREFIX is / ?!?
chown -R $USER.$USER $PREFIX
chown -R $USER.$USER $VAR
chown -R $USER.$USER $ETC
read -d . DEBIAN_VERSION < /etc/debian_version
if (($DEBIAN_VERSION==8)); then # TODO
systemctl daemon-reload
fi
if [ -f "$ETC/rfd.conf" ] && [ $ASK_TO_REBOOT -eq 0 ]; then
whiptail --yesno "Start rfd now?" 20 60 2
if [ $? -eq 0 ]; then # yes
/etc/init.d/rfd start
fi
fi
if [ -f "$ETC/hs485d.conf" ] && [ $ASK_TO_REBOOT -eq 0 ]; then
whiptail --yesno "Start hs485d now?" 20 60 2
if [ $? -eq 0 ]; then # yes
/etc/init.d/hs485d start
fi
fi
if [ -f "$ETC/hm-manager.json" ] && [ $ASK_TO_REBOOT -eq 0 ]; then
whiptail --yesno "Start Homematic Manager now?" 20 60 2
if [ $? -eq 0 ]; then # yes
/etc/init.d/hm-manager start
HMMPORTHINT="Homematic Manager listening on http://`hostname`:$PORT/"
else
HMMPORTHINT=""
fi
fi
whiptail --msgbox "Setup done.\n-----------\n\nConfiguration files are located in $ETC\nLogfiles are located in $VAR/log\n$HMMPORTHINT\n\n\n\nHave Fun :-)" 20 60
if [ $ASK_TO_REBOOT -eq 1 ]; then
whiptail --yesno "Reboot required. Would you like to reboot now?" 20 60 2
if [ $? -eq 0 ]; then # yes
shutdown -r now
fi
fi