Skip to main content
Question

Citrix Receiver update script


Forum|alt.badge.img+13

Script to download the latest Citrix Receiver for Mac:

1#!/bin/bash
2
3#####################################################################################################
4#
5# ABOUT THIS PROGRAM
6#
7# NAME
8# CitrixReceiverUpdate.sh -- Updates Citrix Receiver
9#
10# SYNOPSIS
11# sudo CitrixReceiverUpdate.sh
12#
13# LICENSE
14# Distributed under the MIT License
15#
16# EXIT CODES
17# 0 - Citrix Receiver is current
18# 1 - Citrix Receiver installed successfully
19# 2 - Citrix Receiver NOT installed
20# 3 - Citrix Receiver update unsuccessful
21# 4 - Citrix Receiver is running or was attempted to be installed manually and user deferred install
22# 5 - Not an Intel-based Mac
23# 6 - ERROR: Wireless connected to a known bad WiFi network that won't allow downloading of the installer
24#
25####################################################################################################
26#
27# HISTORY
28#
29# Version: 1.0
30#
31# - v.1.0 Luis Lugo, 09.05.2016 : Updates Citrix Receiver
32#
33####################################################################################################
34# Script to download and install Citrix Receiver.
35
36# Setting variables
37receiverProcRunning=0
38
39# Echo function
40echoFunc () {
41 # Date and Time function for the log file
42 fDateTime () { echo $(date +"%a %b %d %T"); }
43
44 # Title for beginning of line in log file
45 Title="InstallLatestCitrixReceiver:"
46
47 # Header string function
48 fHeader () { echo $(fDateTime) $(hostname) $Title; }
49
50 # Check for the log file
51 if [ -e "/Library/Logs/CitrixReceiverUpdateScript.log" ]; then
52 echo $(fHeader) "$1" >> "/Library/Logs/CitrixReceiverUpdateScript.log"
53 else
54 cat > "/Library/Logs/CitrixReceiverUpdateScript.log"
55 if [ -e "/Library/Logs/CitrixReceiverUpdateScript.log" ]; then
56 echo $(fHeader) "$1" >> "/Library/Logs/CitrixReceiverUpdateScript.log"
57 else
58 echo "Failed to create log file, writing to JAMF log"
59 echo $(fHeader) "$1" >> "/var/log/jamf.log"
60 fi
61 fi
62
63 # Echo out
64 echo $(fDateTime) ": $1"
65}
66
67# Exit function
68exitFunc () {
69 case $1 in
70 0) exitCode="0 - Citrix Receiver is current! Version: $2";;
71 1) exitCode="1 - SUCCESS: Citrix Receiver has been updated to version $2";;
72 2) exitCode="2 - ERROR: Citrix Receiver NOT installed!";;
73 3) exitCode="3 - ERROR: Citrix Receiver update unsuccessful, version remains at $2!";;
74 4) exitCode="4 - ERROR: Citrix Receiver is running or was attempted to be installed manually and user deferred install.";;
75 5) exitCode="5 - ERROR: Not an Intel-based Mac.";;
76 6) exitCode="6 - ERROR: Wireless connected to a known bad WiFi network that won't allow downloading of the installer! SSID: $2";;
77 *) exitCode="$1";;
78 esac
79 echoFunc "Exit code: $exitCode"
80 echoFunc "======================== Script Complete ========================"
81 exit $1
82}
83
84# Check to see if Citrix Receiver is running
85receiverRunningCheck () {
86 processNum=$(ps aux | grep "Citrix Receiver" | wc -l)
87 if [ $processNum -gt 1 ]
88 then
89 # Receiver is running, prompt the user to close it or defer the upgrade
90 receiverRunning
91 fi
92}
93
94# If Citrix Receiver is running, prompt the user to close it
95receiverRunning () {
96 echoFunc "Citrix Receiver appears to be running!"
97 hudTitle="Citrix Receiver Update"
98 hudDescription="Citrix Receiver needs to be updated. Please save your work and close the application to proceed. You can defer if needed.
99
100If you have any questions, please call the help desk."
101
102 jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Proceed" -button2 "Defer" -defaultButton 1`
103
104 case $jamfHelperPrompt in
105 0)
106 echoFunc "Proceed selected"
107 receiverProcRunning=1
108 receiverRunningCheck
109 ;;
110 2)
111 echoFunc "Deferment Selected"
112 exitFunc 4
113 ;;
114 *)
115 echoFunc "Selection: $?"
116 #receiverProcRunning=1
117 #receiverRunningCheck
118 exitFunc 3 "Unknown"
119 ;;
120 esac
121}
122
123# If Citrix Receiver is running, prompt the user to close it
124receiverUpdateMan () {
125 echoFunc "Citrix Receiver appears to be running!"
126 hudTitle="Citrix Receiver Update"
127 hudDescription="Citrix Receiver needs to be updated. You will see a program downloading the installer. You can defer if needed.
128
129If you have any questions, please call the help desk."
130
131 jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Defer" -button2 "Proceed" -defaultButton 1 -timeout 60 -countdown`
132
133 case $jamfHelperPrompt in
134 0)
135 echoFunc "Deferment Selected"
136 exitFunc 4
137 ;;
138 2)
139 echoFunc "Proceed selected"
140 receiverRunningCheck
141 ;;
142 *)
143 echoFunc "Selection: $?"
144 exitFunc 3 "Unknown"
145 ;;
146 esac
147}
148
149echoFunc ""
150echoFunc "======================== Starting Script ========================"
151
152# Are we on a bad wireless network?
153if [[ "$4" != "" ]]
154then
155 wifiSSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
156 echoFunc "Current Wireless SSID: $wifiSSID"
157
158 badSSIDs=( $4 )
159 for (( i = 0; i < "${#badSSIDs[@]}"; i++ ))
160 do
161 if [[ "$wifiSSID" == "${badSSIDs[i]}" ]]
162 then
163 echoFunc "Connected to a WiFi network that blocks downloads!"
164 exitFunc 6 "${badSSIDs[i]}"
165 fi
166 done
167fi
168
169# Are we running on Intel?
170if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
171 ## Get OS version and adjust for use with the URL string
172 OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )
173
174 ## Set the User Agent string for use with curl
175 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"
176
177 # Get the latest version of Receiver available from Citrix's Receiver page.
178 latestver=``
179 while [ -z "$latestver" ]
180 do
181 latestver=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html | grep "<h1>Receiver " | awk '{print $2}'`
182 done
183
184 echoFunc "Latest Citrix Receiver Version is: $latestver"
185 latestvernorm=`echo ${latestver}`
186 # Get the version number of the currently-installed Citrix Receiver, if any.
187 if [ -e "/Applications/Citrix Receiver.app" ]; then
188 currentinstalledapp="Citrix Receiver"
189 currentinstalledver=`/usr/bin/defaults read /Applications/Citrix Receiver.app/Contents/Info CFBundleShortVersionString`
190 echoFunc "Current Receiver installed version is: $currentinstalledver"
191 if [ ${latestvernorm} = ${currentinstalledver} ]; then
192 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
193 else
194 # Not running the latest version, check if Receiver is running
195 receiverRunningCheck
196 fi
197 else
198 currentinstalledapp="None"
199 currentinstalledver="N/A"
200 exitFunc 2
201 fi
202
203 # Build URL and dmg file name
204 CRCurrVersNormalized=$( echo $latestver | sed -e 's/[.]//g' )
205 echoFunc "CRCurrVersNormalized: $CRCurrVersNormalized"
206 url1="https:"
207 url2=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html | grep "ctx-dl-link ie10-download-hide promptDw"" | awk '{print $8}' | cut -c 6-112`
208 url=`echo "${url1}${url2}"`
209 echoFunc "Latest version of the URL is: $url"
210 dmgfile="Citrix_Rec_${CRCurrVersNormalized}.dmg"
211
212 # Compare the two versions, if they are different or Citrix Receiver is not present then download and install the new version.
213 if [ "${currentinstalledver}" != "${latestvernorm}" ]; then
214 echoFunc "Current Receiver version: ${currentinstalledapp} ${currentinstalledver}"
215 echoFunc "Available Receiver version: ${latestver} => ${CRCurrVersNormalized}"
216 echoFunc "Downloading newer version."
217 curl -s -o /tmp/${dmgfile} ${url}
218 case $? in
219 0)
220 echoFunc "Checking if the file exists after downloading."
221 if [ -e "/tmp/${dmgfile}" ]; then
222 receiverFileSize=$(du -k "/tmp/${dmgfile}" | cut -f 1)
223 echoFunc "Downloaded File Size: $receiverFileSize kb"
224 else
225 echoFunc "File NOT downloaded!"
226 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
227 fi
228 echoFunc "Checking if Receiver is running one last time before we install"
229 receiverRunningCheck
230 echoFunc "Mounting installer disk image."
231 hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
232 echoFunc "Installing..."
233 installer -pkg /Volumes/Citrix Receiver/Install Citrix Receiver.pkg -target / > /dev/null
234
235 sleep 10
236 echoFunc "Unmounting installer disk image."
237 umount "/Volumes/Citrix Receiver"
238 sleep 10
239 echoFunc "Deleting disk image."
240 rm /tmp/${dmgfile}
241
242 #double check to see if the new version got update
243 if [ -e "/Applications/Citrix Receiver.app" ]; then
244 newlyinstalledver=`/usr/bin/defaults read /Applications/Citrix Receiver.app/Contents/Info CFBundleShortVersionString`
245 if [ "${latestvernorm}" = "${newlyinstalledver}" ]; then
246 echoFunc "SUCCESS: Citrix Receiver has been updated to version ${newlyinstalledver}, issuing JAMF recon command"
247 jamf recon
248 if [ $receiverProcRunning -eq 1 ];
249 then
250 /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "Citrix Receiver Updated" -description "Citrix Receiver has been updated to version ${newlyinstalledver}." -button1 "OK" -defaultButton 1
251 fi
252 exitFunc 1 "${newlyinstalledver}"
253 else
254 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
255 fi
256 else
257 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
258 fi
259 ;;
260 *)
261 echoFunc "Curl function failed on download! Error: $?. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html"
262 ;;
263 esac
264 else
265 # If Citrix Receiver is up to date already, just log it and exit.
266 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
267 fi
268else
269 # This script is for Intel Macs only.
270 exitFunc 5
271fi

