forked from j-a-n/homematic-addon-hue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_script
executable file
·92 lines (76 loc) · 2.91 KB
/
update_script
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
#!/bin/sh
ADDON_NAME=hue
CONFIG_DIR=/usr/local/etc/config
ADDON_DIR=/usr/local/addons/${ADDON_NAME}
RCD_DIR=${CONFIG_DIR}/rc.d
LOG_FILE=/tmp/${ADDON_NAME}-install.log
exec 1<&-
exec 2<&-
exec 1<>$LOG_FILE
exec 2>&1
echo "starting installation of addon ${ADDON_NAME} at $(date)" >>$LOG_FILE
echo $@ >>$LOG_FILE
echo "mount /usr/local if not already mounted" >>$LOG_FILE
mount | grep /usr/local 2>&1 >/dev/null || mount /usr/local
echo "backup existing config file" >>$LOG_FILE
[ -e "/tmp/${ADDON_NAME}.conf" ] && rm "/tmp/${ADDON_NAME}.conf"
[ -e "${ADDON_DIR}/etc/${ADDON_NAME}.conf" ] && cp "${ADDON_DIR}/etc/${ADDON_NAME}.conf" "/tmp/${ADDON_NAME}.conf"
echo "create directories" >>$LOG_FILE
[ -e "${ADDON_DIR}" ] && rm -rf "${ADDON_DIR}"
mkdir -p "${ADDON_DIR}"
chmod 755 "${ADDON_DIR}"
[ -e "${RCD_DIR}" ] || (mkdir -p "${RCD_DIR}"; chmod 755 "${RCD_DIR}")
echo "install addon files" >>$LOG_FILE
[ -d addon ] && cp -af addon/* ${ADDON_DIR}/
[ -f "${ADDON_DIR}/hue.tcl" ] && chmod 755 "${ADDON_DIR}/hue.tcl"
[ -f "${ADDON_DIR}/hued.tcl" ] && chmod 755 "${ADDON_DIR}/hued.tcl"
[ -f VERSION ] && cp VERSION ${ADDON_DIR}/
echo "restore config file" >>$LOG_FILE
[ -e "/tmp/${ADDON_NAME}.conf" ] && mv "/tmp/${ADDON_NAME}.conf" "${ADDON_DIR}/etc/${ADDON_NAME}.conf"
echo "install ccu dependent files" >>$LOG_FILE
if [ "$1" = "" ]; then
[ -d "ccu1" ] && cp -af ccu1/* "${ADDON_DIR}/"
elif [ "$1" = "CCU2" ]; then
[ -d "ccu2" ] && cp -af ccu2/* "${ADDON_DIR}/"
elif [ "$1" = "CCU3" ]; then
[ -d "ccu3" ] && cp -af ccu3/* "${ADDON_DIR}/"
elif [ "$1" == "HM-RASPBERRYMATIC" ]; then
[ -d "ccu3" ] && cp -af ccu3/* "${ADDON_DIR}/"
fi
echo "link www files" >>$LOG_FILE
if [ -d "${ADDON_DIR}/www" -a ! -e "${CONFIG_DIR}/addons/www/${ADDON_NAME}" ]; then
ln -sf "${ADDON_DIR}/www" "${CONFIG_DIR}/addons/www/${ADDON_NAME}"
fi
echo "copy rc.d script" >>$LOG_FILE
if [ -e ${ADDON_NAME} ]; then
cp -af ${ADDON_NAME} "${RCD_DIR}/"
chmod 755 "${RCD_DIR}/${ADDON_NAME}"
fi
echo "add menu entry" >>$LOG_FILE
touch "${CONFIG_DIR}/hm_addons.cfg"
if [ -x /bin/updateAddonConfig.tcl ]; then
/bin/updateAddonConfig.tcl -a hue -url /addons/hue/index.html -name "Philips Hue" -de "Philips Hue Steuerung" -en "Philips Hue control"
else
"/usr/local/addons/cuxd/update_addon" ${ADDON_NAME} "${ADDON_DIR}/etc/${ADDON_NAME}-addon.cfg"
fi
sync
if [ -e /usr/local/etc/config/rc.d/cuxdaemon -a -e /usr/local/addons/cuxd/cuxd.ini ]; then
echo "cuxd config" >>$LOG_FILE
/usr/local/etc/config/rc.d/cuxdaemon stop
grep -v "LEVEL-FILTER" /usr/local/addons/cuxd/cuxd.ini > /usr/local/addons/cuxd/cuxd.ini.tmphue
echo "LEVEL-FILTER=0" >> /usr/local/addons/cuxd/cuxd.ini.tmphue
mv /usr/local/addons/cuxd/cuxd.ini.tmphue /usr/local/addons/cuxd/cuxd.ini
/usr/local/etc/config/rc.d/cuxdaemon start
fi
if [ "$1" = "" ]; then
echo "running on CCU1, rebooting"
echo "x" > /dev/watchdog
reboot
while true; do
sleep 1
done
else
echo "(re)starting hued"
/usr/local/addons/hue/hued.tcl
fi
exit 0