From 34ec6a19c62892911c39d1d205de2ecb80c2adfc Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sun, 15 May 2011 11:48:48 +0300 Subject: added up2date --- up2date.scptd/Contents/Info.plist | 21 +++++++++ up2date.scptd/Contents/Resources/Scripts/main.scpt | Bin 0 -> 1748 bytes .../Contents/Resources/description.rtfd/TXT.rtf | 4 ++ up2date.scptd/Contents/Resources/up2date.sh | 47 +++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 up2date.scptd/Contents/Info.plist create mode 100644 up2date.scptd/Contents/Resources/Scripts/main.scpt create mode 100644 up2date.scptd/Contents/Resources/description.rtfd/TXT.rtf create mode 100755 up2date.scptd/Contents/Resources/up2date.sh (limited to 'up2date.scptd') diff --git a/up2date.scptd/Contents/Info.plist b/up2date.scptd/Contents/Info.plist new file mode 100644 index 0000000..c23a467 --- /dev/null +++ b/up2date.scptd/Contents/Info.plist @@ -0,0 +1,21 @@ + + + + + WindowState + + dividerCollapsed + + eventLogLevel + -1 + name + ScriptWindowState + positionOfDivider + 346 + savedFrame + 77 104 824 602 0 0 1440 878 + selectedTabView + result + + + diff --git a/up2date.scptd/Contents/Resources/Scripts/main.scpt b/up2date.scptd/Contents/Resources/Scripts/main.scpt new file mode 100644 index 0000000..5479faa Binary files /dev/null and b/up2date.scptd/Contents/Resources/Scripts/main.scpt differ diff --git a/up2date.scptd/Contents/Resources/description.rtfd/TXT.rtf b/up2date.scptd/Contents/Resources/description.rtfd/TXT.rtf new file mode 100644 index 0000000..33192ea --- /dev/null +++ b/up2date.scptd/Contents/Resources/description.rtfd/TXT.rtf @@ -0,0 +1,4 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 +{\fonttbl} +{\colortbl;\red255\green255\blue255;} +} \ No newline at end of file diff --git a/up2date.scptd/Contents/Resources/up2date.sh b/up2date.scptd/Contents/Resources/up2date.sh new file mode 100755 index 0000000..c917e81 --- /dev/null +++ b/up2date.scptd/Contents/Resources/up2date.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# up2date.sh +# Run software update until there are no more updates available. +# @author Filipp Lepalaan +# @package mtk + +if [[ $USER != "root" ]]; then + echo "$(basename $0) must be run as root" 2>&1 + exit 1 +fi + +ME=$0 +PLIST=/Library/LaunchDaemons/com.unflyingobject.mtk.up2date.plist + +# updates available... +if /usr/sbin/softwareupdate -l 2>&1 | grep -q 'found the following new' +then + if [[ ! -e "${PLIST}" ]]; then + cat > "${PLIST}" < + + + + RunAtLoad + + Label + com.unflyingobject.mtk.up2date + ProgramArguments + + ${ME} + + + +EOT + /bin/launchctl load -w "${PLIST}" + /usr/bin/logger "$(basename $0) loaded" + exit 0 + fi + /usr/bin/open /var/log/system.log + /usr/sbin/softwareupdate -ia && /sbin/reboot + exit 0 +fi + +# no more updates available +/bin/launchctl unload -w "${PLIST}" && rm "${PLIST}" +/usr/bin/logger "$(basename $0) finished, script unloaded. Have a nice day." +exit 0 -- cgit v1.2.3