33 replies

Forum|alt.badge.img+8
  • Contributor
  • 118 replies
  • May 10, 2016

Oddly enough I was thinking about this earlier. Thank you.

I'll try it out.


Forum|alt.badge.img+13
  • Author
  • Valued Contributor
  • 217 replies
  • October 18, 2016

Version 12.3.0 broke some things with the script. Mainly, it sees the version as "12.3" instead of "12.3.0", so I added a check around line 184 to check for this specific version, and add ".0" after. I also tidied up the download url to look for the string between the double quotes, instead of counting characters (line 211).

1#!/bin/bash
2
3#####################################################################################################
4#
5# ABOUT THIS PROGRAM
6#
7# NAME
8# CitrixReceiverUpdate.sh -- Installs or updates Citrix Receiver
9#
10# SYNOPSIS
11# sudo CitrixReceiverUpdate.sh
12#
13# LICENSE
14# Distributed under the MIT License
15#
16# EXIT CODES
17# 0 - Citrix Receiver is current
18# 1 - Citrix Receiver installed successfully
19# 2 - Citrix Receiver NOT installed
20# 3 - Citrix Receiver update unsuccessful
21# 4 - Citrix Receiver is running or was attempted to be installed manually and user deferred install
22# 5 - Not an Intel-based Mac
23#
24####################################################################################################
25#
26# HISTORY
27#
28# Version: 1.0
29#
30# - v.1.0 Luie Lugo, 09.05.2016 : Updates Citrix Receiver
31# - v.1.1 Luie Lugo, 10.18.2016 : Updated for v12.3, also cleaned up download URL handling
32#
33####################################################################################################
34# Script to download and install Citrix Receiver.
35
36# Setting variables
37receiverProcRunning=0
38
39# Echo function
40echoFunc () {
41 # Date and Time function for the log file
42 fDateTime () { echo $(date +"%a %b %d %T"); }
43
44 # Title for beginning of line in log file
45 Title="InstallLatestCitrixReceiver:"
46
47 # Header string function
48 fHeader () { echo $(fDateTime) $(hostname) $Title; }
49
50 # Check for the log file
51 if [ -e "/Library/Logs/CitrixReceiverUpdateScript.log" ]; then
52 echo $(fHeader) "$1" >> "/Library/Logs/CitrixReceiverUpdateScript.log"
53 else
54 cat "" > "/Library/Logs/CitrixReceiverUpdateScript.log"
55 if [ -e "/Library/Logs/CitrixReceiverUpdateScript.log" ]; then
56 echo $(fHeader) "$1" >> "/Library/Logs/CitrixReceiverUpdateScript.log"
57 else
58 echo "Failed to create log file, writing to JAMF log"
59 echo $(fHeader) "$1" >> "/var/log/jamf.log"
60 fi
61 fi
62
63 # Echo out
64 echo $(fDateTime) ": $1"
65}
66
67# Exit function
68exitFunc () {
69 case $1 in
70 0) exitCode="0 - Citrix Receiver is current! Version: $2";;
71 1) exitCode="1 - SUCCESS: Citrix Receiver has been updated to version $2";;
72 2) exitCode="2 - ERROR: Citrix Receiver NOT installed!";;
73 3) exitCode="3 - ERROR: Citrix Receiver update unsuccessful, version remains at $2!";;
74 4) exitCode="4 - ERROR: Citrix Receiver is running or was attempted to be installed manually and user deferred install.";;
75 5) exitCode="5 - ERROR: Not an Intel-based Mac.";;
76 6) exitCode="6 - ERROR: Wireless connected to a known bad WiFi network that won't allow downloading of the installer! SSID: $2";;
77 *) exitCode="$1";;
78 esac
79 echoFunc "Exit code: $exitCode"
80 echoFunc "======================== Script Complete ========================"
81 exit $1
82}
83
84# Check to see if Citrix Receiver is running
85receiverRunningCheck () {
86 processNum=$(ps aux | grep "Citrix Receiver" | wc -l)
87 if [ $processNum -gt 1 ]
88 then
89 # Receiver is running, prompt the user to close it or defer the upgrade
90 receiverRunning
91 fi
92}
93
94# If Citrix Receiver is running, prompt the user to close it
95receiverRunning () {
96 echoFunc "Citrix Receiver appears to be running!"
97 hudTitle="Citrix Receiver Update"
98 hudDescription="Citrix Receiver needs to be updated. Please save your work and close the application to proceed. You can defer if needed.
99
100If you have any questions, please call SPOC at 1-888-905-9500."
101
102 #sudo -u $(ls -l /dev/console | awk '{print $3}') utility
103 jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Proceed" -button2 "Defer" -defaultButton 1`
104
105 case $jamfHelperPrompt in
106 0)
107 echoFunc "Proceed selected"
108 receiverProcRunning=1
109 receiverRunningCheck
110 ;;
111 2)
112 echoFunc "Deferment Selected"
113 exitFunc 4
114 ;;
115 *)
116 echoFunc "Selection: $?"
117 #receiverProcRunning=1
118 #receiverRunningCheck
119 exitFunc 3 "Unknown"
120 ;;
121 esac
122}
123
124# If Citrix Receiver is running, prompt the user to close it
125receiverUpdateMan () {
126 echoFunc "Citrix Receiver appears to be running!"
127 hudTitle="Citrix Receiver Update"
128 hudDescription="Citrix Receiver needs to be updated. You will see a program downloading the installer. You can defer if needed.
129
130If you have any questions, please call SPOC at 1-888-905-9500."
131
132 jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Defer" -button2 "Proceed" -defaultButton 1 -timeout 60 -countdown`
133
134 case $jamfHelperPrompt in
135 0)
136 echoFunc "Deferment Selected"
137 exitFunc 4
138 ;;
139 2)
140 echoFunc "Proceed selected"
141 receiverRunningCheck
142 ;;
143 *)
144 echoFunc "Selection: $?"
145 exitFunc 3 "Unknown"
146 ;;
147 esac
148}
149
150echoFunc ""
151echoFunc "======================== Starting Script ========================"
152
153# Are we on a bad wireless network?
154if [[ "$4" != "" ]]
155then
156 wifiSSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
157 echoFunc "Current Wireless SSID: $wifiSSID"
158
159 badSSIDs=( $4 )
160 for (( i = 0; i < "${#badSSIDs[@]}"; i++ ))
161 do
162 if [[ "$wifiSSID" == "${badSSIDs[i]}" ]]
163 then
164 echoFunc "Connected to a WiFi network that blocks downloads!"
165 exitFunc 6 "${badSSIDs[i]}"
166 fi
167 done
168fi
169
170# Are we running on Intel?
171if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
172 ## Get OS version and adjust for use with the URL string
173 OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )
174
175 ## Set the User Agent string for use with curl
176 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"
177
178 # Get the latest version of Receiver available from Citrix's Receiver page.
179 latestver=``
180 while [ -z "$latestver" ]
181 do
182 latestver=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html | grep "<h1>Receiver " | awk '{print $2}'`
183 done
184 if [ ${latestver} = "12.3" ]; then
185 latestver="12.3.0"
186 fi
187 echoFunc "Latest Citrix Receiver Version is: $latestver"
188 latestvernorm=`echo ${latestver}`
189
190 # Get the version number of the currently-installed Citrix Receiver, if any.
191 if [ -e "/Applications/Citrix Receiver.app" ]; then
192 currentinstalledapp="Citrix Receiver"
193 currentinstalledver=`/usr/bin/defaults read /Applications/Citrix Receiver.app/Contents/Info CFBundleShortVersionString`
194 echoFunc "Current Receiver installed version is: $currentinstalledver"
195 if [ ${latestvernorm} = ${currentinstalledver} ]; then
196 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
197 else
198 # Not running the latest version, check if Receiver is running
199 receiverRunningCheck
200 fi
201 else
202 currentinstalledapp="None"
203 currentinstalledver="N/A"
204 exitFunc 2
205 fi
206
207 # Build URL and dmg file name
208 CRCurrVersNormalized=$( echo $latestver | sed -e 's/[.]//g' )
209 echoFunc "CRCurrVersNormalized: $CRCurrVersNormalized"
210 url1="https:"
211 url2=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html | grep "ctx-dl-link ie10-download-hide promptDw"" | awk '{print $8}' | awk -F" '{ print $2 }'`
212 url=`echo "${url1}${url2}"`
213 echoFunc "Latest version of the URL is: $url"
214 dmgfile="Citrix_Rec_${CRCurrVersNormalized}.dmg"
215
216 # Compare the two versions, if they are different or Citrix Receiver is not present then download and install the new version.
217 if [ "${currentinstalledver}" != "${latestvernorm}" ]; then
218 echoFunc "Current Receiver version: ${currentinstalledapp} ${currentinstalledver}"
219 echoFunc "Available Receiver version: ${latestver} => ${CRCurrVersNormalized}"
220 echoFunc "Downloading newer version."
221 curl -s -o /tmp/${dmgfile} ${url}
222 case $? in
223 0)
224 echoFunc "Checking if the file exists after downloading."
225 if [ -e "/tmp/${dmgfile}" ]; then
226 receiverFileSize=$(du -k "/tmp/${dmgfile}" | cut -f 1)
227 echoFunc "Downloaded File Size: $receiverFileSize kb"
228 else
229 echoFunc "File NOT downloaded!"
230 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
231 fi
232 echoFunc "Checking if Receiver is running one last time before we install"
233 receiverRunningCheck
234 echoFunc "Mounting installer disk image."
235 hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
236 echoFunc "Installing..."
237 echo "$(date +"%a %b %d %T") Installing Citrix Receiver v$latestver" >> /var/log/CitrixReceiverInstall.log
238 installer -pkg "/Volumes/Citrix Receiver/Install Citrix Receiver.pkg" -target / >> /var/log/CitrixReceiverInstall.log # > /dev/null
239
240 sleep 10
241 echoFunc "Unmounting installer disk image."
242 umount "/Volumes/Citrix Receiver"
243 sleep 10
244 echoFunc "Deleting disk image."
245 rm /tmp/${dmgfile}
246
247 #double check to see if the new version got update
248 if [ -e "/Applications/Citrix Receiver.app" ]; then
249 newlyinstalledver=`/usr/bin/defaults read /Applications/Citrix Receiver.app/Contents/Info CFBundleShortVersionString`
250 if [ "${latestvernorm}" = "${newlyinstalledver}" ]; then
251 echoFunc "SUCCESS: Citrix Receiver has been updated to version ${newlyinstalledver}, issuing JAMF recon command"
252 jamf recon
253 if [ $receiverProcRunning -eq 1 ];
254 then
255 /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "Citrix Receiver Updated" -description "Citrix Receiver has been updated to version ${newlyinstalledver}." -button1 "OK" -defaultButton 1
256 fi
257 exitFunc 1 "${newlyinstalledver}"
258 else
259 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
260 fi
261 else
262 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
263 fi
264 ;;
265 *)
266 echoFunc "Curl function failed on download! Error: $?. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html"
267 ;;
268 esac
269 else
270 # If Citrix Receiver is up to date already, just log it and exit.
271 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
272 fi
273else
274 # This script is for Intel Macs only.
275 exitFunc 5
276fi

