diff options
author | Filipp Lepalaan <filipp@mac.com> | 2011-05-16 12:44:09 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2011-05-16 12:44:09 +0300 |
commit | 8e73071f6a1790ded27184f7702f1b4d8b092847 (patch) | |
tree | c54f8ccd17cdacd407264257f60f94f68e806794 | |
parent | 35a2edf8b277206b04528a72ab89fe9dddcd3459 (diff) | |
download | mtk-8e73071f6a1790ded27184f7702f1b4d8b092847.tar.gz mtk-8e73071f6a1790ded27184f7702f1b4d8b092847.tar.bz2 mtk-8e73071f6a1790ded27184f7702f1b4d8b092847.zip |
up2date fixed
-rwxr-xr-x | cyclone.sh | 20 | ||||
-rw-r--r-- | up2date.app/Contents/Resources/Scripts/main.scpt | bin | 1748 -> 1716 bytes | |||
-rwxr-xr-x | up2date.app/Contents/Resources/up2date.sh | 32 |
3 files changed, 30 insertions, 22 deletions
@@ -1,7 +1,7 @@ #!/usr/bin/env bash -# clone all partitions of a drive -# and try not to waste space +# clone all partitions of a drive and try not to waste space # @author Filipp Lepalaan <filipp@mcare.fi> +# @package mtk if [[ $USER != "root" ]]; then echo "Insufficient privileges!" 2>&1 @@ -27,27 +27,27 @@ TMPFILE="/tmp/$(uuidgen)" trap "killall dd; rm ${TMPFILE}; echo 'Cleaning up...'; exit 255" SIGINT SIGTERM # Get size of source -diskutil info -plist $SOURCE > "${TMPFILE}".plist +/usr/sbin/diskutil info -plist $SOURCE > "${TMPFILE}".plist SOURCE_SIZE=`defaults read $TMPFILE TotalSize` # Get size of destination -diskutil info -plist $TARGET > $TMPFILE +/usr/sbin/diskutil info -plist $TARGET > $TMPFILE TARGET_SIZE=`defaults read $TMPFILE TotalSize` rm $TMPFILE if [[ $TARGET_SIZE == $SOURCE_SIZE ]]; then echo "Sizes are identical, cloning with dd..." - diskutil quiet unmountDisk $SOURCE - diskutil quiet unmountDisk $TARGET - dd bs=16m if="/dev/r${SOURCE}" of="/dev/r${TARGET}" conv=noerror,sync & + /usr/sbin/diskutil quiet unmountDisk $SOURCE + /usr/sbin/diskutil quiet unmountDisk $TARGET + /bin/dd bs=16m if="/dev/r${SOURCE}" of="/dev/r${TARGET}" conv=noerror,sync & DD_PID=$! # while dd is running... while [[ ps -ax | egrep -q -m 1 " ${DD_PID} " ]]; do sleep 1 - kill -SIGINFO $DD_PID + /bin/kill -SIGINFO $DD_PID done - diskutil quiet mountDisk $SOURCE - diskutil quiet mountDisk $TARGET + /usr/sbin/diskutil quiet mountDisk $SOURCE + /usr/sbin/diskutil quiet mountDisk $TARGET exit 0 fi diff --git a/up2date.app/Contents/Resources/Scripts/main.scpt b/up2date.app/Contents/Resources/Scripts/main.scpt Binary files differindex 5479faa..5bf062d 100644 --- a/up2date.app/Contents/Resources/Scripts/main.scpt +++ b/up2date.app/Contents/Resources/Scripts/main.scpt 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}" <<EOT <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> @@ -38,25 +42,29 @@ then </plist> 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 |