Skip to content

Commit

Permalink
we replace CRLF by LF when saving the notify script using our web-bas…
Browse files Browse the repository at this point in the history
…ed configuration. also fixed other issues related to notification and automatic reboot of the system.
  • Loading branch information
jens-maus committed Jun 24, 2016
1 parent f56b2f8 commit 6e17935
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2
0.3
8 changes: 7 additions & 1 deletion common/bin/hm-watchdog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ notify_user()
if [ -e ${ADDONDIR}/etc/notify.rega ]; then
# lets load the user configured rega script and replace "${notify_text}" with
# the supplied text in this function.
postbody=$(cat ${ADDONDIR}/etc/notify.rega | sed -e "s/<NOTIFY_TXT>/${notify_text}/")
postbody=$(grep -v "^!" ${ADDONDIR}/etc/notify.rega | sed -e "s/<NOTIFY_TXT>/${notify_text}/")
if [ -n "${postbody}" ]; then
wget -q -O - --post-data "${postbody}" "http://127.0.0.1:8181/tclrega.exe"
fi
Expand Down Expand Up @@ -54,7 +54,13 @@ restart_service()
notify_user "hm-watchdog: CCU restarted due to service ${name} down >${MAX_THRESHOLD} times."

/usr/bin/logger -t hm-watchdog -p err "${name} service down for >${MAX_THRESHOLD} iterations. Rebooting CCU" 2>&1 >/dev/null

# lets wait 5 seconds before we actually reboot to give the notification
# the time to send out all information
sleep 5
sync
/sbin/reboot

exit 1
fi

Expand Down
3 changes: 3 additions & 0 deletions common/etc/hm-watchdog.conf_default
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# the number of minutes hm-watchdog should
# be regularly executed via cron
HM_WATCHDOG_INTERVAL=3
5 changes: 5 additions & 0 deletions www/settings/inc/settings.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ proc saveConfigFile { } {

# output the whole content of WATCHDOG_NOTIFY to our notify.rega file
set fd [open $NOTIFY_REGA w]

# convert all \r\n (CRLF) to \n (LF) only
set HM_WATCHDOG_NOTIFY [string map -nocase { "\r\n" "\n" } $HM_WATCHDOG_NOTIFY]

# write out the notify script text and close the file
puts $fd $HM_WATCHDOG_NOTIFY
close $fd

Expand Down

0 comments on commit 6e17935

Please sign in to comment.