Forum|alt.badge.img+2

I can't get this script to work for me. It always thinks Citrix is in use and won't proceed. Even when the app isn't in use there is always something active from Citrix in the Activity Manager. I have played with the script and even tried removing the in use checks but it still won't install. Is anyone else using this or have something better?

I'm currently running Citrix Receiver 12.1.100 and need to update to 12.4. I would rather have the script kill Citrix on it's own instead of requesting the user to do something.


Forum|alt.badge.img+3
  • New Contributor
  • 6 replies
  • March 21, 2017

I tried to get this script going but isn't working for me either. I'm trying to update from 12.4.0 to 12.5.0 but i get this error

Executing Policy Auto-Update Citrix Receiver
Running script autoUpdateCitrixReciever.sh...
Script exit code: 0
Script result: cat: : No such file or directory
Tue Mar 21 12:20:37 : Tue Mar 21 12:20:37 : ======================== Starting Script ========================
Tue Mar 21 12:20:38 : Latest Citrix Receiver Version is: 12.5.0
Tue Mar 21 12:20:38 : Current Receiver installed version is: 12.4.0
Tue Mar 21 12:20:38 : CRCurrVersNormalized: 1250
Tue Mar 21 12:20:39 : Latest version of the URL is: https:
Tue Mar 21 12:20:39 : Current Receiver version: Citrix Receiver 12.4.0
Tue Mar 21 12:20:39 : Available Receiver version: 12.5.0 => 1250
Tue Mar 21 12:20:39 : Downloading newer version.
Tue Mar 21 12:20:39 : Curl function failed on download! Error: 6. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html


Forum|alt.badge.img+15
  • Valued Contributor
  • 78 replies
  • April 11, 2017

I'm getting the same results as @khuong_lai : Curl function failed on download! Error: 6. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html


Forum|alt.badge.img+17
  • Valued Contributor
  • 404 replies
  • April 12, 2017

Hmmm... similar issue here. I have 12.5 installed, so I thought I'd test how it handles that.

1bash-3.2# sudo ./CitrixReceiverUpdate.sh
2cat: : No such file or directory
3Wed Apr 12 13:26:13 :
4Wed Apr 12 13:26:13 : ======================== Starting Script ========================
5Wed Apr 12 13:26:13 : Latest Citrix Receiver Version is: 12.5
6Wed Apr 12 13:26:13 : Current Receiver installed version is: 12.5.0
7Wed Apr 12 13:26:13 : CRCurrVersNormalized: 125
8Wed Apr 12 13:26:14 : Latest version of the URL is: https:
9Wed Apr 12 13:26:14 : Current Receiver version: Citrix Receiver 12.5.0
10Wed Apr 12 13:26:14 : Available Receiver version: 12.5 => 125
11Wed Apr 12 13:26:14 : Downloading newer version.
12Wed Apr 12 13:26:14 : Curl function failed on download! Error: 6. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html

ericjboyd
Forum|alt.badge.img+6
  • Contributor
  • 59 replies
  • May 19, 2017

I am getting the same output as cwaldrip.


Forum|alt.badge.img+4
  • New Contributor
  • 10 replies
  • May 24, 2017

Is the reported download link valid? It should be in the log.

echoFunc "Latest version of the URL is: $url"


ericjboyd
Forum|alt.badge.img+6
  • Contributor
  • 59 replies
  • May 24, 2017

looks like no? Latest version of the URL is: https:

Wed May 24 09:54:38 : ======================== Starting Script ========================
Wed May 24 09:54:39 : Latest Citrix Receiver Version is: 12.5
Wed May 24 09:54:39 : Current Receiver installed version is: 12.5.0
Wed May 24 09:54:39 : CRCurrVersNormalized: 125
Wed May 24 09:54:40 : Latest version of the URL is: https:
Wed May 24 09:54:40 : Current Receiver version: Citrix Receiver 12.5.0
Wed May 24 09:54:40 : Available Receiver version: 12.5 => 125
Wed May 24 09:54:40 : Downloading newer version.
Wed May 24 09:54:40 : Curl function failed on download! Error: 6. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html
m


Forum|alt.badge.img+4
  • New Contributor
  • 10 replies
  • May 31, 2017

They changed the website... You need to replace the line that sets url2. This will work as a work around:

1url2=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html#ctx-dl-eula-external | grep dmg? | sed 's/.*rel=.(.*)..id=.*/1/'`

The original author also hard coded a minor version add with 12.3 (so it would become 12.3.0) so I added some regex for that check so it'll match the installed version for everything else (12.5 becomes 12.5.0) Below is the relevant section that needs to be changed:

