-
Notifications
You must be signed in to change notification settings - Fork 23
/
install_raspberrymatic.sh
104 lines (77 loc) · 2.93 KB
/
install_raspberrymatic.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
mount -o remount,rw /
# check addon is there
if [ ! -d /usr/local/addons/hvl ]; then
mkdir -p /usr/local/addons/hvl
fi
cd /usr/local/addons/hvl
wget https://nodejs.org/dist/v6.10.0/node-v6.10.0-linux-armv7l.tar.xz -Onode.tar.xz --no-check-certificate
tar xf node.tar.xz
rm node.tar.xz
mv node-v6.10.0-linux-armv7l node
# link it
ln /usr/local/addons/hvl/node/bin/node /usr/bin/node -s
ln /usr/local/addons/hvl/node/bin/npm /usr/bin/npm -s
# Set some new Paths for NPM -> /root is RO
npm set cache=/usr/local/addons/hvl/.npm
npm set init-module=/usr/local/addons/hvl/.npm-init.js
npm set userconfig=/usr/local/addons/hvl/.npmrc
npm set path=/usr/local/addons/hvl/.npm
# Install Core System
npm install homematic-virtual-interface
# Add Button to System Prefrences
cat >> /tmp/inst_button <<EOF
#!/bin/tclsh
package require HomeMatic
set ID hvl
set URL /addons/hvl/index.html
set NAME "Homematic Virt. Interface"
array set DESCRIPTION {
de {<li>Stellt einen virtuellen Layer für die Nutzung div. Geräte (Hue, Sonos) direkt aus der CCU zur Verfügung</li>}
en {<li>provides a virtual layer to control other devices from CCU (eg Hue or Sonos).</li>}
}
::HomeMatic::Addon::AddConfigPage \$ID \$URL \$NAME [array get DESCRIPTION]
EOF
/bin/tclsh /tmp/inst_button
# clean the mess up
rm /tmp/inst_button
# Build JS Redirector
if [ ! -f /usr/local/etc/config/addons/www/hvl/index.html ]; then
mkdir /usr/local/etc/config/addons/www/hvl
cat > /usr/local/etc/config/addons/www/hvl/index.html <<EOF
<script type="text/javascript">
window.location.href='http://' + window.location.host +':8300/'
</script>
EOF
fi
# Add Interface
if [ $(cat /usr/local/etc/config/InterfacesList.xml | grep '<name>HVL</name>' | wc -l ) -eq 0 ]; then
sed -i /usr/local/etc/config/InterfacesList.xml -e "s/<\/interfaces>/<ipc><name>HVL<\/name><url>xmlrpc:\/\/127.0.0.1:8301<\/url><info>HVL<\/info><\/ipc><\/interfaces>/"
fi
# Add Interface Template
if [ $(cat /etc/config_templates/InterfacesList.xml | grep '<name>HVL</name>' | wc -l ) -eq 0 ]; then
sed -i /etc/config_templates/InterfacesList.xml -e "s/<\/interfaces>/<ipc><name>HVL<\/name><url>xmlrpc:\/\/127.0.0.1:8301<\/url><info>HVL<\/info><\/ipc><\/interfaces>/"
fi
#Setup config.json
if [ ! -f /usr/local/etc/config/hvl/config.json ]; then
if [ ! -d /usr/local/etc/config/hvl ]; then
mkdir /usr/local/etc/config/hvl
fi
touch /usr/local/etc/config/hvl/config.json
cat > /usr/local/etc/config/hvl/config.json <<EOF
{
"ccu_ip": "127.0.0.1",
"local_ip": "127.0.0.1",
"local_rpc_port": 8301,
"web_http_port":8300,
"restart_command":"/etc/init.d/S51hvl restart",
"plugins": []
}
EOF
fi
#build system launcher
if [ ! -f /usr/local/etc/config/rc.d/hvl ]; then
wget --no-check-certificate -nv -O /usr/local/etc/config/rc.d/hvl https://raw.githubusercontent.com/thkl/Homematic-Virtual-Interface/master/rc.d/hvl
chmod +x /usr/local/etc/config/rc.d/hvl
fi
#back to RO
mount -o remount,ro /