ryangball / DockBuilder

A LaunchAgent and .app to build a user's Dock upon login and/or on demand.
45 stars 7 forks source link

Initialise the Dock on 1st run #3

Closed remusache closed 5 years ago

remusache commented 5 years ago

Hello! I am deploying the package via JAFM Pro and I would like, if possible, as soon as DockBuilder is installed and runs, the Dock is modified as well for the currently logged in user. Right now after JAMF installs the DockBuilder.pkg, nothing happens to the user's Dock. I have to remove the breadcrumb, restart the machine and only then the Dock is modified.

Thank you for your time and consideration.

Kind Regards Remus

ryangball commented 5 years ago

@remusache DockBuilder is designed to create a breadcrumb for existing user accounts where the dock has already been set up. However, I allowed for modifications to this with the SkipInitialBreadcrumbUsers key in the prefs plist. If you know the username of the individual you can add it there.

In the more likely event that you do not know the username you want to skip, I suggest the following:

  1. Add this line at line 7 in postinstall.sh: loggedInUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
  2. Change line 28 in postinstall.sh to: if [[ "$skipInitialBreadcrumbUsers" =~ $userName ]] || [[ "$loggedInUser" == "$userName" ]]; then
remusache commented 5 years ago

Thank you so much for getting back to me @ryangball. You were right in your assumption that I don't know the username, I mean I know it but it changes every time we install a new Mac.

I added/changed the suggested modifications in the postinstall.sh file but the Dock is still unchanged upon install completion.

Screenshot 2019-10-14 at 14 29 10

postinstall.sh.zip

ryangball commented 5 years ago

So is the breadcrumb getting created for the logged in user when the package installs?

ryangball commented 5 years ago

I see the issue, I made an error in the above code. The last variable should read “$userName”.

remusache commented 5 years ago

So instead of if [[ "$skipInitialBreadcrumbUsers" =~ $userName ]] || [[ "$loggedInUser" == "$userName" ]]; then it should be if [[ "$skipInitialBreadcrumbUsers" =~ "$userName" ]] || [[ "$loggedInUser" == "$userName" ]]; then

remusache commented 5 years ago

Beautiful :) Is not right after the installation finishes, but after restarting the machine, the Dock is changed. The breadcrumb is not created anymore during installation.

Thank you so much for taking the time to help me out.

ryangball commented 5 years ago

No problem, just to confirm, the line should be: if [[ "$skipInitialBreadcrumbUsers" =~ $userName ]] || [[ "$loggedInUser" == "$userName" ]]; then

remusache commented 5 years ago

Now I'm confused… :) If you say the line should be like the one bellow, then it's the same as the original line from your first post and then the breadcrumb is created.

if [[ "$skipInitialBreadcrumbUsers" =~ $userName ]] || [[ "$loggedInUser" == "$userName" ]]; then

When I changed the line like the one bellow if [[ "$skipInitialBreadcrumbUsers" =~ "$userName" ]] || [[ "$loggedInUser" == "$userName" ]]; then then no breadcrumb is created and the Dock is changing after restart..

ryangball commented 5 years ago

Sorry, I caused the confusion as I edited my original comment to correct the code after you mentioned it did not work.

remusache commented 5 years ago

Solved! Thank you Ryan!