1 # Get the latest version of Receiver available from Citrix's Receiver page.
2 latestver=``
3 while [ -z "$latestver" ]
4 do
5 latestver=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html | grep "<h1>Receiver " | awk '{print $2}'`
6 done
7 if [[ ${latestver} =~ ^[0-9]+.[0-9]+$ ]; then
8 # Missing minor version to match the installed version, so we’ll add it here.
9 latestver=${latestver}.0
10 fi
11 echoFunc "Latest Citrix Receiver Version is: $latestver"
12 latestvernorm=`echo ${latestver}`

Forum|alt.badge.img+4
  • New Contributor
  • 10 replies
  • May 31, 2017

Here's an updated version that lets you edit OP's contact info and place your ORGs info instead. Check the variable section.

1#!/bin/bash
2
3#####################################################################################################
4#
5# ABOUT THIS PROGRAM
6#
7# NAME
8# CitrixReceiverUpdate.sh -- Installs or updates Citrix Receiver
9#
10# SYNOPSIS
11# sudo CitrixReceiverUpdate.sh
12#
13# LICENSE
14# Distributed under the MIT License
15#
16# EXIT CODES
17# 0 - Citrix Receiver is current
18# 1 - Citrix Receiver installed successfully
19# 2 - Citrix Receiver NOT installed
20# 3 - Citrix Receiver update unsuccessful
21# 4 - Citrix Receiver is running or was attempted to be installed manually and user deferred install
22# 5 - Not an Intel-based Mac
23#
24####################################################################################################
25#
26# HISTORY
27#
28# Version: 1.2
29#
30# - v.1.2 Brian Monroe, 05.31.2016 : Fixed downloads and added regex for version matching
31# - v.1.1 Luie Lugo, 10.18.2016 : Updated for v12.3, also cleaned up download URL handling
32# - v.1.0 Luie Lugo, 09.05.2016 : Updates Citrix Receiver
33#
34####################################################################################################
35# Script to download and install Citrix Receiver.
36
37# Setting variables
38receiverProcRunning=0
39contactinfo="<YourOrgSupportNameAndInfoHere>"
40
41# Echo function
42echoFunc () {
43 # Date and Time function for the log file
44 fDateTime () { echo $(date +"%a %b %d %T"); }
45
46 # Title for beginning of line in log file
47 Title="InstallLatestCitrixReceiver:"
48
49 # Header string function
50 fHeader () { echo $(fDateTime) $(hostname) $Title; }
51
52 # Check for the log file
53 if [ -e "/Library/Logs/CitrixReceiverUpdateScript.log" ]; then
54 echo $(fHeader) "$1" >> "/Library/Logs/CitrixReceiverUpdateScript.log"
55 else
56 cat "" > "/Library/Logs/CitrixReceiverUpdateScript.log"
57 if [ -e "/Library/Logs/CitrixReceiverUpdateScript.log" ]; then
58 echo $(fHeader) "$1" >> "/Library/Logs/CitrixReceiverUpdateScript.log"
59 else
60 echo "Failed to create log file, writing to JAMF log"
61 echo $(fHeader) "$1" >> "/var/log/jamf.log"
62 fi
63 fi
64
65 # Echo out
66 echo $(fDateTime) ": $1"
67}
68
69# Exit function
70exitFunc () {
71 case $1 in
72 0) exitCode="0 - Citrix Receiver is current! Version: $2";;
73 1) exitCode="1 - SUCCESS: Citrix Receiver has been updated to version $2";;
74 2) exitCode="2 - ERROR: Citrix Receiver NOT installed!";;
75 3) exitCode="3 - ERROR: Citrix Receiver update unsuccessful, version remains at $2!";;
76 4) exitCode="4 - ERROR: Citrix Receiver is running or was attempted to be installed manually and user deferred install.";;
77 5) exitCode="5 - ERROR: Not an Intel-based Mac.";;
78 6) exitCode="6 - ERROR: Wireless connected to a known bad WiFi network that won't allow downloading of the installer! SSID: $2";;
79 *) exitCode="$1";;
80 esac
81 echoFunc "Exit code: $exitCode"
82 echoFunc "======================== Script Complete ========================"
83 exit $1
84}
85
86# Check to see if Citrix Receiver is running
87receiverRunningCheck () {
88 processNum=$(ps aux | grep "Citrix Receiver" | wc -l)
89 if [ $processNum -gt 1 ]
90 then
91 # Receiver is running, prompt the user to close it or defer the upgrade
92 receiverRunning
93 fi
94}
95
96# If Citrix Receiver is running, prompt the user to close it
97receiverRunning () {
98 echoFunc "Citrix Receiver appears to be running!"
99 hudTitle="Citrix Receiver Update"
100 hudDescription="Citrix Receiver needs to be updated. Please save your work and close the application to proceed. You can defer if needed.
101
102If you have any questions, please contact: ${contactinfo}."
103
104 #sudo -u $(ls -l /dev/console | awk '{print $3}') utility
105 jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Proceed" -button2 "Defer" -defaultButton 1`
106
107 case $jamfHelperPrompt in
108 0)
109 echoFunc "Proceed selected"
110 receiverProcRunning=1
111 receiverRunningCheck
112 ;;
113 2)
114 echoFunc "Deferment Selected"
115 exitFunc 4
116 ;;
117 *)
118 echoFunc "Selection: $?"
119 #receiverProcRunning=1
120 #receiverRunningCheck
121 exitFunc 3 "Unknown"
122 ;;
123 esac
124}
125
126# If Citrix Receiver is running, prompt the user to close it
127receiverUpdateMan () {
128 echoFunc "Citrix Receiver appears to be running!"
129 hudTitle="Citrix Receiver Update"
130 hudDescription="Citrix Receiver needs to be updated. You will see a program downloading the installer. You can defer if needed.
131
132If you have any questions, please contact: ${contactinfo}."
133
134 jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Defer" -button2 "Proceed" -defaultButton 1 -timeout 60 -countdown`
135
136 case $jamfHelperPrompt in
137 0)
138 echoFunc "Deferment Selected"
139 exitFunc 4
140 ;;
141 2)
142 echoFunc "Proceed selected"
143 receiverRunningCheck
144 ;;
145 *)
146 echoFunc "Selection: $?"
147 exitFunc 3 "Unknown"
148 ;;
149 esac
150}
151
152echoFunc ""
153echoFunc "======================== Starting Script ========================"
154
155# Are we on a bad wireless network?
156if [[ "$4" != "" ]]
157then
158 wifiSSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
159 echoFunc "Current Wireless SSID: $wifiSSID"
160
161 badSSIDs=( $4 )
162 for (( i = 0; i < "${#badSSIDs[@]}"; i++ ))
163 do
164 if [[ "$wifiSSID" == "${badSSIDs[i]}" ]]
165 then
166 echoFunc "Connected to a WiFi network that blocks downloads!"
167 exitFunc 6 "${badSSIDs[i]}"
168 fi
169 done
170fi
171
172# Are we running on Intel?
173if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
174 ## Get OS version and adjust for use with the URL string
175 OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )
176
177 ## Set the User Agent string for use with curl
178 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"
179
180 # Get the latest version of Receiver available from Citrix's Receiver page.
181 latestver=``
182 while [ -z "$latestver" ]
183 do
184 latestver=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html | grep "<h1>Receiver " | awk '{print $2}'`
185 done
186 if [[ ${latestver} =~ ^[0-9]+.[0-9]+$ ]]; then
187 # Missing minor version to match the installed version, so we’ll add it here.
188 latestver=${latestver}.0
189 fi
190 echoFunc "Latest Citrix Receiver Version is: $latestver"
191 latestvernorm=`echo ${latestver}`
192
193 # Get the version number of the currently-installed Citrix Receiver, if any.
194 if [ -e "/Applications/Citrix Receiver.app" ]; then
195 currentinstalledapp="Citrix Receiver"
196 currentinstalledver=`/usr/bin/defaults read /Applications/Citrix Receiver.app/Contents/Info CFBundleShortVersionString`
197 echoFunc "Current Receiver installed version is: $currentinstalledver"
198 if [ ${latestvernorm} = ${currentinstalledver} ]; then
199 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
200 else
201 # Not running the latest version, check if Receiver is running
202 receiverRunningCheck
203 fi
204 else
205 currentinstalledapp="None"
206 currentinstalledver="N/A"
207 exitFunc 2
208 fi
209
210 # Build URL and dmg file name
211 CRCurrVersNormalized=$( echo $latestver | sed -e 's/[.]//g' )
212 echoFunc "CRCurrVersNormalized: $CRCurrVersNormalized"
213 url1="https:"
214 url2=`curl -s -L https://www.citrix.com/downloads/citrix-receiver/mac/receiver-for-mac-latest.html#ctx-dl-eula-external | grep dmg? | sed 's/.*rel=.(.*)..id=.*/1/'`
215 url=`echo "${url1}${url2}"`
216 echoFunc "Latest version of the URL is: $url"
217 dmgfile="Citrix_Rec_${CRCurrVersNormalized}.dmg"
218
219 # Compare the two versions, if they are different or Citrix Receiver is not present then download and install the new version.
220 if [ "${currentinstalledver}" != "${latestvernorm}" ]; then
221 echoFunc "Current Receiver version: ${currentinstalledapp} ${currentinstalledver}"
222 echoFunc "Available Receiver version: ${latestver} => ${CRCurrVersNormalized}"
223 echoFunc "Downloading newer version."
224 curl -s -o /tmp/${dmgfile} ${url}
225 case $? in
226 0)
227 echoFunc "Checking if the file exists after downloading."
228 if [ -e "/tmp/${dmgfile}" ]; then
229 receiverFileSize=$(du -k "/tmp/${dmgfile}" | cut -f 1)
230 echoFunc "Downloaded File Size: $receiverFileSize kb"
231 else
232 echoFunc "File NOT downloaded!"
233 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
234 fi
235 echoFunc "Checking if Receiver is running one last time before we install"
236 receiverRunningCheck
237 echoFunc "Mounting installer disk image."
238 hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
239 echoFunc "Installing..."
240 echo "$(date +"%a %b %d %T") Installing Citrix Receiver v$latestver" >> /var/log/CitrixReceiverInstall.log
241 installer -pkg "/Volumes/Citrix Receiver/Install Citrix Receiver.pkg" -target / >> /var/log/CitrixReceiverInstall.log # > /dev/null
242
243 sleep 10
244 echoFunc "Unmounting installer disk image."
245 umount "/Volumes/Citrix Receiver"
246 sleep 10
247 echoFunc "Deleting disk image."
248 rm /tmp/${dmgfile}
249
250 #double check to see if the new version got update
251 if [ -e "/Applications/Citrix Receiver.app" ]; then
252 newlyinstalledver=`/usr/bin/defaults read /Applications/Citrix Receiver.app/Contents/Info CFBundleShortVersionString`
253 if [ "${latestvernorm}" = "${newlyinstalledver}" ]; then
254 echoFunc "SUCCESS: Citrix Receiver has been updated to version ${newlyinstalledver}, issuing JAMF recon command"
255 jamf recon
256 if [ $receiverProcRunning -eq 1 ];
257 then
258 /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "Citrix Receiver Updated" -description "Citrix Receiver has been updated to version ${newlyinstalledver}." -button1 "OK" -defaultButton 1
259 fi
260 exitFunc 1 "${newlyinstalledver}"
261 else
262 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
263 fi
264 else
265 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
266 fi
267 ;;
268 *)
269 echoFunc "Curl function failed on download! Error: $?. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html"
270 ;;
271 esac
272 else
273 # If Citrix Receiver is up to date already, just log it and exit.
274 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
275 fi
276else
277 # This script is for Intel Macs only.
278 exitFunc 5
279fi

