GFX First logon script

PictureProducti
New Contributor III

Hi all,
I've got a problem that I hope should be easy to solve. I have a script that is set to trigger on first time login that configures the dock/wallpaper and various other things.

Problem is, the script triggers ok, but fails to execute commands. I suspect because JAMF seems to be running each command with sudo (which is not explicitly stated in the script itself). This does not happen when triggered manually in Self Service (or physically copy/pasting the code locally and executing in terminal).

I've been trying to look all over the 'Policies' section and cannot find anything which might be inserting the sudo command in the code and what user/pass it might be trying to use on the client to run the script.

These are the errors I'm getting:

sudo: defaults: command not found

But, when I trigger the script manually in Self Service, the script runs just fine.

When it runs automatically on login:

Script result: JAMF Helper launched with informational messaging.
Clearing the Dock of the standard Apple configuration...
sudo: defaults: command not found
Adding Safari...
Safari already exists in dock. Use --replacing 'Safari' to update an existing item
item /Applications/Safari.app was not added to Dock
Adding System Preferences...
System Preferences already exists in dock. Use --replacing 'System Preferences' to update an existing item
item /Applications/System Preferences.app was not added to Dock
Adding iTunes...
iTunes already exists in dock. Use --replacing 'iTunes' to update an existing item
item /Applications/iTunes.app was not added to Dock
Adding Notes...
Notes already exists in dock. Use --replacing 'Notes' to update an existing item
item /Applications/Notes.app was not added to Dock
sudo: defaults: command not found
Adding FileMaker Pro ...
sudo: defaults: command not found
Adding MAXON Cinema 4D ...
sudo: defaults: command not found

When triggered manually in self service:

[STEP 3 of 5]
Running script User Config - Dock & Desktop Picture...
Script exit code: 0
Script result: JAMF Helper launched with informational messaging.
Clearing the Dock of the standard Apple configuration...
Adding Safari...
Adding System Preferences...
Adding iTunes...
Adding Notes...
Adding FileMaker Pro ...
Adding MAXON Cinema 4D ...
Adding Adobe After Effects ...
Adding Adobe Photoshop ...
Adding Adobe InDesign ...
Adding Adobe Illustrator ...
Adding Adobe Media Encoder ...
Adding VLC...
Adding Self Service ...
Adding Deadlne Launcher ...
Adding Deadline Monitor ...
Adding Documents folder...
Adding Downloads folder...
Adding FileMaker database shortcut...
No matching processes were found
Make sure everything is in place before coming back...

Snippet of the code I use:

#!/bin/bash

user_short_name=$( /usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");' )
user_home_dir="/Users/$user_short_name"
os_version=$( sw_vers -productVersion | awk -F. '{print $2}' )

dockutil="/usr/local/bin/dockutil"
icon="/Library/PPC/Resources/ppcImage.jpg"
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
SR2=$( /usr/sbin/system_profiler SPDisplaysDataType | awk '/Resolution/{i++}i==2{print $2 $3 $4; exit}' )

.....


# Start populating the dock
echo "Adding Safari..."
$dockutil --add '/Applications/Safari.app' --no-restart "$user_home_dir"

# Firefox
while read fireFox; do
        "$dockutil" --add "${fireFox}" --no-restart "$user_home_dir"
        echo "Adding Firefox ..."
done < <( find /Applications -maxdepth 1 -iname 'Firefox.app' )

echo "Adding System Preferences..."
$dockutil --add '/Applications/System Preferences.app' --no-restart "$user_home_dir"

echo "Adding iTunes..."
$dockutil --add '/Applications/iTunes.app' --no-restart "$user_home_dir"

echo "Adding Notes..."
$dockutil --add '/Applications/Notes.app' --no-restart "$user_home_dir"

## If installed, add these apps to the Dock
# FileMaker Pro
while read fileMaker; do
        "$dockutil" --add "${fileMaker}" --no-restart "$user_home_dir"
        echo "Adding FileMaker Pro ..."
done < <( find /Applications -maxdepth 2 -iname 'FileMaker *.app' )

# Avid Media Composer
while read avidMediaComposer; do
        "$dockutil" --add "${avidMediaComposer}" --no-restart "$user_home_dir"
        echo "Adding Avid Media Composer ..."
done < <( find /Applications -maxdepth 2 -iname 'AvidMedia *.app' )

# MAXON Ciema 4D
while read maxonCinema4D; do
        "$dockutil" --add "${maxonCinema4D}" --no-restart "$user_home_dir"
        echo "Adding MAXON Cinema 4D ..."
done < <( find /Applications -maxdepth 3 -iname 'CINEMA 4D.app' )

etc...etc...

1 REPLY 1

PictureProducti
New Contributor III

Haven't solved the problem, but I did clock on a few things, found this

[https://www.jamf.com/jamf-nation/articles/146/script-parameters](link URL)

Which lead me to add echo $3
to the script so I could see what account the script is being run under, and it is the users network account.

So the sudo: defaults: command not found error lead me to try adding :
echo $PATH

result: /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.$

to the script so I could see if the location of sudo, and defaults commands are located and they are present in /usr/bin
when the script is being run automatically, so it doesn't make sense to me why the commands aren't found.