diff options
author | Filipp Lepalaan <filipp@mac.com> | 2011-05-15 13:13:04 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2011-05-15 13:13:04 +0300 |
commit | c98e968933b806630986895c72cd21c5d3d6de99 (patch) | |
tree | e5e1e7b74c789a81d784756c7db4dc065dfb8234 /up2date.app/Contents/Resources/up2date.sh | |
parent | 4eccc89ade476790ef1511a22707bb25127622f5 (diff) | |
download | mtk-c98e968933b806630986895c72cd21c5d3d6de99.tar.gz mtk-c98e968933b806630986895c72cd21c5d3d6de99.tar.bz2 mtk-c98e968933b806630986895c72cd21c5d3d6de99.zip |
testing
Diffstat (limited to 'up2date.app/Contents/Resources/up2date.sh')
-rwxr-xr-x | up2date.app/Contents/Resources/up2date.sh | 18 |
1 files changed, 14 insertions, 4 deletions
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 </plist> 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 |