Skip to content

Commit

Permalink
simplified the rc.d and update_script scripts by adding the 'update_a…
Browse files Browse the repository at this point in the history
…ddon' tool for adding the Addon Button to the right place. We also use the /tmp directory rather than having to maintain an own tmp directory within our addon directory which might cause SD card corruption upon crashes.
  • Loading branch information
jens-maus committed Jun 9, 2016
1 parent 80e453a commit c060798
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 214 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.5
1.6.6
43 changes: 11 additions & 32 deletions addon/backup/update_script
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions addon/email
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
exec rm -f /tmp/$AttName
}
8 changes: 8 additions & 0 deletions ccu1/hm_email-addon.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
CONFIG_URL /addons/email
CONFIG_DESCRIPTION {
<li>Email-Integration</li><li>Alarmierung und Weiterleitung von Systemzustaenden</li><li>Einfache Benachrichtigungen</li>
}
ID email
CONFIG_NAME "Email"
}
Binary file added ccu1/update_addon
Binary file not shown.
9 changes: 9 additions & 0 deletions ccu2/hm_email-addon.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
CONFIG_URL /addons/email
CONFIG_DESCRIPTION {
de {<li>Email-Integration</li><li>Alarmierung und Weiterleitung von Systemzustaenden</li><li>Einfache Benachrichtigungen</li><li>...</li>}
en {<li>Email-Integration</li><li>Alerting and routing of System-States</li><li>Simple Notifications</li><li>...</li>}
}
ID email
CONFIG_NAME "Email"
}
Binary file added ccu2/update_addon
Binary file not shown.
9 changes: 9 additions & 0 deletions ccurm/hm_email-addon.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
CONFIG_URL /addons/email
CONFIG_DESCRIPTION {
de {<li>Email-Integration</li><li>Alarmierung und Weiterleitung von Systemzustaenden</li><li>Einfache Benachrichtigungen</li><li>...</li>}
en {<li>Email-Integration</li><li>Alerting and routing of System-States</li><li>Simple Notifications</li><li>...</li>}
}
ID email
CONFIG_NAME "Email"
}
File renamed without changes.
Binary file added ccurm/update_addon
Binary file not shown.
117 changes: 0 additions & 117 deletions email

This file was deleted.

6 changes: 3 additions & 3 deletions generate_img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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/
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
49 changes: 49 additions & 0 deletions rc.d/email
Original file line number Diff line number Diff line change
@@ -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: <b>E-Mail CCU Addon</b><br>"
echo "Info: (c) 2010-2016 HMside, Jens Maus<br>"
echo "Info: <a href='https://github.com/jens-maus/hm_email'>https://github.com/jens-maus/hm_email</a>"
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 $?
Loading

0 comments on commit c060798

Please sign in to comment.