Posted on 12-18-2017 09:26 AM
I've noticed after installing Citrix Receiver the default setting is to have it automatically check for updates, and the popups to update are really persistent. I'm trying to build a script to change this setting, and I'm close but I'm running into some issues.
The script I have is:
#!/bin/sh
#kill Citrix Receiver if running
pkill Citrix Receiver
#get loggedinuser
loggedInUser="$(/bin/ls -la /dev/console | /usr/bin/cut -d " " -f 4)"
#make sure labuser logged in
if [[ $loggedInUser != "labuser" ]]
then
echo "labuser not logged in, please re-run later"
exit 1
else
echo "labuser logged in"
fi
#confirm plist exists where this setting can be entered
if [ ! -f /Users/"$loggedInUser"/Library/Preferences/com.citrix.receiver.nomas.plist ]
then
echo "Plist not found, Citrix not installed or in error."
exit 1
else
echo "Plist exists, continuing..."
fi
plistContents="$(defaults read com.citrix.receiver.nomas)"
autoUpdateSetting="$(defaults read com.citrix.receiver.nomas AutoUpdateState)"
if [[ "$plistContents" == *"AutoUpdateState"* ]] #autoupdatesetting exists
then
if [[ $autoUpdateSetting != "Disabled" ]] #autoupdatesetting is not set to Disabled
then
defaults write com.citrix.receiver.nomas AutoUpdateState -string Disabled
echo "${autoUpdateSetting} set"
else
echo "${autoUpdateSetting} already set"
fi
else
defaults write com.citrix.receiver.nomas AutoUpdateState -string Disabled
echo "${autoUpdateSetting} set"
fi
exit 0
If I just run this script on a computer it works fine, but I'm running into issues doing it through JAMF. I'm able to get through the part where it confirms the PLIST exists, but then when it tries to define the plistContents variable it says "Domain com.citrix.receiver.nomas does not exist." Which is frustrating since I confirmed that it existed before running that command (and it definitely does exist).
I also tried specifying the full path of the PLIST (so defaults write /Users/"$loggedInUser"/Library/Preferences/com.citrix.receiver.nomas) for the "defaults read" and "defaults write" commands and it seemed to work, though when I run "defaults read com.citrix.receiver.nomas" in terminal (which used to come up with the contents of that file) it now just gives the "Domain com.citrix.receiver.nomas does not exist" error message. And when I open Citrix, it's still set to automatically check for updates.
Any ideas about what I might be doing wrong?
Thanks
Posted on 12-18-2017 10:47 AM
I just noticed that if I try to open the PLIST through Finder (on a computer that I had JAMF push the policy/script to) it says I don't have permission to view the file. Though if I go to another computer (that didn't get the policy/script) it opens fine. Maybe I need to run the defaults commands as the user?
Posted on 12-18-2017 11:30 AM
Yep, that seemed to be it. https://www.jamf.com/jamf-nation/discussions/18627/running-a-script-as-a-login-user helped out, the script I have (which seems to be working now) is:
#!/bin/bash -v
#kill Citrix Receiver if running
pkill Citrix Receiver
#get loggedinuser
loggedInUser="$(/bin/ls -la /dev/console | /usr/bin/cut -d " " -f 4)"
#make sure labuser logged in
if [[ $loggedInUser != "labuser" ]]
then
echo "labuser not logged in, please re-run later"
exit 1
else
echo "labuser logged in"
fi
#confirm plist exists
if [ ! -f /Users/"$loggedInUser"/Library/Preferences/com.citrix.receiver.nomas.plist ]
then
echo "Plist not found, Citrix not installed or in error."
exit 1
else
echo "Plist exists, continuing..."
fi
plistContents="$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.citrix.receiver.nomas)"
autoUpdateSetting="$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.citrix.receiver.nomas AutoUpdateState)"
if [[ "$plistContents" == *"AutoUpdateState"* ]] #autoupdatesetting exists
then
if [[ $autoUpdateSetting != "Disabled" ]] #autoupdatesetting is not set to Disabled
then
su -l $loggedInUser -c "defaults write com.citrix.receiver.nomas AutoUpdateState -string Disabled"
autoUpdateSetting="$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.citrix.receiver.nomas AutoUpdateState)"
echo "${autoUpdateSetting} set"
else
echo "${autoUpdateSetting} already set"
fi
else
su -l $loggedInUser -c "defaults write com.citrix.receiver.nomas AutoUpdateState -string Disabled"
autoUpdateSetting="$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.citrix.receiver.nomas AutoUpdateState)"
echo "${autoUpdateSetting} set"
fi
exit 0
Posted on 10-02-2018 01:15 PM
We were able to push out the PLIST via Configuration Profiles.