From e0bb9180af98961a43c15048e11475bfe8d96186 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 29 Nov 2010 18:05:28 +0200 Subject: better netbless, updated readme --- up2date.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 up2date.sh (limited to 'up2date.sh') diff --git a/up2date.sh b/up2date.sh new file mode 100755 index 0000000..d64d7f6 --- /dev/null +++ b/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/sbin/softwareupdate -ia && /sbin/reboot + exit 0 +fi + +# no more updates available +/bin/launchctl unload -w "${PLIST}" && rm "${PLIST}" +/usr/bin/logger "$(basename $0) unloaded" +exit 0 -- cgit v1.2.3