aboutsummaryrefslogtreecommitdiffstats
path: root/up2date.scptd/Contents
diff options
context:
space:
mode:
Diffstat (limited to 'up2date.scptd/Contents')
-rw-r--r--up2date.scptd/Contents/Info.plist21
-rw-r--r--up2date.scptd/Contents/Resources/Scripts/main.scptbin0 -> 1748 bytes
-rw-r--r--up2date.scptd/Contents/Resources/description.rtfd/TXT.rtf4
-rwxr-xr-xup2date.scptd/Contents/Resources/up2date.sh47
4 files changed, 72 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>WindowState</key>
+ <dict>
+ <key>dividerCollapsed</key>
+ <false/>
+ <key>eventLogLevel</key>
+ <integer>-1</integer>
+ <key>name</key>
+ <string>ScriptWindowState</string>
+ <key>positionOfDivider</key>
+ <real>346</real>
+ <key>savedFrame</key>
+ <string>77 104 824 602 0 0 1440 878 </string>
+ <key>selectedTabView</key>
+ <string>result</string>
+ </dict>
+</dict>
+</plist>
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
--- /dev/null
+++ b/up2date.scptd/Contents/Resources/Scripts/main.scpt
Binary files 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}" <<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">
+<plist version="1.0">
+ <dict>
+ <key>RunAtLoad</key>
+ <true/>
+ <key>Label</key>
+ <string>com.unflyingobject.mtk.up2date</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>${ME}</string>
+ </array>
+ </dict>
+</plist>
+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