From c98e968933b806630986895c72cd21c5d3d6de99 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sun, 15 May 2011 13:13:04 +0300 Subject: testing --- up2date.app/Contents/Info.plist | 2 +- up2date.app/Contents/Resources/up2date.sh | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/up2date.app/Contents/Info.plist b/up2date.app/Contents/Info.plist index 5c8b161..533cf06 100644 --- a/up2date.app/Contents/Info.plist +++ b/up2date.app/Contents/Info.plist @@ -38,7 +38,7 @@ savedFrame 77 104 824 602 0 0 1440 878 selectedTabView - result + event log diff --git a/up2date.app/Contents/Resources/up2date.sh b/up2date.app/Contents/Resources/up2date.sh index b9e4841..fdad055 100755 --- a/up2date.app/Contents/Resources/up2date.sh +++ b/up2date.app/Contents/Resources/up2date.sh @@ -10,8 +10,12 @@ if [[ $(id -u) != 0 ]]; then fi ME=$0 -LOGFILE=/var/log/up2date.log -PLIST=/Library/LaunchAgents/com.unflyingobject.mtk.up2date.plist +MAILTO="filipp@mcare.fi" +LOGFILE=/Library/Logs/up2date.log +PLIST=/Library/LaunchDaemons/com.unflyingobject.mtk.up2date.plist + +# disable automatic checking to avoid possible race condition +/usr/sbin/softwareupdate --schedule off # updates available... if /usr/sbin/softwareupdate -l 2>&1 | grep -q 'found the following new' @@ -34,19 +38,25 @@ then EOT /bin/launchctl load -w "${PLIST}" - /usr/bin/logger "$(basename $0) loaded" + echo "$(basename $0) loaded" > "${LOGFILE}" exit 0 fi # wait for the GUI to come up... # while [[ ! (/bin/ps aux | /usr/bin/grep loginwindow | /usr/bin/grep -qv grep) ]]; do # sleep 5 # done - /usr/bin/open "${LOGFILE}" +# /usr/bin/open "${LOGFILE}" /usr/sbin/softwareupdate -ia > "${LOGFILE}" 2>&1 && /sbin/reboot exit 0 fi # no more updates available +/usr/sbin/softwareupdate --schedule on /bin/launchctl unload -w "${PLIST}" && rm "${PLIST}" /usr/bin/logger "$(basename $0) finished, script unloaded. Have a nice day." + +if [[ ! -z "${MAILTO}" ]]; then + cat "${LOGFILE} | mail -s up2date ${MAILTO}" +fi + exit 0 -- cgit v1.2.3