From 8e73071f6a1790ded27184f7702f1b4d8b092847 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 16 May 2011 12:44:09 +0300 Subject: up2date fixed --- up2date.app/Contents/Resources/Scripts/main.scpt | Bin 1748 -> 1716 bytes up2date.app/Contents/Resources/up2date.sh | 32 ++++++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'up2date.app/Contents/Resources') diff --git a/up2date.app/Contents/Resources/Scripts/main.scpt b/up2date.app/Contents/Resources/Scripts/main.scpt index 5479faa..5bf062d 100644 Binary files a/up2date.app/Contents/Resources/Scripts/main.scpt and b/up2date.app/Contents/Resources/Scripts/main.scpt differ diff --git a/up2date.app/Contents/Resources/up2date.sh b/up2date.app/Contents/Resources/up2date.sh index 122cd70..24d8b47 100755 --- a/up2date.app/Contents/Resources/up2date.sh +++ b/up2date.app/Contents/Resources/up2date.sh @@ -10,17 +10,21 @@ if [[ $(id -u) != 0 ]]; then fi ME=$0 -MAILTO="filipp@mcare.fi" +MAILTO="filipp@mcare.macpalvelin.com" LOGFILE=/Library/Logs/up2date.log PLIST=/Library/LaunchDaemons/com.unflyingobject.mtk.up2date.plist +echo "up2date launched..." >> "${LOGFILE}" + # disable automatic checking to avoid possible race condition /usr/sbin/softwareupdate --schedule off +echo "scheduling disabled, checking for updates..." >> "${LOGFILE}" # updates available... if /usr/sbin/softwareupdate -l 2>&1 | grep -q 'found the following new' then if [[ ! -e "${PLIST}" ]]; then + echo "installing launchd item..." >> "${LOGFILE}" cat > "${PLIST}" < @@ -38,25 +42,29 @@ then EOT /bin/launchctl load -w "${PLIST}" - echo "$(basename $0) loaded" > "${LOGFILE}" + echo "up2date loaded..." >> "${LOGFILE}" + sleep 10 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/sbin/softwareupdate -ia >> "${LOGFILE}" 2>&1 && /sbin/reboot +fi + echo "more updates available, installing..." >> "${LOGFILE}" + # this is the part that should be looped until there are no more updates + /usr/sbin/softwareupdate -ia >> "${LOGFILE}" 2>&1 + echo "updates installed, rebooting..." >> "${LOGFILE}" + /sbin/shutdown -r now exit 0 fi # no more updates available +echo "all updates installed, cleaning up..." >> "${LOGFILE}" /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}" + cat "${LOGFILE} | /usr/bin/mail -s up2date ${MAILTO}" fi +echo "up2date finished, script unloaded. Have a nice day." >> "${LOGFILE}" +/usr/bin/say "$(/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial Number/ {print $4}') up to date!" + +rm "${PLIST}" + exit 0 -- cgit v1.2.3