Forum|alt.badge.img+3
  • New Contributor
  • 6 replies
  • June 24, 2017

Script works great again, thanks! I'm noticing that it does the install but JSS still says it fails. Any ideas?

An error occurred while running the policy "Citrix Receiver Update 12.6.0" on the computer "air15-20".

Actions from policy log: Executing Policy Citrix Receiver Update 12.6.0 Running script autoUpdateCitrixReciever.sh... Script exit code: 1 Script result: cat: : No such file or directory
Sat Jun 24 13:53:22 : Sat Jun 24 13:53:22 : ======================== Starting Script ========================
Sat Jun 24 13:53:24 : Latest Citrix Receiver Version is: 12.6.0
Sat Jun 24 13:53:25 : Current Receiver installed version is: 12.4.0
Sat Jun 24 13:53:25 : CRCurrVersNormalized: 1260
Sat Jun 24 13:53:26 : Latest version of the URL is: https://downloads.citrix.com/13154/CitrixReceiver.dmg?gda=1498280000_22209b8e32a3b0a0313d90b8105690c1
Sat Jun 24 13:53:26 : Current Receiver version: Citrix Receiver 12.4.0
Sat Jun 24 13:53:26 : Available Receiver version: 12.6.0 => 1260
Sat Jun 24 13:53:26 : Downloading newer version.
Sat Jun 24 13:54:26 : Checking if the file exists after downloading.
Sat Jun 24 13:54:26 : Downloaded File Size: 55472 kb
Sat Jun 24 13:54:26 : Checking if Receiver is running one last time before we install
Sat Jun 24 13:54:26 : Mounting installer disk image.
Sat Jun 24 13:54:28 : Installing...
Sat Jun 24 13:54:44 : Unmounting installer disk image.
Sat Jun 24 13:54:54 : Deleting disk image.
Sat Jun 24 13:54:54 : SUCCESS: Citrix Receiver has been updated to version 12.6.0, issuing JAMF recon command
Retrieving inventory preferences from https://jss.trinity.edu.au:8443/...
Finding extension attributes...
Locating package receipts...
Locating accounts...
Locating software updates...
Locating applications...
Locating hard drive information...
Searching path: /Applications
Locating printers...
Locating hardware information (Mac OS X 10.11.6)...
Gathering application usage information...
Submitting data to https://jss.trinity.edu.au:8443/...
<computer_id>764</computer_id>
Sat Jun 24 13:55:38 : Exit code: 1 - SUCCESS: Citrix Receiver has been updated to version 12.6.0
Sat Jun 24 13:55:38 : ======================== Script Complete ========================

Error running script: return code was 1.


stevewood
Forum|alt.badge.img+35
  • Hall of Fame
  • 1799 replies
  • June 24, 2017

@khuong_lai because the script uses Bash exit codes to tell what it has done, and the author chose to use exit code 1 to show a successful install, the JSS will always see it as a failed script. Any exit code other than 0 will be seen as a failed attempt by the JSS, as the JSS expects exit code 0 for success.

Rather than using exit codes, the script should probably be modified to write to an EA via the API, or write to a PLIST file that is then read by an EA, or simply echo some text with what was found.

At any rate, something other than exit codes should be used, or users of the script just need to know a failure isn't necessarily a failure.


whitebeer
Forum|alt.badge.img+7
  • Contributor
  • 41 replies
  • June 29, 2017

I had an issue with "Citrix appears to be running" - it always showed up even if the receiver was not running. Then I realised, that ps aux also found different processes. So I changed this module of the script as follows:

1# Check to see if Citrix Receiver is running
2receiverRunningCheck () {
3 processNum=$(ps aux | grep "Citrix Receiver.app" | wc -l)
4 if [ $processNum -gt 0 ]
5 then
6 # Receiver is running, prompt the user to close it or defer the upgrade
7 receiverRunning
8 fi
9}

With this changed module the workflow works for me :-) btw. thank you for the script


Forum|alt.badge.img+1
  • New Contributor
  • 6 replies
  • October 4, 2017

Has anyone had any luck using this script to perform a clean install of Citrix Receiver 12.7?


ericjboyd
Forum|alt.badge.img+6
  • Contributor
  • 59 replies
  • September 18, 2018

Citrix Receiver has become Citrix Workspace.

Any suggestions on how to modify the script to include this new version?


Forum|alt.badge.img+1
  • New Contributor
  • 2 replies
  • September 19, 2018

I have made some quick modifications to the script to support Citrix Workspace . Seems to install ok, but It throws an error 3 at my end.

