Skip to content

Commit

Permalink
Merge pull request #16 from homebysix/better-deferral-initialization
Browse files Browse the repository at this point in the history
added cleanup on fresh installs and exit_without_updating
  • Loading branch information
mpanighetti authored May 14, 2019
2 parents d9b594c + 8f4ad35 commit 39c2f23
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build-info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>suppress_bundle_relocation</key>
<true/>
<key>version</key>
<string>2.1.3</string>
<string>2.1.4</string>
</dict>
</plist>
13 changes: 9 additions & 4 deletions payload/Library/Scripts/install_or_defer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
###

Expand Down Expand Up @@ -261,8 +261,13 @@ exit_without_updating () {
echo "Running jamf recon..."
"$jamf" recon

"/bin/echo" "Unloading $BUNDLE_ID LaunchDaemon. Script will end here."
"/bin/launchctl" unload -w "/private/tmp/$BUNDLE_ID.plist"
clean_up

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

}
Expand Down
14 changes: 12 additions & 2 deletions scripts/preinstall
Original file line number Diff line number Diff line change
@@ -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>"/dev/null"

# Clean up plist values.
echo "Cleaning up all stored plist values..."
defaults delete "$PLIST" 2>"/dev/null"

# Unload LaunchDaemons.
if [[ -f "$HELPER_LD" ]]; then
echo "Unloading and removing $HELPER_LD..."
launchctl unload -w "$HELPER_LD"
Expand Down

0 comments on commit 39c2f23

Please sign in to comment.