From 92bf1739de21d5481b7c586c2e044fcfcb9cc0bf Mon Sep 17 00:00:00 2001 From: Mario Panighetti Date: Tue, 14 May 2019 12:18:54 -0700 Subject: [PATCH 1/3] added cleanup on fresh installs and exit_without_updating - added cleanup tasks to preinstall script and exit_without_updating (ensures AppleSoftwareUpdatesForcedAfter attribute doesn't persist between script reinstalls) - iterated version to 2.1.4 --- build-info.plist | 2 +- payload/Library/Scripts/install_or_defer.sh | 6 ++++-- scripts/preinstall | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/build-info.plist b/build-info.plist index 7cd5125..e67fcbf 100644 --- a/build-info.plist +++ b/build-info.plist @@ -17,6 +17,6 @@ suppress_bundle_relocation version - 2.1.3 + 2.1.4 diff --git a/payload/Library/Scripts/install_or_defer.sh b/payload/Library/Scripts/install_or_defer.sh index 087f0b1..83f046e 100644 --- a/payload/Library/Scripts/install_or_defer.sh +++ b/payload/Library/Scripts/install_or_defer.sh @@ -13,8 +13,8 @@ # restarts automatically. # Authors: Elliot Jordan and Mario Panighetti # Created: 2017-03-09 -# Last Modified: 2019-04-11 -# Version: 2.1.3 +# Last Modified: 2019-05-14 +# Version: 2.1.4 # ### @@ -261,6 +261,8 @@ exit_without_updating () { echo "Running jamf recon..." "$jamf" recon + clean_up + "/bin/echo" "Unloading $BUNDLE_ID LaunchDaemon. Script will end here." "/bin/launchctl" unload -w "/private/tmp/$BUNDLE_ID.plist" exit 0 diff --git a/scripts/preinstall b/scripts/preinstall index 835a278..baf8a53 100755 --- a/scripts/preinstall +++ b/scripts/preinstall @@ -1,11 +1,21 @@ #!/bin/bash +PLIST="$3/Library/Preferences/com.elliotjordan.install_or_defer" +HELPER_LD="$3/private/tmp/com.elliotjordan.install_or_defer_helper.plist" +MAIN_LD="$3/Library/LaunchDaemons/com.elliotjordan.install_or_defer.plist" + # Copy all output to the system log for diagnostic purposes. exec 1> >(logger -s -t "$(basename "$0")") 2>&1 -HELPER_LD="$3/private/tmp/com.elliotjordan.install_or_defer_helper.plist" -MAIN_LD="$3/Library/LaunchDaemons/com.elliotjordan.install_or_defer.plist" +# Kill jamfHelper process to close all current notifications. +echo "Killing any active jamfHelper notifications..." +killall jamfHelper 2>"$3/dev/null" + +# Clean up plist values. +echo "Cleaning up all stored plist values..." +defaults delete "$PLIST" +# Unload LaunchDaemons. if [[ -f "$HELPER_LD" ]]; then echo "Unloading and removing $HELPER_LD..." launchctl unload -w "$HELPER_LD" From 11b784c2979cfd536cde1864082180b1ec639dc2 Mon Sep 17 00:00:00 2001 From: Mario Panighetti Date: Tue, 14 May 2019 12:24:57 -0700 Subject: [PATCH 2/3] redirected defaults delete error output to /dev/null --- scripts/preinstall | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/preinstall b/scripts/preinstall index baf8a53..cbc0e54 100755 --- a/scripts/preinstall +++ b/scripts/preinstall @@ -9,11 +9,11 @@ exec 1> >(logger -s -t "$(basename "$0")") 2>&1 # Kill jamfHelper process to close all current notifications. echo "Killing any active jamfHelper notifications..." -killall jamfHelper 2>"$3/dev/null" +killall jamfHelper 2>"/dev/null" # Clean up plist values. echo "Cleaning up all stored plist values..." -defaults delete "$PLIST" +defaults delete "$PLIST" 2>"/dev/null" # Unload LaunchDaemons. if [[ -f "$HELPER_LD" ]]; then From 8f4ad3566dfccb32dd774b5d64040c7a833b43e9 Mon Sep 17 00:00:00 2001 From: Mario Panighetti Date: Tue, 14 May 2019 12:32:28 -0700 Subject: [PATCH 3/3] made LaunchDaemon unload conditional on file existing --- payload/Library/Scripts/install_or_defer.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/payload/Library/Scripts/install_or_defer.sh b/payload/Library/Scripts/install_or_defer.sh index 83f046e..7d0ed8b 100644 --- a/payload/Library/Scripts/install_or_defer.sh +++ b/payload/Library/Scripts/install_or_defer.sh @@ -263,8 +263,11 @@ exit_without_updating () { clean_up - "/bin/echo" "Unloading $BUNDLE_ID LaunchDaemon. Script will end here." - "/bin/launchctl" unload -w "/private/tmp/$BUNDLE_ID.plist" + if [[ -e "/private/tmp/$BUNDLE_ID.plist" ]]; then + "/bin/echo" "Unloading $BUNDLE_ID LaunchDaemon..." + "/bin/launchctl" unload -w "/private/tmp/$BUNDLE_ID.plist" + fi + "/bin/echo" "Script will end here." exit 0 }