1#!/bin/bash
2
3#####################################################################################################
4#
5# ABOUT THIS PROGRAM
6#
7# NAME
8# CitrixWorkspaceUpdate.sh -- Installs or updates Citrix Workspace
9#
10# SYNOPSIS
11# sudo CitrixWorkspaceUpdate.sh
12#
13# LICENSE
14# Distributed under the MIT License
15#
16# EXIT CODES
17# 0 - Citrix Workspace is current
18# 1 - Citrix Workspace installed successfully
19# 2 - Citrix Workspace NOT installed
20# 3 - Citrix Workspace update unsuccessful
21# 4 - Citrix Workspace is running or was attempted to be installed manually and user deferred install
22# 5 - Not an Intel-based Mac
23#
24####################################################################################################
25#
26# HISTORY
27#
28# Version: 1.3
29# - v.1.3 Peter Wreiber 09.19.2018 : Added support for Citrix Workspace
30# - v.1.2 Brian Monroe, 05.31.2016 : Fixed downloads and added regex for version matching
31# - v.1.1 Luie Lugo, 10.18.2016 : Updated for v12.3, also cleaned up download URL handling
32# - v.1.0 Luie Lugo, 09.05.2016 : Updates Citrix Receiver
33#
34####################################################################################################
35# Script to download and install Citrix Workspace.
36
37# Setting variables
38WorkspaceProcRunning=0
39contactinfo="<YourOrgSupportNameAndInfoHere>"
40
41# Echo function
42echoFunc () {
43 # Date and Time function for the log file
44 fDateTime () { echo $(date +"%a %b %d %T"); }
45
46 # Title for beginning of line in log file
47 Title="InstallLatestCitrixWorkspace:"
48
49 # Header string function
50 fHeader () { echo $(fDateTime) $(hostname) $Title; }
51
52 # Check for the log file
53 if [ -e "/Library/Logs/CitrixWorkspaceUpdateScript.log" ]; then
54 echo $(fHeader) "$1" >> "/Library/Logs/CitrixWorkspaceUpdateScript.log"
55 else
56 cat "" > "/Library/Logs/CitrixWorkspaceUpdateScript.log"
57 if [ -e "/Library/Logs/CitrixWorkspaceUpdateScript.log" ]; then
58 echo $(fHeader) "$1" >> "/Library/Logs/CitrixWorkspaceUpdateScript.log"
59 else
60 echo "Failed to create log file, writing to JAMF log"
61 echo $(fHeader) "$1" >> "/var/log/jamf.log"
62 fi
63 fi
64
65 # Echo out
66 echo $(fDateTime) ": $1"
67}
68
69# Exit function
70exitFunc () {
71 case $1 in
72 0) exitCode="0 - Citrix Workspace is current! Version: $2";;
73 1) exitCode="1 - SUCCESS: Citrix Workspace has been updated to version $2";;
74 2) exitCode="2 - ERROR: Citrix Workspace NOT installed!";;
75 3) exitCode="3 - ERROR: Citrix Workspace update unsuccessful, version remains at $2!";;
76 4) exitCode="4 - ERROR: Citrix Workspace is running or was attempted to be installed manually and user deferred install.";;
77 5) exitCode="5 - ERROR: Not an Intel-based Mac.";;
78 6) exitCode="6 - ERROR: Wireless connected to a known bad WiFi network that won't allow downloading of the installer! SSID: $2";;
79 *) exitCode="$1";;
80 esac
81 echoFunc "Exit code: $exitCode"
82 echoFunc "======================== Script Complete ========================"
83 exit $1
84}
85
86# Check to see if Citrix Workspace is running
87WorkspaceRunningCheck () {
88 processNum=$(ps aux | grep "Citrix Workspace" | wc -l)
89 if [ $processNum -gt 1 ]
90 then
91 # Workspace is running, prompt the user to close it or defer the upgrade
92 WorkspaceRunning
93 fi
94}
95
96# If Citrix Workspace is running, prompt the user to close it
97WorkspaceRunning () {
98 echoFunc "Citrix Workspace appears to be running!"
99 hudTitle="Citrix Workspace Update"
100 hudDescription="Citrix Workspace needs to be updated. Please save your work and close the application to proceed. You can defer if needed.
101
102If you have any questions, please contact: ${contactinfo}."
103
104 #sudo -u $(ls -l /dev/console | awk '{print $3}') utility
105 #jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Proceed" -button2 "Defer" -defaultButton 1`
106
107 case $jamfHelperPrompt in
108 0)
109 echoFunc "Proceed selected"
110 WorkspaceProcRunning=1
111 WorkspaceRunningCheck
112 ;;
113 2)
114 echoFunc "Deferment Selected"
115 exitFunc 4
116 ;;
117 *)
118 echoFunc "Selection: $?"
119 #WorkspaceProcRunning=1
120 #WorkspaceRunningCheck
121 exitFunc 3 "Unknown"
122 ;;
123 esac
124}
125
126# If Citrix Workspace is running, prompt the user to close it
127WorkspaceUpdateMan () {
128 echoFunc "Citrix Workspace appears to be running!"
129 hudTitle="Citrix Workspace Update"
130 hudDescription="Citrix Workspace needs to be updated. You will see a program downloading the installer. You can defer if needed.
131
132If you have any questions, please contact: ${contactinfo}."
133
134 #jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Defer" -button2 "Proceed" -defaultButton 1 -timeout 60 -countdown`
135
136 case $jamfHelperPrompt in
137 0)
138 echoFunc "Deferment Selected"
139 exitFunc 4
140 ;;
141 2)
142 echoFunc "Proceed selected"
143 WorkspaceRunningCheck
144 ;;
145 *)
146 echoFunc "Selection: $?"
147 exitFunc 3 "Unknown"
148 ;;
149 esac
150}
151
152echoFunc ""
153echoFunc "======================== Starting Script ========================"
154
155# Are we on a bad wireless network?
156if [[ "$4" != "" ]]
157then
158 wifiSSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
159 echoFunc "Current Wireless SSID: $wifiSSID"
160
161 badSSIDs=( $4 )
162 for (( i = 0; i < "${#badSSIDs[@]}"; i++ ))
163 do
164 if [[ "$wifiSSID" == "${badSSIDs[i]}" ]]
165 then
166 echoFunc "Connected to a WiFi network that blocks downloads!"
167 exitFunc 6 "${badSSIDs[i]}"
168 fi
169 done
170fi
171
172# Are we running on Intel?
173if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
174 ## Get OS version and adjust for use with the URL string
175 OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )
176
177 ## Set the User Agent string for use with curl
178 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"
179
180 # Get the latest version of Workspace available from Citrix's Workspace page.
181 latestver=``
182 while [ -z "$latestver" ]
183 do
184 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 $2}'`
185 done
186 if [[ ${latestver} =~ ^[0-9]+.[0-9]+$ ]]; then
187 # Missing minor version to match the installed version, so we’ll add it here.
188 latestver=${latestver}.0
189 fi
190 echoFunc "Latest Citrix Workspace Version is: $latestver"
191 latestvernorm=`echo ${latestver}`
192
193 # Get the version number of the currently-installed Citrix Workspace, if any.
194 if [ -e "/Applications/Citrix Workspace.app" ]; then
195 currentinstalledapp="Citrix Workspace"
196 currentinstalledver=`/usr/bin/defaults read /Applications/Citrix Workspace.app/Contents/Info CFBundleShortVersionString`
197 echoFunc "Current Workspace installed version is: $currentinstalledver"
198 if [ ${latestvernorm} = ${currentinstalledver} ]; then
199 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
200 fi
201 fi
202
203
204 # Build URL and dmg file name
205 CRCurrVersNormalized=$( echo $latestver | sed -e 's/[.]//g' )
206 echoFunc "CRCurrVersNormalized: $CRCurrVersNormalized"
207 url1="https:"
208 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/'`
209 url=`echo "${url1}${url2}"`
210 echoFunc "Latest version of the URL is: $url"
211 dmgfile="Citrix_work_${CRCurrVersNormalized}.dmg"
212
213 # Compare the two versions, if they are different or Citrix Workspace is not present then download and install the new version.
214 if [ "${currentinstalledver}" != "${latestvernorm}" ]; then
215 echoFunc "Current Workspace version: ${currentinstalledapp} ${currentinstalledver}"
216 echoFunc "Available Workspace version: ${latestver} => ${CRCurrVersNormalized}"
217 echoFunc "Downloading newer version."
218 curl -s -o /tmp/${dmgfile} ${url}
219 case $? in
220 0)
221 echoFunc "Checking if the file exists after downloading."
222 if [ -e "/tmp/${dmgfile}" ]; then
223 WorkspaceFileSize=$(du -k "/tmp/${dmgfile}" | cut -f 1)
224 echoFunc "Downloaded File Size: $WorkspaceFileSize kb"
225 fi
226 echoFunc "Checking if Workspace is running one last time before we install"
227 #WorkspaceRunningCheck
228 echoFunc "Mounting installer disk image."
229 hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
230 echoFunc "Installing..."
231 echo "$(date +"%a %b %d %T") Installing Citrix Workspace v$latestver" >> /var/log/CitrixWorkspaceInstall.log
232 /usr/sbin/installer -pkg "/Volumes/Citrix Workspace/Install Citrix Workspace.pkg" -target / >> /var/log/CitrixWorkspaceInstall.log # > /dev/null
233
234 sleep 10
235 echoFunc "Unmounting installer disk image."
236 /sbin/umount /Volumes/Cit*
237 sleep 10
238 echoFunc "Deleting disk image."
239 rm /tmp/${dmgfile}
240
241 #double check to see if the new version got update
242 if [ -e "/Applications/Citrix Workspace.app" ]; then
243 newlyinstalledver=`/usr/bin/defaults read /Applications/Citrix Workspace.app/Contents/Info CFBundleShortVersionString`
244 if [ "${latestvernorm}" = "${newlyinstalledver}" ]; then
245 echoFunc "SUCCESS: Citrix Workspace has been updated to version ${newlyinstalledver}, issuing JAMF recon command"
246 jamf recon
247 if [ $WorkspaceProcRunning -eq 1 ];
248 then
249 /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 ${newlyinstalledver}." -button1 "OK" -defaultButton 1
250 fi
251 exitFunc 1 "${newlyinstalledver}"
252 else
253 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
254 fi
255 else
256 exitFunc 3 "${currentinstalledapp} ${currentinstalledver}"
257 fi
258 ;;
259 *)
260 echoFunc "Curl function failed on download! Error: $?. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html"
261 ;;
262 esac
263 else
264 # If Citrix Workspace is up to date already, just log it and exit.
265 exitFunc 0 "${currentinstalledapp} ${currentinstalledver}"
266 fi
267else
268 # This script is for Intel Macs only.
269 exitFunc 5
270fi

Forum|alt.badge.img+6
  • Contributor
  • 14 replies
  • September 20, 2018

Tried it at my end and getting same error, appears to download the file but fails when trying to execute the installation bit of the script.

Thu Sep 20 11:06:01 : ======================== Starting Script ========================
Thu Sep 20 11:06:02 : Latest Citrix Workspace Version is: Workspace
Thu Sep 20 11:06:02 : CRCurrVersNormalized: Workspace
Thu Sep 20 11:06:03 : Latest version of the URL is: https://downloads.citrix.com/14987/CitrixWorkspaceApp.dmg?gda=1537441505_5e9cc241de7a57197961ea6b218f4e14
Thu Sep 20 11:06:03 : Current Workspace version: Thu Sep 20 11:06:03 : Available Workspace version: Workspace => Workspace
Thu Sep 20 11:06:03 : Downloading newer version.
Thu Sep 20 11:06:39 : Checking if the file exists after downloading.
Thu Sep 20 11:06:39 : Downloaded File Size: 114752 kb
Thu Sep 20 11:06:39 : Checking if Workspace is running one last time before we install
Thu Sep 20 11:06:39 : Mounting installer disk image.
Thu Sep 20 11:06:41 : Installing...
Thu Sep 20 11:06:51 : Unmounting installer disk image.
Thu Sep 20 11:07:02 : Deleting disk image.
Thu Sep 20 11:07:02 : Exit code: 3 - ERROR: Citrix Workspace update unsuccessful, version remains at !
Thu Sep 20 11:07:02 : ======================== Script Complete ========================


Forum|alt.badge.img+1
  • New Contributor
  • 2 replies
  • November 14, 2018

Fixed the exit code 3 problem and also some version parsing and normalisation issues:

!/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 or was attempted to be installed manually and user deferred install

5 - Not an Intel-based Mac

########################################################################################

# HISTORY

Version: 1.4

- 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="NatWest Markets CurrencyPay 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 or was attempted to be installed manually and user deferred install.";; 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 ========================" exit $1
}

Check to see if Citrix Workspace is running

WorkspaceRunningCheck () { processNum=$(ps aux | grep "Citrix Workspace" | wc -l) if [ $processNum -gt 1 ] then # Workspace is running, prompt the user to close it or defer the upgrade WorkspaceRunning fi
}

If Citrix Workspace is running, prompt the user to close it

WorkspaceRunning () { echoFunc "Citrix Workspace appears to be running!" hudTitle="Citrix Workspace Update" hudDescription="Citrix Workspace needs to be updated. Please save your work and close the application to proceed. You can defer if needed.

If you have any questions, please contact: ${contactinfo}."

#sudo -u $(ls -l /dev/console | awk '{print $3}') utility #jamfHelperPrompt=/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Proceed" -button2 "Defer" -defaultButton 1

case $jamfHelperPrompt in 0) echoFunc "Proceed selected" WorkspaceProcRunning=1 WorkspaceRunningCheck ;; 2) echoFunc "Deferment Selected" exitFunc 4 ;; *) echoFunc "Selection: $?" #WorkspaceProcRunning=1 #WorkspaceRunningCheck exitFunc 3 "Unknown" ;; esac
}

