From ef9a65c018f8941e674866e07ce5c18c865de3b7 Mon Sep 17 00:00:00 2001 From: Stephen Boyle Date: Wed, 30 Mar 2022 16:56:44 -0400 Subject: [PATCH] User home fix --- CHANGELOG.md | 3 +++ CONTRIBUTORS.md | 1 + depNotify.sh | 11 ++++++----- depNotifyReset.sh | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc50d1..ffaa00b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [2.0.8] - 2022/03/30 +Account for users who do not have home directories under /Users + ## [2.0.5] - 2021/02/20 Address issue #39. You can define the amount of time to wait for the custom branding, if the icon does not appear in the specified time it defaults to the standard Self Service icon. To-do, add ability to define a custom icon path. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 20389c3..dd94c05 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -14,3 +14,4 @@ This page is for recognition to community members who have assisted in developme * @aaronpolley * @arekdreyer * @erinmc +* @sphen13 diff --git a/depNotify.sh b/depNotify.sh index 19c94e4..ea60c0d 100644 --- a/depNotify.sh +++ b/depNotify.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Version 2.0.7 +# Version 2.0.8 ######################################################################################### # License information @@ -104,7 +104,8 @@ # This wrapper allows variables that are created later to be used but also allow for # configuration of where the plist is stored INFO_PLIST_WRAPPER (){ - DEP_NOTIFY_USER_INPUT_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotifyUserInput.plist" + USER_HOME=$(/usr/bin/dscl . -read /Users/$CURRENT_USER NFSHomeDirectory | cut -d' ' -f2) + DEP_NOTIFY_USER_INPUT_PLIST="$USER_HOME/Library/Preferences/menu.nomad.DEPNotifyUserInput.plist" } # Status Text Alignment @@ -559,8 +560,8 @@ TRIGGER="event" # Loop waiting on the branding image to properly show in the users library SELF_SERVICE_COUNTER=0 - CUSTOM_BRANDING_PNG="/Users/$CURRENT_USER/Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage.png" - + CUSTOM_BRANDING_PNG="$USER_HOME/Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage.png" + until [ -f "$CUSTOM_BRANDING_PNG" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Waiting for branding image from Jamf Pro." >> "$DEP_NOTIFY_DEBUG" sleep 1 @@ -596,7 +597,7 @@ TRIGGER="event" INFO_PLIST_WRAPPER # The plist information below - DEP_NOTIFY_CONFIG_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotify.plist" + DEP_NOTIFY_CONFIG_PLIST="$USER_HOME/Library/Preferences/menu.nomad.DEPNotify.plist" # If testing mode is on, this will remove some old configuration files if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_CONFIG_PLIST" ]; then rm "$DEP_NOTIFY_CONFIG_PLIST"; fi diff --git a/depNotifyReset.sh b/depNotifyReset.sh index 92245ac..e997325 100644 --- a/depNotifyReset.sh +++ b/depNotifyReset.sh @@ -10,7 +10,8 @@ # Removing plists in local user folder CURRENT_USER=$(/usr/bin/stat -f "%Su" /dev/console) - rm /Users/"$CURRENT_USER"/Library/Preferences/menu.nomad.DEPNotify* + USER_HOME=$(dscl . -read /Users/$CURRENT_USER NFSHomeDirectory | cut -d' ' -f2) + rm "$USER_HOME"/Library/Preferences/menu.nomad.DEPNotify* # Restarting cfprefsd due to plist changes killall cfprefsd