Posted on 06-06-2019 12:47 PM
I'm trying to script a direct download of Citrix Workspace so I don't have to manual update the pkg for each patch.
Unfortunately, the download link is a redirect, and the URL changes regularly. Does anyone know the URL for a direct download?
My current script does this:
#!/bin/sh
curl -L -O "https://downloads.citrix.com/16002/CitrixWorkspaceApp.dmg?__gda__=1559853370_f26ea92eb50e024708c1e0cb9dc29474"
mv CitrixWorkspaceApp.dmg?__gda__=1559853370_f26ea92eb50e024708c1e0cb9dc29474 /tmp/CitrixWorkspaceApp.dmg
hdiutil attach /tmp/CitrixWorkspaceApp.dmg -nobrowse
installer -pkg "/Volumes/Citrix Workspace/Install Citrix Workspace.pkg" -target /
citrixmnt="$(hdiutil info | grep "/Volumes/Citrix Workspace" | awk '{ print $1 }')"
hdiutil detach $citrixmnt
rm -f /tmp/CitrixWorkspaceApp.dmg
Posted on 06-07-2019 01:41 AM
@ncats_lab Really.. i'd use Autopkg here.. but you could borrow some bits from the Autopkg recipe
Posted on 06-07-2019 02:57 AM
Workspace can check for updates itself, but Autopkgr is the way to go.
Posted on 06-09-2019 12:19 PM
I did some work on this and it seems to work.
#!/bin/bash
#####################################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
# CitrixWorkspaceUpdate.sh -- Installs or updates Citrix Workspace
#
# SYNOPSIS
# sudo CitrixWorkspaceUpdate.sh
#
# LICENSE
# Distributed under the MIT License
#
# EXIT CODES
# 0 - Citrix Workspace is current
# 1 - Citrix Workspace installed successfully
# 2 - Citrix Workspace NOT installed
# 3 - Citrix Workspace update unsuccessful
# 4 - Citrix Workspace is running
# 5 - Not an Intel-based Mac
#
# these are logged but not passed to jamf as anything other than 0 is a failed script
#
####################################################################################################
#
# HISTORY
#
# Version: 1.7
# - v.1.7 Mark Lamont 15.05.2019 : made a whole bunch of tidy ups of bits I added for debug and changed logic round app running check
# - v.1.6 Mark Lamont 15.05.2019 : made some changes to how the version check works, only uses xx.xx and made it so only two exit codes: 0 and 1 so jaf doesn't flag false fails for a success.
# - v.1.5 Alex Waddell 22.02.2019 : Fixed (for real this time) various version parsing and normalisation issues, resolved exit code problems
# - v.1.4 Alex Waddell 11.12.2018 : Fixed various version parsing and normalisation issues, resolved exit code 3 problem
# - v.1.3 Peter Wreiber 09.19.2018 : Added support for Citrix Workspace
# - v.1.2 Brian Monroe, 05.31.2016 : Fixed downloads and added regex for version matching
# - v.1.1 Luie Lugo, 10.18.2016 : Updated for v12.3, also cleaned up download URL handling
# - v.1.0 Luie Lugo, 09.05.2016 : Updates Citrix Receiver
#
####################################################################################################
# Script to download and install Citrix Workspace.
# Setting variables
WorkspaceProcRunning=0
contactinfo="IT Support"
# Echo function
echoFunc () {
# Date and Time function for the log file
fDateTime () { echo $(date +"%a %b %d %T"); }
# Title for beginning of line in log file
Title="InstallLatestCitrixWorkspace:"
# Header string function
fHeader () { echo $(fDateTime) $(hostname) $Title; }
# Check for the log file
if [ -e "/Library/Logs/CitrixWorkspaceUpdateScript.log" ]; then
echo $(fHeader) "$1" >> "/Library/Logs/CitrixWorkspaceUpdateScript.log"
else
cat "" > "/Library/Logs/CitrixWorkspaceUpdateScript.log"
if [ -e "/Library/Logs/CitrixWorkspaceUpdateScript.log" ]; then
echo $(fHeader) "$1" >> "/Library/Logs/CitrixWorkspaceUpdateScript.log"
else
echo "Failed to create log file, writing to JAMF log"
echo $(fHeader) "$1" >> "/var/log/jamf.log"
fi
fi
# Echo out
echo $(fDateTime) ": $1"
}
# Exit function
exitFunc () {
case $1 in
0) exitCode="0 - Citrix Workspace is current! Version: $2";;
1) exitCode="1 - SUCCESS: Citrix Workspace has been updated to version $2";;
2) exitCode="2 - ERROR: Citrix Workspace NOT installed!";;
3) exitCode="3 - ERROR: Citrix Workspace update unsuccessful, version remains at $2!";;
4) exitCode="4 - ERROR: Citrix Workspace is running.";;
5) exitCode="5 - ERROR: Not an Intel-based Mac.";;
6) exitCode="6 - ERROR: Wireless connected to a known bad WiFi network that won't allow downloading of the installer! SSID: $2";;
*) exitCode="$1";;
esac
echoFunc "Exit code: $exitCode"
echoFunc "======================== Script Complete ========================"
# if exit code is expected the exit 0 else exit 1 so it shows correctly in jamf
if [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "4" ]; then
echo "exit 0"
exit 0
else
echo "exit 1"
exit 1
fi
}
# Check to see if Citrix Workspace is running
WorkspaceRunningCheck () {
isRunning=$(ps ax | grep "Citrix Workspace" | grep -v grep | wc -l | sed 's/ //g')
echoFunc "isRunning is $isRunning"
if [[ $isRunning == 0 ]]
then
echoFunc "Workspace is NOT running, continuing"
else
# Workspace is running,
echoFunc "Workspace is running, get out of here"
WorkspaceRunning
fi
}
WorkspaceRunning () {
# workspace running. let's not interupt and we'll wait 'till next run'
# tidy up
echoFunc "tidying up downloaded dmg"
rm /tmp/${dmgfile}
exitFunc 4
}
echoFunc ""
echoFunc "======================== Starting Script ========================"
# Are we running on Intel?
if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
## Get OS version and adjust for use with the URL string
OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )
## Set the User Agent string for use with curl
userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X ${OSvers_URL}) AppleWebKit/535.6.2 (KHTML, like Gecko) Version/5.2 Safari/535.6.2"
# Get the latest version of Workspace available from Citrix's Workspace page.
latestver=``
while [ -z "$latestver" ]
do
latestver=`curl -s -L https://www.citrix.com/downloads/workspace-app/mac/workspace-app-for-mac-latest.html#ctx-dl-eula-external | grep "<h1>Citrix " | awk '{print $4}'`
done
if [[ ${latestver} =~ ^[0-9]+.[0-9]+$ ]]; then
latestvershort=${latestver:0:4}
fi
latestvernorm=`echo ${latestver}`
echoFunc "Latest Available Citrix Workspace Version for install is: $latestvernorm"
echoFunc "latest version to compare is $latestvershort"
# default value, stays at this if not installed
currentinstalledvernorm="0000"
# Get the version number of the currently-installed Citrix Workspace, if any.
if [ -e "/Applications/Citrix Workspace.app" ]
then
currentinstalledapp="Citrix Workspace"
currentinstalledver=`/usr/bin/defaults read /Applications/Citrix Workspace.app/Contents/Info CFBundleShortVersionString`
echoFunc "Current installed version in full: $currentinstalledver"
if [[ ${currentinstalledver} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{0,2}$ ]];
then
currentinstalledvernorm=$( echo $currentinstalledver | sed -e 's/[.]//g' )
currentinstalledvernorm=${currentinstalledvernorm:0:4}
#echoFunc "Installed version $currentinstalledvernorm"
else
currentinstalledvernorm=${currentinstalledver:0:4}
currentinstalledvernorm=$( echo $currentinstalledvernorm | sed -e 's/[.]/0/g' )
#echoFunc "Installed version $currentinstalledvernorm"
fi
echoFunc "Current installed version to compare is: $currentinstalledvernorm"
if [ ${latestvershort} = ${currentinstalledvernorm} ]; then
exitFunc 0 "No update needed as ${currentinstalledapp} ${currentinstalledvernorm} is current version"
fi
fi
# Build URL and dmg file name
CRCurrVersNormalized=$( echo $latestver | sed -e 's/[.]//g' )
echoFunc "CRCurrVersNormalized: $CRCurrVersNormalized"
url1="https:"
url2=`curl -s -L https://www.citrix.com/downloads/workspace-app/mac/workspace-app-for-mac-latest.html#ctx-dl-eula-external | grep dmg? | sed 's/.*rel=.(.*)..id=.*/1/'`
url=`echo "${url1}${url2}"`
echoFunc "Latest version of the URL is: $url"
dmgfile="Citrix_work_${CRCurrVersNormalized}.dmg"
# Compare the two versions, if they are different or Citrix Workspace is not present then download and install the new version.
if [ "${currentinstalledvernorm}" != "${latestvershort}" ]
then
echoFunc "Current Installed Workspace version: ${currentinstalledapp} ${currentinstalledvernorm}"
echoFunc "Available Workspace version : ${latestvershort} => ${currentinstalledvernorm}"
echoFunc "Downloading newer version."
curl -s -o /tmp/${dmgfile} ${url}
case $? in
0)
echoFunc "Checking if the file exists after downloading."
if [ -e "/tmp/${dmgfile}" ]; then
WorkspaceFileSize=$(du -k "/tmp/${dmgfile}" | cut -f 1)
echoFunc "Downloaded File Size: $WorkspaceFileSize kb"
fi
echoFunc "Checking if Workspace is running before we install"
WorkspaceRunningCheck
echoFunc "Mounting installer disk image."
hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
echoFunc "Installing Citrix Workspace v$latestver"
echo "$(date +"%a %b %d %T") Installing Citrix Workspace v$latestver" >> /var/log/CitrixWorkspaceInstall.log
/usr/sbin/installer -pkg "/Volumes/Citrix Workspace/Install Citrix Workspace.pkg" -target / >> /var/log/CitrixWorkspaceInstall.log # > /dev/null
sleep 10
echoFunc "Unmounting installer disk image."
/sbin/umount /Volumes/Cit*
sleep 10
echoFunc "Deleting disk image."
rm /tmp/${dmgfile}
sleep 10
#double check to see if the new version got update
if [ -e "/Applications/Citrix Workspace.app" ]
then
newlyinstalledver=`/usr/bin/defaults read /Applications/Citrix Workspace.app/Contents/Info CFBundleShortVersionString`
echoFunc "Newly installed version is: $newlyinstalledver"
if [[ ${newlyinstalledver} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{0,2}$ ]];
then
newlyinstalledvernorm=$( echo $newlyinstalledver | sed -e 's/[.]//g' )
newlyinstalledvernorm=${newlyinstalledvernorm:0:4}
echoFunc "Installed version now $newlyinstalledvernorm"
else
newlyinstalledvernorm=${newlyinstalledver:0:4}
newlyinstalledvernorm=$( echo $newlyinstalledvernorm | sed -e 's/[.]/0/' )
echoFunc "Installed version now $newlyinstalledvernorm"
if [[ ${newlyinstalledvernorm} =~ ^[0-9]+.[0-9]+$ ]]; then
echoFunc "installed version tweaked $newlyinstalledvernorm"
fi
fi
if [ "${latestvershort}" = "${newlyinstalledvernorm}" ]
then
echoFunc "SUCCESS: Citrix Workspace has been updated to version ${newlyinstalledvernorm}, issuing JAMF recon command"
jamf recon
if [ $WorkspaceProcRunning -eq 1 ]
then
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "Citrix Workspace Updated" -description "Citrix Workspace has been updated to version ${newlyinstalledvernorm}." -button1 "OK" -defaultButton 1
fi
exitFunc 0 "${newlyinstalledvernorm}"
else
exitFunc 3 "${currentinstalledapp} ${currentinstalledvernorm}"
fi
else
exitFunc 3 "${currentinstalledapp} ${currentinstalledvernorm}"
fi
;;
*)
echoFunc "Curl function failed on download! Error: $?. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html"
;;
esac
else
# If Citrix Workspace is up to date already, just log it and exit.
exitFunc 0 "No update needed as ${currentinstalledapp} ${currentinstalledvernorm} is current version"
fi
else
# This script is for Intel Macs only.
exitFunc 5
fi
Posted on 09-21-2023 08:25 AM
@marklamont Do you happen to have an updated version of this app? I have not tested it but I see it is from 2019 so I assumed there might be an updated version?
I am not sure if you have it up somewhere that we could grab it?
Thank you
Posted on 06-11-2019 09:03 AM
@marklamont , your script seemed to work! Thank you.
Posted on 03-11-2020 09:15 AM
I'm getting an error that Citrix is running on a fresh install macOS X where there isn't any Citrix Apps installed.
Posted on 05-13-2020 11:48 AM
@bmee i've been using AutoPkg and running the Citrix Workspace recipe.
Posted on 06-16-2020 11:50 AM
I also get an error "Citrix is running on a fresh install macOS X where there isn't any Citrix Apps installed."
Posted on 09-21-2020 03:13 PM
Anyone able to get this to work lately?
Posted on 10-27-2020 11:02 AM
the latest version will only work with Catalina. You'll need to download the older version and package it.
Posted on 09-30-2021 03:26 AM
I'm getting an error on Big Sur: "Curl function failed on download! Error: 3.
I assume it's a mistake with a malformatted URL.
09-30-2021 04:54 AM - edited 09-30-2021 04:56 AM
Seems ok for me but I have noticed Citrix are not being consistent with the name of the app.
Posted on 10-01-2021 06:39 AM
I'm now using the Installomator Script https://github.com/Installomator/Installomator for installing Citrix Workspace and it works.
04-05-2022 04:58 PM - edited 04-06-2022 01:14 PM
The installomator version also has lots of janky grep & sed & cut... Just gonna leave this here...
#!/bin/sh
# variables
applnam='Citrix Workspace'
applpth="/Volumes/$applnam/Install $applnam.pkg"
applpkg="/private/tmp/$(/usr/bin/basename "$applpth")"
applurl='https://www.citrix.com/downloads/workspace-app/mac/workspace-app-for-mac-latest.html#ctx-dl-eula-external'
applvrs="$(/usr/bin/curl -LsS "$applurl" | /usr/bin/xmllint -html -xpath "//p[contains(text(),'Version:')]/text()" - | /usr/bin/sed 's/Version: //')"; /bin/sleep 2
applcrl="https:$(/usr/bin/curl -LsS "$applurl" | /usr/bin/xmllint -html -xpath "string(//a[contains(@rel, 'dmg?')]/@rel)" -)"; /bin/sleep 2
appldmg="/private/tmp/$applnam $applvrs.dmg"
# install the current stable version available
>&2 echo "...downloading & installing $appldmg"
/usr/bin/curl -LsS "$applcrl" -o "$appldmg"; /bin/sleep 2
/usr/bin/hdiutil attach -nobrowse "$appldmg"; /bin/sleep 2
/bin/cp "$applpth" /private/tmp/; /bin/sleep 2
/usr/sbin/installer -dumplog -pkg "$applpkg" -tgt /; /bin/sleep 2
>&2 echo "cleaning up..."
/usr/bin/hdiutil detach -force "$(/usr/bin/dirname "$applpth")"
/bin/rm -rf -v "$appldmg" "$applpkg"
Posted on 06-06-2022 06:49 AM
Anybody know of a script that can be added that'll auto-populate the workspace site for the user?
06-23-2022 04:21 PM - edited 06-23-2022 04:24 PM
I have an open case with Citrix regarding automatically populating the workspace URL. It's pretty ridiculous because there is not parity between the Windows & macOS versions. You actually can write the value to the following plist:
~/Library/Preferences/com.citrix.ReceiverFTU.AccountRecords.plist
but the problem is that plist does not exist before the app is opened for the 1st time - the plist is created by populating the URL field on the app splash screen.
They claim to be working on it. I would suggest contacting Citrix support & making your own case. This seems like a very easy thing for them to fix.
Lastly, I did play around with creating the plist with the value I wanted & letting the opening of the app the 1st time kind of merge all the values with very mixed results. You can try it, but, I will be waiting for Citrix to fix this.
Posted on 12-02-2022 08:20 AM
Anything new on this from Citrix?
06-23-2022 04:21 PM - edited 06-23-2022 04:22 PM
see above. :)
Posted on 12-02-2022 09:08 AM
Citrix Workspace is available in the Mac App --> Jamf App Catalog. scope it to install on all deployed machines.
Posted on 12-02-2022 09:18 AM
The problem isn't deploying, we're deploying it just fine. Just curious on trying to get the URL to autopopulate.
Posted on 12-28-2022 01:26 PM
I see the scripts on how to update workspace, but is there a script that will disable the autoupdate. Management wants us to manage these updates when they come out every 2 months along with our other 3rd party patching.
12-28-2022 03:46 PM - edited 12-28-2022 03:48 PM
Looks like Citrix has updated this page & there seems to be a key / val for setting Store URL now. Don't know about updates. I'm looking & if I get something together I will post.
https://docs.citrix.com/en-us/citrix-workspace-app-for-mac/configure.html
Posted on 01-06-2023 02:38 AM
very interesting, I guess this is what needs to be in the ...FTU. PLIST?
StoreURLs – Configure store details so it’s automatically added when the user opens the Citrix Workspace app, simplifying the sign-on experience. To add a store, provide the details for the StoreURLs setting. For example:
<array>
<string>blabla</string>
</array>
I'm also struggling to get a silent package with auto-configured store URL
03-07-2023 06:31 AM - edited 03-07-2023 06:33 AM
I solved it and documented it on my blog
It worked for me, please check and validate if ok for you
the only downside is that the login window is minimized on first launch of CWA, I submitted a ticket to them to get this fixed.
Best regards
03-07-2023 06:56 AM - edited 03-07-2023 06:57 AM
Actually you didn't, unless, they have changed the way this plist works (which is possible.)
If not, this plist only stores the URL AFTER it's been set. It does not pre-populate it at install prior to a user opening the app.
03-07-2023 06:59 AM - edited 03-07-2023 07:00 AM
hi it does in my case, here is how it happens on my side :
1- I deploy the CP ahead of time
2- the user installs CWA 2301 from the self service (its the vanilla pkg from citrix)
3 - the app is autolaunched and the user just has to click on the CWA icon in the dock to get the signin windows to the store
tested on 4 diffferent macs last week
BR
Posted on 03-08-2023 04:07 AM
I have tried this and i cannot for the world get the login page :D
03-08-2023 08:42 AM - edited 03-08-2023 08:56 AM
It only seem to work with the non universal package of citrix workspace. With the universal package with apple silicon support i cannot get the login to show.
Posted on 03-09-2023 11:52 AM
I tried on an intel mac with the intel install and after it installs, I click on the icon at the top and have to click sign-in, it brings up the citrix window, but it just spins and never logs on.
Posted on 03-09-2023 12:03 PM
Here is what I get.
Posted on 03-13-2023 03:25 AM
click on the icon in the dock :)
Posted on 03-14-2023 09:32 AM
I get the same thing.
Posted on 05-09-2023 12:27 PM
Config Profile:
domain: com.citrix.receiver.nomas
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AutoUpdateState</key>
<string>Manual</string>
<key>ShowHelperInMenuBar</key>
<true/>
<key>CEIPEnabled</key>
<false/>
<key>StoreURLs</key>
<array>
<string>STORE URL</string>
</array>
</dict>
</plist>
I deploy this profile first, then install Workspace. Store URL is auto populated and user simply has to log in.
Workspace app MUST be v23.01 or above. Does NOT work in v22.