If Citrix Workspace is running, prompt the user to close it

WorkspaceUpdateMan () { echoFunc "Citrix Workspace appears to be running!" hudTitle="Citrix Workspace Update" hudDescription="Citrix Workspace needs to be updated. You will see a program downloading the installer. You can defer if needed.

If you have any questions, please contact: ${contactinfo}."

#jamfHelperPrompt=/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Defer" -button2 "Proceed" -defaultButton 1 -timeout 60 -countdown

case $jamfHelperPrompt in 0) echoFunc "Deferment Selected" exitFunc 4 ;; 2) echoFunc "Proceed selected" WorkspaceRunningCheck ;; *) echoFunc "Selection: $?" exitFunc 3 "Unknown" ;; esac
}

echoFunc ""
echoFunc "======================== Starting Script ========================"

Are we on a bad wireless network?

if [[ "$4" != "" ]]
then wifiSSID=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}' echoFunc "Current Wireless SSID: $wifiSSID"

badSSIDs=( $4 ) for (( i = 0; i < "${#badSSIDs[@]}"; i++ )) do if [[ "$wifiSSID" == "${badSSIDs[i]}" ]] then echoFunc "Connected to a WiFi network that blocks downloads!" exitFunc 6 "${badSSIDs[i]}" fi done
fi

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 # Missing minor version to match the installed version, so we’ll add it here. latestver=${latestver}.0 fi echoFunc "Latest Available Citrix Workspace Version for install is: $latestver" latestvernorm=echo ${latestver}

# 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 currentinstalledvernorm=$( echo $currentinstalledver | sed -e 's/[.]/0/g' ) currentinstalledvernorm=${currentinstalledvernorm:0:4} echoFunc "Current Workspace installed version is: $currentinstalledvernorm" if [ ${latestvernorm} = ${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}" != "${latestvernorm}" ]; then echoFunc "Current Installed Workspace version: ${currentinstalledapp} ${currentinstalledvernorm}" echoFunc "Available Workspace version : ${latestver} => ${CRCurrVersNormalized}" 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 one last time before we install" #WorkspaceRunningCheck echoFunc "Mounting installer disk image." hdiutil attach /tmp/${dmgfile} -nobrowse -quiet echoFunc "Installing..." 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}

#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 if [ "${latestvernorm}" = "${newlyinstalledver}" ]; then echoFunc "SUCCESS: Citrix Workspace has been updated to version ${newlyinstalledver}, 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 ${newlyinstalledver}." -button1 "OK" -defaultButton 1 fi exitFunc 1 "${newlyinstalledver}" else exitFunc 3 "${currentinstalledapp} ${currentinstalledver}" fi else exitFunc 3 "${currentinstalledapp} ${currentinstalledver}" 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


Forum|alt.badge.img+12
  • Contributor
  • 181 replies
  • November 26, 2018

@peter.wreiber I think Citrix have changed things again.

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 $2}'

returns Workspace as the full line returned is

<h1>Citrix Workspace app 1809 for Mac</h1>

'{print $4}' gives the version now.


donmontalvo
Forum|alt.badge.img+36
  • Hall of Fame
  • 4293 replies
  • December 6, 2018

If suppression is a requirement, good to see these settings are now where hey belong, at the computer level:

1#!/bin/sh
2
3/usr/bin/defaults write /Library/Preferences/com.citrix.receiver.nomas AutoUpdateState -string Disabled
4/usr/bin/defaults write /Library/Preferences/com.citrix.receiver.nomas HockeySDKAutomaticallySendCrashReports -bool false
5/usr/bin/defaults write /Library/Preferences/com.citrix.receiver.nomas HockeySDKCrashReportActivated -bool false
6/usr/bin/defaults write /Library/Preferences/com.citrix.receiver.nomas TraceOn -bool false
7/usr/bin/defaults write /Library/Preferences/com.citrix.receiver.nomas DisplaySplashScreen -bool false
8/usr/bin/defaults write /Library/Preferences/com.citrix.receiver.nomas BITApplicationWasLaunched -bool true
9/usr/bin/defaults write /Library/Preferences/com.citrix.receiver.nomas CEIPEnabled -bool false
10
11exit 0

...and yes, can use a Configuration Profile...pick yer poison. :)


Forum|alt.badge.img+1
  • New Contributor
  • 3 replies
  • January 22, 2019

Hi all,

Is it possible for someone to post the latest complete script version? without the Error 3 code.

I'am fairly new with JAMF and I will follow a course this february to get the hang of it.
I already know how to edit and make profiles and policies with adding scripts etc.

But my scripting skills are what you can call a complete beginner.
Luckily we have you guys :)

Thanks for the help.

Cheers,
Dennis


Forum|alt.badge.img+8
  • Contributor
  • 118 replies
  • January 22, 2019

Hi all,

I am trying to get the Citrix Workspace up and running..

The thing is..... When I install the package via JAMF the Workspace app is not detected.. When I manually install the package all is working fine..

I am going nuts here..... Anyone any idea?

I have tried using this script
I have tried using the original installer
I have tried package made by Autopkr.

All with the same results.. Install is OK (no errors) but Workspace is not detected when starting the saas app. When I install the package interactively all is OK..


Forum|alt.badge.img+1
  • New Contributor
  • 2 replies
  • March 19, 2019

Hi all,

After quite some wrangling I believe I have resolved the script errors - the joy of version numbers changing & needing to be padded and normalised...

