I apologize if these questions seem simple but I am still pretty new to scripting and to using JAMF.
My organization needs to whitelist several domains in Google to allow for Single Sign On. Running the script below while logged in as the user will add the sites:
defaults write com.google.Chrome AuthServerWhitelist ".example.com"
defaults write com.google.Chrome AuthNegotiateDelegateWhitelist ".example.com"
Obviously, *.example.com gets replaced with the sites we need added.
Below is the script we have tried using through JAMF:
loggedInUser=$(stat -f%Su /dev/console)
sudo -u $loggedInUser /usr/bin/defaults write /Users/$loggedInUser/Library/Prefences/com.google.Chrome AuthServerWhitelist ".example.com"
sudo -u $loggedInUser /usr/bin/defaults write /Users/$loggedInUser/Library/Prefences/com.google.Chrome AuthNegotiateDelegateWhitelist ".example.com"
The settings are not being written to the file after the script runs. I have done some research about running the script as the user and have had no luck finding a solution.
Any suggestions are greatly appreciated.
No need to run your script as the logged in user. Just run it with a login trigger, use $3 for the current user and then chown the file when you're done.
#!/bin/bash defaults write /Users/$3/Library/Preferences/com.google.Chrome.plist AuthServerWhitelist "*.example.com" chown $3 /Users/$3/Library/Preferences/com.google.Chrome.plist