diff --git a/VERSION b/VERSION
index 9f05f9f..ec70f75 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.6.5
+1.6.6
diff --git a/addon/backup/update_script b/addon/backup/update_script
index 062bd98..0336865 100755
--- a/addon/backup/update_script
+++ b/addon/backup/update_script
@@ -2,44 +2,23 @@
ADDON_DIR=/usr/local/etc/config/addons/email
-if [ "$1" = "" ]; then
- echo "CCU1"
- lcdtool "Installing Addon... "
- mount -t yaffs /dev/mtdblock3 /usr/local
-elif [ "$1" = "CCU2" ]; then
- echo "CCU2"
- mount -t ubifs ubi1:user /usr/local
-elif [ "$1" == "HM-RASPBERRYMATIC" ]; then
- echo "HM-RASPBERRYMATIC"
+# mount /usr/local if not already mounted
+mount | grep /usr/local 2>&1 >/dev/null
+if [ $? -eq 1 ]; then
mount /usr/local
fi
# Vorhandene Dateien löschen
-rm -r /usr/local/etc/config/addons/email/mails
-rm -r /usr/local/etc/config/addons/email/msmtp.conf
-rm -r /usr/local/etc/config/addons/email/account.conf
-rm -r /usr/local/etc/config/addons/email/userscript.tcl
+rm -rf /usr/local/etc/config/addons/email/mails
+rm -rf /usr/local/etc/config/addons/email/msmtp.conf
+rm -rf /usr/local/etc/config/addons/email/account.conf
+rm -rf /usr/local/etc/config/addons/email/userscript.tcl
# Dateien aus dem Backup kopieren
-cp -a userscript.tcl $ADDON_DIR
-cp -a account.conf $ADDON_DIR
-cp -a msmtp.conf $ADDON_DIR
-cp -a mails $ADDON_DIR/
+cp -af userscript.tcl ${ADDON_DIR}
+cp -af account.conf ${ADDON_DIR}
+cp -af msmtp.conf ${ADDON_DIR}
+cp -af mails ${ADDON_DIR}/
# sync filesystem to make sure all changes are written to disk
sync
-
-if [ "$1" = "" ]; then
- echo "CCU1"
- lcdtool "Reboot... "
- lcdtool -a 0x40 -t bin 00
- echo "x" > /dev/watchdog
- reboot
- while true ; do true ; done
-elif [ "$1" = "CCU2" ]; then
- echo "CCU2"
- # CCU2 always reboots after Addon/Firmware Update
-elif [ "$1" = "HM-RASPBERRYMATIC" ]; then
- echo "HM-RASPBERRYMATIC"
- # RASPBERRYMATIC always reboots after Addon/Firmware Update
-fi
diff --git a/addon/email b/addon/email
index 58c4450..05f4040 100755
--- a/addon/email
+++ b/addon/email
@@ -202,8 +202,8 @@ if {$mail(AttType) == "local"} {
set AttName [file tail $mailAttachment]
} elseif {$mail(AttType) == "down"} {
- exec wget --no-check-certificate -q -O /usr/local/etc/config/addons/email/tmp/$AttName $mailAttachment
- set fp [open "/usr/local/etc/config/addons/email/tmp/$AttName" r]
+ exec wget --no-check-certificate -q -O /tmp/$AttName $mailAttachment
+ set fp [open "/tmp/$AttName" r]
fconfigure $fp -translation binary
set imgdata [read $fp]
close $fp
@@ -213,17 +213,17 @@ if {$mail(AttType) == "local"} {
}
# WRITING READY MAIL FROM TMPL TO READY.EML
-set fp [open "/usr/local/etc/config/addons/email/tmp/ready.eml" w]
+set fp [open "/tmp/ready.eml" w]
puts $fp $tmpl
close $fp
# SEND READY.EML USING MSMTP
-exec cat /usr/local/etc/config/addons/email/tmp/ready.eml | /usr/local/etc/config/addons/email/msmtp -t -C /etc/config/addons/email/msmtp.conf
+exec cat /tmp/ready.eml | /usr/local/etc/config/addons/email/msmtp -t -C /etc/config/addons/email/msmtp.conf
# CLEAN UP
-exec rm -f /usr/local/etc/config/addons/email/tmp/ready.eml
+exec rm -f /tmp/ready.eml
if {$mail(AttType) == "local"} {
-exec rm -f /usr/local/etc/config/addons/email/tmp/$AttName
+exec rm -f /tmp/$AttName
} elseif {$mail(AttType) == "down"} {
-exec rm -f /usr/local/etc/config/addons/email/tmp/$AttName
-}
\ No newline at end of file
+exec rm -f /tmp/$AttName
+}
diff --git a/ccu1/hm_email-addon.cfg b/ccu1/hm_email-addon.cfg
new file mode 100644
index 0000000..bf20ac9
--- /dev/null
+++ b/ccu1/hm_email-addon.cfg
@@ -0,0 +1,8 @@
+{
+ CONFIG_URL /addons/email
+ CONFIG_DESCRIPTION {
+
Email-IntegrationAlarmierung und Weiterleitung von SystemzustaendenEinfache Benachrichtigungen
+ }
+ ID email
+ CONFIG_NAME "Email"
+}
diff --git a/ccu1/update_addon b/ccu1/update_addon
new file mode 100755
index 0000000..b302db0
Binary files /dev/null and b/ccu1/update_addon differ
diff --git a/ccu2/hm_email-addon.cfg b/ccu2/hm_email-addon.cfg
new file mode 100644
index 0000000..a1736fc
--- /dev/null
+++ b/ccu2/hm_email-addon.cfg
@@ -0,0 +1,9 @@
+{
+ CONFIG_URL /addons/email
+ CONFIG_DESCRIPTION {
+ de {Email-IntegrationAlarmierung und Weiterleitung von SystemzustaendenEinfache Benachrichtigungen...}
+ en {Email-IntegrationAlerting and routing of System-StatesSimple Notifications...}
+ }
+ ID email
+ CONFIG_NAME "Email"
+}
diff --git a/ccu2/update_addon b/ccu2/update_addon
new file mode 100755
index 0000000..fed1066
Binary files /dev/null and b/ccu2/update_addon differ
diff --git a/ccurm/hm_email-addon.cfg b/ccurm/hm_email-addon.cfg
new file mode 100644
index 0000000..a1736fc
--- /dev/null
+++ b/ccurm/hm_email-addon.cfg
@@ -0,0 +1,9 @@
+{
+ CONFIG_URL /addons/email
+ CONFIG_DESCRIPTION {
+ de {Email-IntegrationAlarmierung und Weiterleitung von SystemzustaendenEinfache Benachrichtigungen...}
+ en {Email-IntegrationAlerting and routing of System-StatesSimple Notifications...}
+ }
+ ID email
+ CONFIG_NAME "Email"
+}
diff --git a/ccupi/msmtp b/ccurm/msmtp
similarity index 100%
rename from ccupi/msmtp
rename to ccurm/msmtp
diff --git a/ccurm/update_addon b/ccurm/update_addon
new file mode 100755
index 0000000..d23cdad
Binary files /dev/null and b/ccurm/update_addon differ
diff --git a/email b/email
deleted file mode 100755
index 91361b9..0000000
--- a/email
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/sh
-#HMBUTTONCCU2="mh {CONFIG_URL /addons/mh/index.cgi CONFIG_DESCRIPTION {de {Sicherer VPN FernzugriffSMS VersandVersand von PUSH NachrichtenMail Versand per Skript} en {Secure VPN remote accessSend SMS MessagesSend push notificationsSend dynamic eMails}} ID mh CONFIG_NAME meine-homematic.de}"
-MAILBUTTONCCU2=" email {CONFIG_URL /addons/email/index.html CONFIG_DESCRIPTION {de {Email-IntegrationAlarmierung und Weiterleitung von SystemzustaendenEinfache Benachrichtigungen...} en {Email-IntegrationAlerting and routing of System-StatesSimple Notifications...}} ID email CONFIG_NAME Email}"
-
-#HMBUTTONCCU1="mh {CONFIG_URL /addons/mh/index.cgi CONFIG_DESCRIPTION {VPN-Zugang einrichtenSMS VersandMail Versand per Skript} ID mh CONFIG_NAME meine-homematic.de}"
-MAILBUTTONCCU1=" email {CONFIG_URL /addons/email/index.html CONFIG_DESCRIPTION {Email-IntegrationAlarmierung und Weiterleitung von SystemzustaendenEinfache Benachrichtigungen} ID email CONFIG_NAME Email}"
-
-MAILUNINSTCCU2=" email {CONFIG_URL /addons/email/index.html CONFIG_DESCRIPTION {de {Email-IntegrationAlarmierung und Weiterleitung von SystemzustaendenEinfache Benachrichtigungen...} en {Email-IntegrationAlerting and routing of System-StatesSimple Notifications...}} ID email CONFIG_NAME Email}"
-MAILUNINSTCCU1=" email {CONFIG_URL /addons/email/index.html CONFIG_DESCRIPTION {Email-IntegrationAlarmierung und Weiterleitung von SystemzustaendenEinfache Benachrichtigungen} ID email CONFIG_NAME Email}"
-MAILUNINST=""
-
-START_SCRIPT=/etc/config/rc.d/email
-WWW_DIR=/etc/config/addons/www/email
-ADDON_DIR=/etc/config/addons/email
-CONFIG_URL=/addons/email/index.html
-
-case "$1" in
-""|start)
- grep -i "CCU2" /etc/config/rfd.conf
- if [ $? -eq 0 ]; then
- echo "CCU2"
- mount -o rw,remount /
- START=`head /etc/config/hm_addons.cfg`
- STARTCCU2=$START$MAILBUTTONCCU2
- mv /usr/local/etc/config/hm_addons.cfg /usr/local/etc/config/hm_addons.cfg_org
- echo "$STARTCCU2" > /usr/local/etc/config/hm_addons.cfg_org > /usr/local/etc/config/hm_addons.cfg
-# sed -e "s|$START|$STARTCCU2|g" "/usr/local/etc/config/hm_addons.cfg_org" > "/usr/local/etc/config/hm_addons.cfg"
- rm -rf /usr/local/etc/config/hm_addons.cfg_org
- chmod 755 /usr/local/etc/config/hm_addons.cfg
- mount -o ro,remount /
- elif [ -e /boot/LXCCUVERSION ]; then
- echo "LXCCU"
- mount -o rw,remount /
- START=`head /etc/config/hm_addons.cfg`
- STARTCCU2=$START$MAILBUTTONCCU2
- mv /usr/local/etc/config/hm_addons.cfg /usr/local/etc/config/hm_addons.cfg_org
- echo "$STARTCCU2" > /usr/local/etc/config/hm_addons.cfg_org > /usr/local/etc/config/hm_addons.cfg
-# sed -e "s|$START|$STARTCCU2|g" "/usr/local/etc/config/hm_addons.cfg_org" > "/usr/local/etc/config/hm_addons.cfg"
- rm -rf /usr/local/etc/config/hm_addons.cfg_org
- chmod 755 /usr/local/etc/config/hm_addons.cfg
- mount -o ro,remount /
- else
- echo "CCU1"
- mount -o rw,remount /
- START=`head /etc/config/hm_addons.cfg`
- STARTCCU1=$START$MAILBUTTONCCU1
- mv /usr/local/etc/config/hm_addons.cfg /usr/local/etc/config/hm_addons.cfg_org
- echo "$STARTCCU1" > /usr/local/etc/config/hm_addons.cfg_org > /usr/local/etc/config/hm_addons.cfg
-# sed -e "s|$START|$STARTCCU1|g" "/usr/local/etc/config/hm_addons.cfg_org" > "/usr/local/etc/config/hm_addons.cfg"
- rm -rf /usr/local/etc/config/hm_addons.cfg_org
- chmod 755 /usr/local/etc/config/hm_addons.cfg
- ln -s /var/log /etc/config/addons/www/email/log
- mount -o ro,remount /
- fi
- # make sure we have the tmp folder
- mkdir -p /usr/local/etc/config/addons/email/tmp
- chmod 755 /usr/local/etc/config/addons/email/tmp
- ;;
- info)
- VER=`cat /usr/local/etc/config/addons/email/VERSION`
- echo "Info: E-Mail CCU Addon
"
- echo "Info: (c) 2010-2016 HMside, Jens Maus
"
- echo "Info: https://github.com/jens-maus/hm_email"
- echo "Version: $VER"
- echo "Name: E-Mail"
- echo "Operations: uninstall"
- echo "Config-Url: $CONFIG_URL"
- echo "Update: /addons/email/update-check.cgi"
- ;;
-restart)
- ;;
-stop)
- ;;
-uninstall)
- grep -i "CCU2" /etc/config/rfd.conf
- if [ $? -eq 0 ]; then
- echo "CCU2"
- mount -o rw,remount /
- mv /usr/local/etc/config/hm_addons.cfg /usr/local/etc/config/hm_addons.cfg_org
- sed -e "s|$MAILUNINSTCCU2|$MAILUNINST|g" "/usr/local/etc/config/hm_addons.cfg_org" > "/usr/local/etc/config/hm_addons.cfg"
- rm -rf /usr/local/etc/config/hm_addons.cfg_org
- chmod 755 /usr/local/etc/config/hm_addons.cfg
- rm /etc/config/rc.d/email
- rm -rf $WWW_DIR
- rm -rf $ADDON_DIR
- sync
- mount -o ro,remount /
- elif [ -e /boot/LXCCUVERSION ]; then
- echo "LXCCU"
- mv /usr/local/etc/config/hm_addons.cfg /usr/local/etc/config/hm_addons.cfg_org
- sed -e "s|$MAILUNINSTCCU2|$MAILUNINST|g" "/usr/local/etc/config/hm_addons.cfg_org" > "/usr/local/etc/config/hm_addons.cfg"
- rm -rf /usr/local/etc/config/hm_addons.cfg_org
- chmod 755 /usr/local/etc/config/hm_addons.cfg
- rm /etc/config/rc.d/email
- rm -rf $WWW_DIR
- rm -rf $ADDON_DIR
- sync
- mount -o ro,remount /
- else
- echo "CCU1"
- mount -o rw,remount /
- mv /usr/local/etc/config/hm_addons.cfg /usr/local/etc/config/hm_addons.cfg_org
- sed -e "s|$MAILUNINSTCCU1|$MAILUNINST|g" "/usr/local/etc/config/hm_addons.cfg_org" > "/usr/local/etc/config/hm_addons.cfg"
- rm -rf /usr/local/etc/config/hm_addons.cfg_org
- chmod 755 /usr/local/etc/config/hm_addons.cfg
- rm /etc/config/rc.d/email
- rm -rf $WWW_DIR
- rm -rf $ADDON_DIR
- sync
- mount -o ro,remount /
- fi
- rm -rf $WWW_DIR
- rm -rf $ADDON_DIR
- ;;
-esac
-
-exit 0
diff --git a/generate_img.sh b/generate_img.sh
index 8b2316d..164180b 100755
--- a/generate_img.sh
+++ b/generate_img.sh
@@ -4,8 +4,8 @@ cp -a account.conf tmp/
cp -a addon tmp/
cp -a ccu1 tmp/
cp -a ccu2 tmp/
-cp -a ccupi tmp/
-cp -a email tmp/
+cp -a ccurm tmp/
+cp -a rc.d tmp/
cp -a mails tmp/
cp -a msmtp.conf tmp/
cp -a update_script tmp/
@@ -13,6 +13,6 @@ cp -a userscript.tcl tmp/
cp -a www tmp/
cp -a VERSION tmp/addon/
cd tmp
-tar --owner=root --group=root -czvf ../email-$(cat ../VERSION).tar.gz *
+tar --owner=root --group=root --exclude=.DS_Store -czvf ../email-$(cat ../VERSION).tar.gz *
cd ..
rm -rf tmp
diff --git a/rc.d/email b/rc.d/email
new file mode 100755
index 0000000..5afc2e8
--- /dev/null
+++ b/rc.d/email
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+ADDONNAME=email
+ADDON_DIR=/usr/local/etc/config/addons/${ADDONNAME}
+WWW_DIR=/usr/local/etc/config/addons/www/${ADDONNAME}
+RCD_DIR=/usr/local/etc/config/rc.d
+
+case "$1" in
+
+ ""|start)
+ # make sure a /var/log/email.log exists
+ touch /var/log/email.log
+ ;;
+
+ info)
+ echo "Info: E-Mail CCU Addon
"
+ echo "Info: (c) 2010-2016 HMside, Jens Maus
"
+ echo "Info: https://github.com/jens-maus/hm_email"
+ echo "Version: $(cat ${ADDON_DIR}/VERSION)"
+ echo "Name: E-Mail"
+ echo "Operations: uninstall"
+ echo "Config-Url: /addons/${ADDONNAME}/"
+ echo "Update: /addons/${ADDONNAME}/update-check.cgi"
+ ;;
+
+ restart)
+ ;;
+
+ stop)
+ ;;
+
+ uninstall)
+ # remove the addon button
+ ${ADDON_DIR}/update_addon email
+
+ # remove the whole addon related stuff
+ rm -rf ${ADDON_DIR}
+ rm -rf ${WWW_DIR}
+ rm -f ${RCD_DIR}/${ADDONNAME}
+ ;;
+
+ *)
+ echo "Usage: ${ADDONNAME} {info|uninstall}" >&2
+ exit 1
+ ;;
+
+esac
+
+exit $?
diff --git a/update_script b/update_script
index c45f90b..ce2cd0b 100755
--- a/update_script
+++ b/update_script
@@ -4,92 +4,77 @@ 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
-if [ "$1" = "" ]; then
- echo "CCU1"
- lcdtool "Installing Addon... "
- mount -t yaffs /dev/mtdblock3 /usr/local
-elif [ "$1" = "CCU2" ]; then
- echo "CCU2"
- mount -t ubifs ubi1:user /usr/local
-elif [ "$1" == "HM-RASPBERRYMATIC" ]; then
- echo "HM-RASPBERRYMATIC"
+# 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 email $RC_DIR/
-chmod +x $RC_DIR/email
+cp -af rc.d/email ${RC_DIR}/
+chmod +x ${RC_DIR}/email
# Web-Konfiguration anlegen
-mkdir -p $WWW_DIR
-cp -R www/* $WWW_DIR
-chmod 755 $WWW_DIR
+mkdir -p ${WWW_DIR}
+cp -af www/* ${WWW_DIR}
+chmod 755 ${WWW_DIR}
# Addon-Verzeichnis anlegen
-mkdir -p $ADDON_DIR
-cp -R addon/* $ADDON_DIR
-chmod 755 $ADDON_DIR
+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 userscript.tcl $ADDON_DIR
+if [ ! -e ${ADDON_DIR}/userscript.tcl ]; then
+ cp -af userscript.tcl ${ADDON_DIR}
fi
-if [ ! -e $ADDON_DIR/account.conf ]; then
- cp account.conf $ADDON_DIR
+if [ ! -e ${ADDON_DIR}/account.conf ]; then
+ cp -af account.conf ${ADDON_DIR}
fi
-if [ ! -e $ADDON_DIR/msmtp.conf ]; then
- cp msmtp.conf $ADDON_DIR
+if [ ! -e ${ADDON_DIR}/msmtp.conf ]; then
+ cp -af msmtp.conf ${ADDON_DIR}
fi
-if [ ! -d $ADDON_DIR/mails ]; then
- cp -R mails $ADDON_DIR/
+if [ ! -d ${ADDON_DIR}/mails ]; then
+ cp -af mails ${ADDON_DIR}/
fi
-if [ ! -f $ADDON_DIR/mails/log.mail ]; then
- cp mails/log.mail $ADDON_DIR/mails/log.mail
+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 mails/cam.mail $ADDON_DIR/mails/cam.mail
+if [ ! -f ${ADDON_DIR}/mails/cam.mail ]; then
+ cp -af mails/cam.mail ${ADDON_DIR}/mails/cam.mail
fi
if [ "$1" = "" ]; then
- cp ccu1/msmtp $ADDON_DIR
+ cp -af ccu1/* ${ADDON_DIR}/
elif [ "$1" = "CCU2" ]; then
- cp ccu2/msmtp $ADDON_DIR
+ cp -af ccu2/* ${ADDON_DIR}/
elif [ "$1" == "HM-RASPBERRYMATIC" ]; then
- cp ccupi/msmtp $ADDON_DIR
+ cp -af ccurm/* ${ADDON_DIR}/
fi
# Alte nicht mehr benötigte Dateien löschen
-if [ -e $WWW_DIR/anleitung.html ]; then
- rm -r $WWW_DIR/anleitung.html
+if [ -e ${WWW_DIR}/anleitung.html ]; then
+ rm -r ${WWW_DIR}/anleitung.html
fi
-if [ -e $WWW_DIR/img/cuxmail.png ]; then
- rm -r $WWW_DIR/img/cuxmail.png
+if [ -e ${WWW_DIR}/img/cuxmail.png ]; then
+ rm -r ${WWW_DIR}/img/cuxmail.png
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
-ln -sf $ADDON_DIR/VERSION $WWW_DIR/VERSION.txt
-ln -sf $ADDON_DIR $WWW_DIR/addon
+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
-
-if [ "$1" = "" ]; then
- echo "CCU1"
- lcdtool "Reboot... "
- lcdtool -a 0x40 -t bin 00
- echo "x" > /dev/watchdog
- reboot
- while true ; do true ; done
-elif [ "$1" = "CCU2" ]; then
- echo "CCU2"
- # CCU2 always reboots after Addon/Firmware Update
-elif [ "$1" = "HM-RASPBERRYMATIC" ]; then
- echo "HM-RASPBERRYMATIC"
- # RASPBERRYMATIC always reboots after Addon/Firmware Update
-fi