1#!/bin/bash
2
3#####################################################################################################
4#
5# ABOUT THIS PROGRAM
6#
7# NAME
8# CitrixWorkspaceUpdate.sh -- Installs or updates Citrix Workspace
9#
10# SYNOPSIS
11# sudo CitrixWorkspaceUpdate.sh
12#
13# LICENSE
14# Distributed under the MIT License
15#
16# EXIT CODES
17# 0 - Citrix Workspace is current
18# 1 - Citrix Workspace installed successfully
19# 2 - Citrix Workspace NOT installed
20# 3 - Citrix Workspace update unsuccessful
21# 4 - Citrix Workspace is running or was attempted to be installed manually and user deferred install
22# 5 - Not an Intel-based Mac
23#
24####################################################################################################
25#
26# HISTORY
27#
28# Version: 1.5
29# - v.1.5 Alex Waddell 22.02.2019 : Fixed (for real this time) various version parsing and normalisation issues, resolved exit code problems
30# - v.1.4 Alex Waddell 11.12.2018 : Fixed various version parsing and normalisation issues, resolved exit code 3 problem
31# - v.1.3 Peter Wreiber 09.19.2018 : Added support for Citrix Workspace
32# - v.1.2 Brian Monroe, 05.31.2016 : Fixed downloads and added regex for version matching
33# - v.1.1 Luie Lugo, 10.18.2016 : Updated for v12.3, also cleaned up download URL handling
34# - v.1.0 Luie Lugo, 09.05.2016 : Updates Citrix Receiver
35#
36####################################################################################################
37# Script to download and install Citrix Workspace.
38
39# Setting variables
40WorkspaceProcRunning=0
41contactinfo="NatWest Markets CurrencyPay Support"
42
43# Echo function
44echoFunc () {
45 # Date and Time function for the log file
46 fDateTime () { echo $(date +"%a %b %d %T"); }
47
48 # Title for beginning of line in log file
49 Title="InstallLatestCitrixWorkspace:"
50
51 # Header string function
52 fHeader () { echo $(fDateTime) $(hostname) $Title; }
53
54 # Check for the log file
55 if [ -e "/Library/Logs/CitrixWorkspaceUpdateScript.log" ]; then
56 echo $(fHeader) "$1" >> "/Library/Logs/CitrixWorkspaceUpdateScript.log"
57 else
58 cat "" > "/Library/Logs/CitrixWorkspaceUpdateScript.log"
59 if [ -e "/Library/Logs/CitrixWorkspaceUpdateScript.log" ]; then
60 echo $(fHeader) "$1" >> "/Library/Logs/CitrixWorkspaceUpdateScript.log"
61 else
62 echo "Failed to create log file, writing to JAMF log"
63 echo $(fHeader) "$1" >> "/var/log/jamf.log"
64 fi
65 fi
66
67 # Echo out
68 echo $(fDateTime) ": $1"
69}
70
71# Exit function
72exitFunc () {
73 case $1 in
74 0) exitCode="0 - Citrix Workspace is current! Version: $2";;
75 1) exitCode="1 - SUCCESS: Citrix Workspace has been updated to version $2";;
76 2) exitCode="2 - ERROR: Citrix Workspace NOT installed!";;
77 3) exitCode="3 - ERROR: Citrix Workspace update unsuccessful, version remains at $2!";;
78 4) exitCode="4 - ERROR: Citrix Workspace is running or was attempted to be installed manually and user deferred install.";;
79 5) exitCode="5 - ERROR: Not an Intel-based Mac.";;
80 6) exitCode="6 - ERROR: Wireless connected to a known bad WiFi network that won't allow downloading of the installer! SSID: $2";;
81 *) exitCode="$1";;
82 esac
83 echoFunc "Exit code: $exitCode"
84 echoFunc "======================== Script Complete ========================"
85 exit $1
86}
87
88# Check to see if Citrix Workspace is running
89WorkspaceRunningCheck () {
90 processNum=$(ps aux | grep "Citrix Workspace" | wc -l)
91 if [ $processNum -gt 1 ]
92 then
93 # Workspace is running, prompt the user to close it or defer the upgrade
94 WorkspaceRunning
95 fi
96}
97
98# If Citrix Workspace is running, prompt the user to close it
99WorkspaceRunning () {
100 echoFunc "Citrix Workspace appears to be running!"
101 hudTitle="Citrix Workspace Update"
102 hudDescription="Citrix Workspace needs to be updated. Please save your work and close the application to proceed. You can defer if needed.
103
104If you have any questions, please contact: ${contactinfo}."
105
106 #sudo -u $(ls -l /dev/console | awk '{print $3}') utility
107 #jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Proceed" -button2 "Defer" -defaultButton 1`
108
109 case $jamfHelperPrompt in
110 0)
111 echoFunc "Proceed selected"
112 WorkspaceProcRunning=1
113 WorkspaceRunningCheck
114 ;;
115 2)
116 echoFunc "Deferment Selected"
117 exitFunc 4
118 ;;
119 *)
120 echoFunc "Selection: $?"
121 #WorkspaceProcRunning=1
122 #WorkspaceRunningCheck
123 exitFunc 3 "Unknown"
124 ;;
125 esac
126}
127
128# If Citrix Workspace is running, prompt the user to close it
129WorkspaceUpdateMan () {
130 echoFunc "Citrix Workspace appears to be running!"
131 hudTitle="Citrix Workspace Update"
132 hudDescription="Citrix Workspace needs to be updated. You will see a program downloading the installer. You can defer if needed.
133
134If you have any questions, please contact: ${contactinfo}."
135
136 #jamfHelperPrompt=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -lockHUD -title "$hudTitle" -description "$hudDescription" -button1 "Defer" -button2 "Proceed" -defaultButton 1 -timeout 60 -countdown`
137
138 case $jamfHelperPrompt in
139 0)
140 echoFunc "Deferment Selected"
141 exitFunc 4
142 ;;
143 2)
144 echoFunc "Proceed selected"
145 WorkspaceRunningCheck
146 ;;
147 *)
148 echoFunc "Selection: $?"
149 exitFunc 3 "Unknown"
150 ;;
151 esac
152}
153
154echoFunc ""
155echoFunc "======================== Starting Script ========================"
156
157# Are we on a bad wireless network?
158if [[ "$4" != "" ]]
159then
160 wifiSSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
161 echoFunc "Current Wireless SSID: $wifiSSID"
162
163 badSSIDs=( $4 )
164 for (( i = 0; i < "${#badSSIDs[@]}"; i++ ))
165 do
166 if [[ "$wifiSSID" == "${badSSIDs[i]}" ]]
167 then
168 echoFunc "Connected to a WiFi network that blocks downloads!"
169 exitFunc 6 "${badSSIDs[i]}"
170 fi
171 done
172fi
173
174# Are we running on Intel?
175if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
176 ## Get OS version and adjust for use with the URL string
177 OSvers_URL=$( sw_vers -productVersion | sed 's/[.]/_/g' )
178
179 ## Set the User Agent string for use with curl
180 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"
181
182 # Get the latest version of Workspace available from Citrix's Workspace page.
183 latestver=``
184 while [ -z "$latestver" ]
185 do
186 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}'`
187 done
188 if [[ ${latestver} =~ ^[0-9]+.[0-9]+$ ]]; then
189 # Missing minor version to match the installed version, so we’ll add it here.
190 latestver=${latestver}.0
191 fi
192 latestvernorm=`echo ${latestver}`
193 echoFunc "Latest Available Citrix Workspace Version for install is: $latestvernorm"
194
195 currentinstalledvernorm="0000"
196
197 # Get the version number of the currently-installed Citrix Workspace, if any.
198 if [ -e "/Applications/Citrix Workspace.app" ]
199 then
200 currentinstalledapp="Citrix Workspace"
201 currentinstalledver=`/usr/bin/defaults read /Applications/Citrix Workspace.app/Contents/Info CFBundleShortVersionString`
202 echoFunc "Current installed version is: $currentinstalledver"
203 if [[ ${currentinstalledver} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{0,2}$ ]];
204 then
205 currentinstalledvernorm=$( echo $currentinstalledver | sed -e 's/[.]//g' )
206 currentinstalledvernorm=${currentinstalledvernorm:0:4}
207 else
208 # Missing minor version so we’ll add it here.
209 currentinstalledvernorm=${currentinstalledver:0:4}
210 currentinstalledvernorm=$( echo $currentinstalledvernorm | sed -e 's/[.]/0/g' )
211 fi
212
213 echoFunc "Current installed version normalised is: $currentinstalledvernorm"
214 if [ ${latestvernorm} = ${currentinstalledvernorm} ]; then
215 exitFunc 0 "No update needed as ${currentinstalledapp} ${currentinstalledvernorm} is current version"
216 fi
217 fi
218
219
220 # Build URL and dmg file name
221 CRCurrVersNormalized=$( echo $latestver | sed -e 's/[.]//g' )
222 echoFunc "CRCurrVersNormalized: $CRCurrVersNormalized"
223 url1="https:"
224 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/'`
225 url=`echo "${url1}${url2}"`
226 echoFunc "Latest version of the URL is: $url"
227 dmgfile="Citrix_work_${CRCurrVersNormalized}.dmg"
228
229 # Compare the two versions, if they are different or Citrix Workspace is not present then download and install the new version.
230 if [ "${currentinstalledvernorm}" != "${latestvernorm}" ]
231 then
232 echoFunc "Current Installed Workspace version: ${currentinstalledapp} ${currentinstalledvernorm}"
233 echoFunc "Available Workspace version : ${latestver} => ${currentinstalledvernorm}"
234 echoFunc "Downloading newer version."
235 curl -s -o /tmp/${dmgfile} ${url}
236 case $? in
237 0)
238 echoFunc "Checking if the file exists after downloading."
239 if [ -e "/tmp/${dmgfile}" ]; then
240 WorkspaceFileSize=$(du -k "/tmp/${dmgfile}" | cut -f 1)
241 echoFunc "Downloaded File Size: $WorkspaceFileSize kb"
242 fi
243 echoFunc "Checking if Workspace is running one last time before we install"
244 #WorkspaceRunningCheck
245 echoFunc "Mounting installer disk image."
246 hdiutil attach /tmp/${dmgfile} -nobrowse -quiet
247 echoFunc "Installing..."
248 echo "$(date +"%a %b %d %T") Installing Citrix Workspace v$latestver" >> /var/log/CitrixWorkspaceInstall.log
249 /usr/sbin/installer -pkg "/Volumes/Citrix Workspace/Install Citrix Workspace.pkg" -target / >> /var/log/CitrixWorkspaceInstall.log # > /dev/null
250
251 sleep 10
252 echoFunc "Unmounting installer disk image."
253 /sbin/umount /Volumes/Cit*
254 sleep 10
255 echoFunc "Deleting disk image."
256 rm /tmp/${dmgfile}
257
258 sleep 10
259 #double check to see if the new version got update
260 if [ -e "/Applications/Citrix Workspace.app" ]
261 then
262 newlyinstalledver=`/usr/bin/defaults read /Applications/Citrix Workspace.app/Contents/Info CFBundleShortVersionString`
263 echoFunc "Newly installed version is: $newlyinstalledver"
264
265 if [[ ${newlyinstalledver} =~ ^[0-9]{2}.[0-9]{2}.[0-9]{0,2}$ ]];
266 then
267 newlyinstalledvernorm=$( echo $newlyinstalledver | sed -e 's/[.]//g' )
268 newlyinstalledvernorm=${newlyinstalledvernorm:0:4}
269 else
270 # Missing minor version so we’ll add it here.
271 newlyinstalledvernorm=${newlyinstalledver:0:4}
272 newlyinstalledvernorm=$( echo $newlyinstalledvernorm | sed -e 's/[.]/0/g' )
273 fi
274
275 if [ "${latestvernorm}" = "${newlyinstalledvernorm}" ]
276 then
277 echoFunc "SUCCESS: Citrix Workspace has been updated to version ${newlyinstalledvernorm}, issuing JAMF recon command"
278 jamf recon
279 if [ $WorkspaceProcRunning -eq 1 ]
280 then
281 /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
282 fi
283 exitFunc 0 "${newlyinstalledvernorm}"
284 else
285 exitFunc 3 "${currentinstalledapp} ${currentinstalledvernorm}"
286 fi
287 else
288 exitFunc 3 "${currentinstalledapp} ${currentinstalledvernorm}"
289 fi
290 ;;
291 *)
292 echoFunc "Curl function failed on download! Error: $?. Review error codes here: https://curl.haxx.se/libcurl/c/libcurl-errors.html"
293 ;;
294 esac
295 else
296 # If Citrix Workspace is up to date already, just log it and exit.
297 exitFunc 0 "No update needed as ${currentinstalledapp} ${currentinstalledvernorm} is current version"
298 fi
299else
300 # This script is for Intel Macs only.
301 exitFunc 5
302fi

Forum|alt.badge.img+3
  • New Contributor
  • 4 replies
  • March 20, 2019

Just saw someone else beat me to it


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings