-
Notifications
You must be signed in to change notification settings - Fork 6
/
update_script
executable file
·107 lines (85 loc) · 2.55 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
RC_DIR=/usr/local/etc/config/rc.d
WWW_DIR=/usr/local/etc/config/addons/www/email
ADDON_DIR=/usr/local/etc/config/addons/email
# check for unsupported platforms
if grep -qim1 busmatic /www/api/methods/ccu/downloadFirmware.tcl; then
exit 13
fi
# mount /usr/local if not already mounted
mount | grep /usr/local 2>&1 >/dev/null
if [ $? -eq 1 ]; then
mount /usr/local
fi
# Startscript anlegen
cp -af rc.d/email ${RC_DIR}/
chmod +x ${RC_DIR}/email
# Web-Konfiguration anlegen
mkdir -p ${WWW_DIR}
cp -af www/* ${WWW_DIR}
chmod 755 ${WWW_DIR}
# Addon-Verzeichnis anlegen
mkdir -p ${ADDON_DIR}
cp -af addon/* ${ADDON_DIR}
chmod 755 ${ADDON_DIR}
# Konfigdateien und Vorlagen kopieren sofern nicht vorhanden
if [ ! -e ${ADDON_DIR}/userscript.tcl ]; then
cp -af userscript.tcl ${ADDON_DIR}
fi
if [ ! -e ${ADDON_DIR}/account.conf ]; then
cp -af account.conf ${ADDON_DIR}
fi
if [ ! -e ${ADDON_DIR}/msmtp.conf ]; then
cp -af msmtp.conf ${ADDON_DIR}
fi
if [ ! -d ${ADDON_DIR}/mails ]; then
cp -af mails ${ADDON_DIR}/
fi
if [ ! -f ${ADDON_DIR}/mails/log.mail ]; then
cp -af mails/log.mail ${ADDON_DIR}/mails/log.mail
fi
if [ ! -f ${ADDON_DIR}/mails/cam.mail ]; then
cp -af mails/cam.mail ${ADDON_DIR}/mails/cam.mail
fi
# Alte Dateien löschen da diese vom kommenden Copy
# Kommando ersetzt werden (auch durch Links)
rm -f ${ADDON_DIR}/msmtp
# Nun alle Addon datein platformspezifisch kopieren
if [ "$1" = "" ]; then
cp -af ccu1/* ${ADDON_DIR}/
elif [ "$1" = "CCU2" ]; then
cp -af ccu2/* ${ADDON_DIR}/
elif [ "$1" == "HM-RASPBERRYMATIC" ]; then
if [ "$(uname -m)" == "i686" ] || [ "$(uname -m)" == "x86_64" ]; then
cp -af ccu3x86/* ${ADDON_DIR}/
else
cp -af ccu3/* ${ADDON_DIR}/
fi
fi
# Alte nicht mehr benötigte Dateien löschen
if [ -e ${WWW_DIR}/anleitung.html ]; then
rm -f ${WWW_DIR}/anleitung.html
fi
if [ -e ${WWW_DIR}/img/cuxmail.png ]; then
rm -f ${WWW_DIR}/img/cuxmail.png
fi
if [ -e ${WWW_DIR}/anleitung.pdf ]; then
rm -f ${WWW_DIR}/anleitung.pdf
fi
# Fix for issue with incorrect prio parameter in templates, replace brackets
if [ -d ${ADDON_DIR}/mails ]; then
sed -i 's/Prio {}/Prio false/g' ${ADDON_DIR}/mails/*.mail
fi
# add menu entry
touch /usr/local/etc/config/hm_addons.cfg
${ADDON_DIR}/update_addon email ${ADDON_DIR}/hm_email-addon.cfg
# Symbolic Links
rm -f ${WWW_DIR}/VERSION.txt
ln -sf ${ADDON_DIR}/VERSION ${WWW_DIR}/VERSION.txt
rm -f ${WWW_DIR}/addon
ln -sf ${ADDON_DIR} ${WWW_DIR}/addon
# sync filesystem to make sure all changes are written to disk
sync
# exit with 0 to signal install succeeded and no reboot
# is required
exit 0