Citrix Receiver fails to install via Casper 8.70

mthakur
Contributor

Citrix Receiver for Mac.pkg v11.8.2.
JAMF Casper 8.70
OSX 10.8.5

When I try to install Citrix Receiver for Mac via JAMF Casper, the Citrix-provided postinstall script fails:

$ cat /Library/Logs/ReceiverInstall.log Starting install at Tue Jan 7 03:20:04 EST 2014 Dumping environment: INSTALLER_TEMP=/private/tmp/PKInstallSandbox.aRXFDY/tmp DSTVOLUME=/ TMPDIR=/private/tmp/PKInstallSandbox.aRXFDY/tmp DSTROOT=/ SCRIPT_NAME=postinstall SHARED_INSTALLER_TEMP=/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager-shared-tmp INSTALLER_SECURE_TEMP=/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/Cleanup At Startup/PKInstallSandboxManager/1.sandbox/Secure_Temp.1666402934 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec PWD=/private/tmp/PKInstallSandbox.aRXFDY/Scripts/com.citrix.ICAClient.gTiUVs INSTALL_PKG_SESSION_ID=com.citrix.ICAClient PACKAGE_PATH=/Library/Application Support/JAMF/Downloads/Install Citrix Receiver v11.8.2.pkg SHLVL=1 COMMAND_LINE_INSTALL=1 _=/usr/bin/printenv Dumping 4 Arguments: Arg 1: /Library/Application Support/JAMF/Downloads/Install Citrix Receiver v11.8.2.pkg Arg 2: / Arg 3: / Arg 4: / Extracting userName from Installing as user ConfigureAgent AM agent launchctl failed loading agent

The problem appears to be these lines in the Citrix-provided postinstall script:

#!/bin/bash # Uncomment set-x to get verbose logging in the console #set -x CITRIX="Citrix Receiver" DAZZLE_APPS_FOLDER="/Applications/Dazzle" DAZZLE_APPS_FOLDER_LEN=echo ${#DAZZLE_APPS_FOLDER} DAZZLE_APPS_FOLDER_LEN=$((DAZZLE_APPS_FOLDER_LEN + 1)) # +1 for the trailing slash # We need to know the real logged in user for # normal install - the user double click the installer # scripted install - the installer command is inside a script (both with and without sudo) # command line install - the user runs 'sudo installer' from the command line # Merc Server install - the installer is run from within an application with elevated permissions # $USER - okay for normal, but nothing else #not valid for a normal install # WriteLog $USERNAME # WriteLog $LOGNAME # WriteLog $(who -m) # WriteLog $(whoami) # WriteLog $(logname) # WriteLog $(id -un) # WriteLog $(id -urn) userName=$(stat -f "%Su" "$HOME")

It appears that the $HOME environment variable isn't being set when this pkg is installed via JAMF Casper.

So my questions are:

  1. Have any of you successfully deployed Citrix Receiver v11.8.2 via JAMF Casper via policy?
  2. Is the $HOME variable set and available to postinstall scripts during install?
  3. What workarounds would you suggest?

Thanks for any advice or assistance!

mthakur

17 REPLIES 17

mthakur
Contributor

Bump… anyone else having problems installing Citrix Receiver via JAMF Casper?

thoughton
New Contributor

How are you packaging the application? Or are you just dropping the package installer straight from the dmg provided by Citrix into Casper Admin? I'm currently testing this for our setup. I'll let you know how it goes.

Not applicable

I had noticed that version of Citrix Receiver prior to 11.8.2 installed fine straight from the .pkg, but that 11.8.2 was failing.

I used Composer (9.2) to snapshot Receiver 11.8.2 and have now distributed it successfully.

Chris_Hafner
Valued Contributor II

I have had both success and failure with the .pkg from Citrix. Though I haven't yet dived into it. All I see are generic errors in the casper logs. Though I do in fact also have successes.

mthakur
Contributor

Hi everyone, thanks for the responses.
I'm installing Citrix Receiver v11.8.2 directly from the pkg provided by Citrix.

I'm also filing a bug report with Citrix through my organization's support contact with Citrix.

This is because their postinstall shell script assumes the $HOME environment variable is set, but — and this is the error — the postinstall script fails when this variable isn't set, which it isn't, when installed via Casper.

For now, it seems the only workaround is, as pete_c says, to snapshot the package and repackage it through Composer.

Thanks, everyone.

thoughton
New Contributor

I can confirm that using Casper 9.21 and repackaging the Receiver 11.8.2 Install through Composer works without errors when installed on client machines. Using just the .pkg from the Receiver.dmg was generating errors, but actually installing. So I recommend repackaging through Composer.

sunny_s
New Contributor II

Useing Casper 9.22, to install Citrix Receiver 11.8.2 the following worked for me;
Use Composer to make a normal snapshot
Install Citrix Receiver, & customise any options in Receiver used for your site
Finish Composers snapshot & do some house cleaning of the source in Composer
Export as DMG, upload to JSS & set in JSS as "Fill existing user home directories (FEU)"
Run policy on test/client machine then reboot.
Test Citrix Receiver & should be able to login now.

Problem I had was that after Citrix Receiver installed via policy/Self Service, authentication to Citric service wouldn't work. This is because an authentication daemon was not running (where the Citrix installer launches this on finishing install, Jamf policy doesn't have this script), a reboot launches the daemon & authentication should then work.

globaldominatio
New Contributor II

Hi guys, So does it mean the only option is to reboot the Mac?
I tried to test manually, after deployment I manually ran the /usr/local/libexec/AuthManager_Mac/Contents/MacOS/AuthManager_Mac but it did not help. Anything else is suggested to make it work without a reboot?

mistacabbage
Contributor

I get the below error when having Citrix Receiver 11.9.15 in my imaging configuration. JSS is at 9.72.

from /private/var/log/jamf.log on the client Mac. I get emailed that an error occurred as well. Citrix Receiver seems to work just fine though.

Wed Jun 24 11:03:23 ltus227390 jamf[4889]: Installing Citrix Receiver 11.9.15_20150504.pkg...
Wed Jun 24 11:03:29 ltus227390 jamf[4889]: Installation failed. The installer reported: installer: Package name is Citrix Receiver
installer: Installing at base path /
installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)

hunter99
New Contributor

I get the same error as mistacabbage with Receiver 12. My JSS is also at 9.72. I did not have any errors with prior versions of Receiver.

I am going to do some more tinkering. The above errors came using the pkg directly from Citrix.

nessts
Valued Contributor II

make sure you check the install on boot drive box is checked if using this in imaging.

wmateo
Contributor

@hunter99 @mistacabbage were you guys able to determine the cause? This is happening to me also. Funny thing is when I trigger the policy manually on the client machine, it works fine. It's on the check-in trigger that I see this error.

wmateo
Contributor

@thoughton did you repackage this as a .pkg or .dmg?

joecurrin
New Contributor III

I stripped out a lot of the legacy code in the post installer. If your users are relatively up to date (in version 11). You don't need the version 10 conversion code in there.

wmateo
Contributor

@joecurrin did you output a DMG or .PKG from snapshot?

donmontalvo
Esteemed Contributor III

Easier than snapshooting, just pulled Citrix Receiver 12.1.0 (flat/signed PKG) into Composer, yanked the preinstallation/postinstallation scripts and deployed.

Worked like a charm, even though I'm wondering if the launchd item may have needed to be unloaded before overwriting. Didn't seem to get in the way of the application working correctly.

Here is the preinstallation script in 12.1.0:

#!/bin/bash

# Check to see if this is an upgrade. We do this by seeing if our
# package is already installed. pkgutil --pkg-info will return 0
# if it's installed and 1 if it is not. Installer will set the 
# INSTALL_PKG_SESSION_ID environment variable to the name of the
# package being installed, so we will just use that here instead
# of hard-coding it.
#
# If we see that our package is already installed, we create a
# flag file in the same directory as this script. That file will
# then be checked for existance by the postinstall script. It's
# too late to use pkgutil --pkg-info in the postinstall script because
# the package has already been installed by the time it gets called.
pkgutil --pkg-info $INSTALL_PKG_SESSION_ID
if [ $? -eq 0 ]; then
    touch "./IsUpgrade"
fi

Here is the postinstallation script in 12.1.0:

#!/bin/bash

# Uncomment set-x to get verbose logging in the console
#set -x

CITRIX="Citrix Receiver"
DAZZLE_APPS_FOLDER="/Applications/Dazzle"
DAZZLE_APPS_FOLDER_LEN=`echo ${#DAZZLE_APPS_FOLDER}`
DAZZLE_APPS_FOLDER_LEN=$((DAZZLE_APPS_FOLDER_LEN + 1)) # +1 for the trailing slash
APP_SUPPORT_DIR="$HOME/Library/Application Support/$CITRIX"


# We need to know the real logged in user for
# normal install - the user double click the installer
# scripted install - the installer command is inside a script (both with and without sudo)
# command line install - the user runs 'sudo installer' from the command line
# Merc Server install - the installer is run from within an application with elevated permissions
# $USER - okay for normal, but nothing else
#not valid for a normal install
#   WriteLog $USERNAME
#   WriteLog $LOGNAME
#   WriteLog $(who -m)
#   WriteLog $(whoami)
#   WriteLog $(logname)
#   WriteLog $(id -un)
#   WriteLog $(id -urn)

userName=$(stat -f "%Su" "$HOME")



# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
function WriteLog()
{
    echo "$@" >> "$HOME/Library/Logs/ReceiverInstall.log"
}

# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
function CheckError()
{
    local err=$?
    if [ $err -ne 0 ] ; then
        WriteLog "ERROR ($err): $1"
        exit 1
    fi
}



#----------------------------------------------------------------------------------------------
# ConfigureAgent the agent .
#
# Arg 1 name - The name under which this agent is to be installed,
#
function ConfigureAgent()
{
    plist_path="/Library/LaunchAgents/com.citrix.""$1"".plist"

# launchctl is fussy about the ownership and permissions on the launchd plists.
# This from the man page:
#   Note that per-user configuration files (LaunchAgents) must be owned by the user
#   loading them. All system-wide daemons (Launch-Daemons) must be owned by root.
#   Configuration files must not be group- or world-writable. These restrictions are in
#   place for security reasons, as allowing writability to a launchd configuration
#   file allows one to specify which executable will be launched.
#   Note that allowing non-root write access to the /System/Library/LaunchDaemons
#   directory WILL render your system unbootable.
#
    chown root:wheel "$plist_path"
    CheckError "Failed setting launchd plist ownership"

    chmod 644 "$plist_path"
    CheckError "Failed setting launchd plist permissions"

    # Load the  launchd plists. The unload is allowed to fail. launchctl has
    # to be run as the correct user if this was a user install, or as root
    # if this was a system install. If this was a system install then we
    # expect to be running as root anyway.

    sudo -u $userName launchctl unload -wF -S Aqua "$plist_path"
    sudo -u $userName launchctl load -wF -S Aqua "$plist_path"

    CheckError "launchctl failed loading agent"
}

#==============================================================================================
#  S C R I P T   S T A R T S   H E R E
#==============================================================================================

WriteLog "Starting install at $(date)"
WriteLog ""

# Dump the env
WriteLog "Dumping environment:"
printenv >> "$HOME/Library/Logs/ReceiverInstall.log"
WriteLog ""

# Dump the arguments
WriteLog "Dumping $# Arguments:"
for ((i=1;i<=$#;i++)); do
    WriteLog "  Arg $i: ${!i}"
done
WriteLog ""

WriteLog "Extracting userName from $HOME"
WriteLog "Installing as user $userName"

if [ -d "/usr/local/libexec" ]; then
    WriteLog "Setting permissions on /usr/local/libexec"
    sudo chmod 755 /usr/local/libexec
    CheckError "chmod failed for /usr/local/libexec"
else
    WriteLog "WARNING: /usr/local/libexec does not exist!"
fi

WriteLog "ConfigureAgent AM agent"
ConfigureAgent "AuthManager_Mac"

WriteLog "ConfigureAgent SRB agent"
ConfigureAgent "ServiceRecords"

WriteLog "ConfigureAgent ReceiverHelper agent"
ConfigureAgent "ReceiverHelper"

# Kernel Extension
OSX_VERSION=$(sw_vers -productVersion | awk -F '.' '{print $1 "." $2}')
KEXT_INSTALL_PATH="/Library/Extensions/CitrixGUSB.kext"
KEXT_LOAD_PATH="$KEXT_INSTALL_PATH"
WriteLog "OS X Version: $OSX_VERSION"
if [[ "$OSX_VERSION" == "10.8" ]]; then
    WriteLog "Copying $KEXT_INSTALL_PATH to /System/Library/Extensions"
    cp -R "$KEXT_INSTALL_PATH" "/System/Library/Extensions"
    CheckError "Kernel extension copy failed!"
    KEXT_INSTALL_PATH="/System$KEXT_INSTALL_PATH"
fi

WriteLog "Loading Generic USB kernel extension at: $KEXT_INSTALL_PATH"
/sbin/kextload "$KEXT_INSTALL_PATH"
CheckError "Generic USB kernel extension load failed!"

KEXT_ROOT_PATH=$(dirname $KEXT_INSTALL_PATH)
WriteLog "Updating boot cache for: $KEXT_ROOT_PATH"
touch "$KEXT_ROOT_PATH"

# Delete the old shared module directory
sudo rm -rf "/Users/Shared/Citrix/Modules"

# Remove older versions of the client (Version 10)
sudo rm -rf "/Applications/Citrix ICA Client/Citrix ICA Client Editor.app"
sudo rm -rf "/Applications/Citrix ICA Client/Citrix online plug-in.app"
sudo rm -rf "/Applications/Citrix ICA Client/Citrix ICA Client.app"
sudo rm -rf "/Applications/Citrix ICA Client/Citrix ICA EULA.rtf"
sudo rm -rf "/Applications/Citrix ICA Client/ReadMe.html"
sudo rm -rf "/Library/Receipts/Citrix ICA Client.pkg"
sudo rmdir "/Applications/Citrix ICA Client"

# Remove Version 11.0 (may need to move this to preflight)
sudo rm -rf  "/Applications/Citrix Dazzle.app"

# Remove Beta versions of the client (Version 11.2)
sudo rm -rf "/Library/Application Support/Citrix/XenDesktop Viewer.app"
sudo rm -rf "/Library/Application Support/Citrix/XenApp Viewer.app"

#Create app support directories
sudo mkdir -p "/Library/Application Support/Citrix"
sudo chmod 775 "/Library/Application Support/Citrix"
sudo -u $userName mkdir -p "$HOME/Library/Application Support/Citrix"

# Give the integration file everyone read/write so Receiver updater can remove it when done
sudo chmod -R a+rw "/Users/Shared/Citrix/Receiver Integration"

# Migrate older Config/Modules preferences (~/Library/Preferences/Citrix ICA Client) to the new location
sudo -u $userName mkdir -p "$APP_SUPPORT_DIR"
sudo -u $userName mv -n "$HOME/Library/Preferences/Citrix ICA Client/Config" "$APP_SUPPORT_DIR/Config"
sudo -u $userName mv -n "$HOME/Library/Preferences/Citrix ICA Client/Modules" "$APP_SUPPORT_DIR/Modules"
sudo -u $userName rm -rf "$HOME/Library/Preferences/Citrix ICA Client"

# If the Config/Modules/ViewerLogging.plist files don't exist, copy the defaults
if [ ! -e "$APP_SUPPORT_DIR/Config" ]; then
    WriteLog "Copying default Config file to: $APP_SUPPORT_DIR"
    sudo -u $userName cp "/Applications/Citrix Receiver.app/Contents/Helpers/Citrix Viewer.app/Contents/Resources/Config" "$APP_SUPPORT_DIR"
fi
if [ ! -e "$APP_SUPPORT_DIR/Modules" ]; then
    WriteLog "Copying default Modules file to: $APP_SUPPORT_DIR"
    sudo -u $userName cp "/Applications/Citrix Receiver.app/Contents/Helpers/Citrix Viewer.app/Contents/Resources/Modules" "$APP_SUPPORT_DIR"
fi
if [ ! -e "$APP_SUPPORT_DIR/ViewerLogging.plist" ]; then
    WriteLog "Copying default ViewerLogging.plist file to: $APP_SUPPORT_DIR"
    sudo -u $userName cp "/Applications/Citrix Receiver.app/Contents/Frameworks/ICAServices.framework/Resources/ViewerLogging.plist" "$APP_SUPPORT_DIR"
fi

# Migrate older subscriptions from /Applications/Dazzle
#
# This lovely bit of script will go through /Applications/Dazzle and it's subdirectories
# looking for subscriptions. They will get moved into ~/Applications in the same relative
# locations. Any non-subscription apps that are in /Applications/Dazzle will be left alone.
# After moving any subscriptions, all non-empty subdirectories of /Applications/Dazzle will
# be deleted. Finally, if /Applications/Dazzle is empty, it will be deleted as well.
UPGRADE_SUBS=0
SAVEIFS=$IFS
IFS=`echo -en "
"`
files=`sudo find "$DAZZLE_APPS_FOLDER" -type d -name "*.app"`
for f in $files; do
    plist="$f/Contents/Info"
    bundleID=`defaults read "$plist" CFBundleIdentifier`
    if [[ $bundleID == com.citrix.XenAppAlias-* || $bundleID == com.citrix.XenDesktopAlias-* ]]; then
        WriteLog "Found subscription at $f"
        relativePath=${f:DAZZLE_APPS_FOLDER_LEN}
        relativeDir=`dirname "$relativePath"`
        if [ ! -d "$HOME/Applications/$relativePath" ]; then
            WriteLog "   Migrating subscription $f to $HOME/Applications/$relativePath"
            sudo -u $USER mkdir -p "$HOME/Applications/$relativeDir"
            sudo -u $USER mv -n "$f" "$HOME/Applications/$relativeDir"
            UPGRADE_SUBS=1
        else
            WriteLog "   Subscription at $f already exists in $HOME/Applications/$relativePath"
            sudo rm -rf "$f"
        fi
    else
        WriteLog "App at $f is NOT a subscription"
    fi
done
IFS=$SAVEIFS
sudo find "/Applications/Dazzle" -type d -mindepth 1 -empty -delete
sudo rm -f "/Applications/Dazzle/.DS_Store"
sudo rmdir "/Applications/Dazzle"

# Remove older versions of the client (Version 11.2)
sudo rm -rf "/Applications/Citrix/Dazzle.app"
sudo rm -f "/Applications/Citrix/.DS_Store"
sudo rmdir "/Applications/Citrix"
sudo rm -rf "/Library/Application Support/Citrix/DockApplication.app"
sudo rm -rf "/Library/Application Support/Citrix/Citrix Online Web Plug-in.app"
sudo rm -rf "/Library/Application Support/Citrix/Desktop Viewer.app"
sudo rm -rf "/Library/Application Support/Citrix/Citrix Online Plug-in.app"
sudo rm -rf "/Library/Application Support/Citrix/DazzleMe.app"
sudo rm -rf "/Library/Application Support/Citrix/Uninstall Citrix Online Plug-in.app"
sudo rm -f "/Library/Application Support/Citrix/.DS_Store"
sudo rmdir "/Library/Application Support/Citrix"
sudo rm -rf "/Library/PreferencePanes/Citrix Online Plug-in.prefpane"
sudo rm -rf "/Library/Receipts/Install Citrix Online Plug-in.pkg"

# 11.2 was taken care of above. For 11.3 MAS, subscriptions are in the right place but
# they still need to be upgraded. If we didn't do any migrations for 11.2, check ~/Applications
# and see if there are any subscriptions there. If so, mark the flag so that they will
# get upgraded later.
if [ $UPGRADE_SUBS -eq 0 ]; then
    SAVEIFS=$IFS
    IFS=`echo -en "
"`
    files=`sudo -u $USER find "$HOME/Applications" -type d -name "*.app"`
    for f in $files; do
        plist="$f/Contents/Info"
        bundleID=`defaults read "$plist" CFBundleIdentifier`
        if [[ $bundleID == com.citrix.XenAppAlias-* || $bundleID == com.citrix.XenDesktopAlias-* ]]; then
            WriteLog "Found at least one subscription in ~/Applications..."
            UPGRADE_SUBS=1
            break
        fi
    done
    IFS=$SAVEIFS
fi

# Remove older versions of the client (Version 11.3)
sudo -u $USER rm -rf "$HOME/Library/Internet Plug-Ins/CitrixICAClientPlugIn.plugin"

# remove the older preferences (not sure -u required - check before next release)
sudo -u $USER rm -f "$HOME/Library/Preferences/com.citrix.ApplicationReconnect.plist"
sudo -u $USER rm -f "$HOME/Library/Preferences/com.citrix.Citrix_Dazzle.plist"
sudo -u $USER rm -f "$HOME/Library/Preferences/com.citrix.DockApplication.plist"
sudo -u $USER rm -f "$HOME/Library/Preferences/com.citrix.ICAClient.plist"
sudo -u $USER rm -f "$HOME"/Library/Preferences/com.citrix.XenAppAlias*
sudo -u $USER rm -f "$HOME"/Library/Preferences/com.citrix.XenDesktopAlias*
sudo -u $USER rm -f "$HOME/Library/Preferences/com.citrix.XenAppViewer.plist"
sudo -u $USER rm -f "$HOME/Library/Preferences/com.citrix.XenDesktopViewer.plist"
sudo -u $USER rm -f "$HOME/Library/Preferences/com.citrix.receiver.mas.plist"

# If FMD is installed, remove it now. The presense of the Uninstaller
# is used to determine if it should be removed.
FMD_IN_USE=0
FMD_DOCS_PATH="$HOME/ShareFile"
FMD_UNINSTALLER="/Applications/Citrix/FollowMeData/Uninstall ShareFile Plug-in.app/Contents/Resources/PreviledgedTool"
if [ -e "$FMD_UNINSTALLER" ]; then

    # FMD is installed... let's see if the user was actually using it. To do
    # this we check to see if ~/ShareFile exists and is not empty. Excluding
    # .DS_Store, of course.
    existingFMDData=$(sudo -u $USER find "$FMD_DOCS_PATH" -type f ( ! -iname ".DS_Store" ))
    if [ "$existingFMDData" != "" ]; then
        FMD_IN_USE=1
    fi

    WriteLog "FMD install detected. Uninstalling..."
    "$FMD_UNINSTALLER"
    WriteLog "FMD uninstall complete."
fi

# If this is an upgrade, the preinstall script will have created a
# flag file in the same directory as this script. Just checked for it's
# existance.
IS_UPGRADE=0
if [ -e "./IsUpgrade" ]; then
    IS_UPGRADE=1
fi

WriteLog "IS_UPGRADE=$IS_UPGRADE"
WriteLog "COMMAND_LINE_INSTALL=$COMMAND_LINE_INSTALL"
WriteLog "UPGRADE_SUBS=$UPGRADE_SUBS"
WriteLog "FMD_IN_USE=$FMD_IN_USE"

if [[ $IS_UPGRADE -ne 0 || "$COMMAND_LINE_INSTALL" != "" ]]; then
    RECEIVER_ARGS=""
    if [ $UPGRADE_SUBS -eq 1 ]; then
        WriteLog "Launching Receiver to upgrade subscriptions..."
        RECEIVER_ARGS="$RECEIVER_ARGS --upgrade-subs"
    fi
    if [ $FMD_IN_USE -eq 1 ]; then
        WriteLog "Launching Receiver to show FMD warning..."
        RECEIVER_ARGS="$RECEIVER_ARGS --show-fmd-warning"
    fi

    if [ "$RECEIVER_ARGS" != "" ]; then

        if [ "$COMMAND_LINE_INSTALL" != "" ]; then
            RECEIVER_ARGS="$RECEIVER_ARGS --quiet"
        fi

        # We have subscriptions that potentially need to be upgraded. Launch Receiver with the upgrade command-line
        WriteLog "Launching Receiver install step with command-line args: $RECEIVER_ARGS"
        sudo -u $userName "/Applications/Citrix Receiver.app/Contents/MacOS/Citrix Receiver" $RECEIVER_ARGS
        wait $!
        WriteLog "Receiver install step complete"
    fi
fi

exit 0
--
https://donmontalvo.com

kstrick
Contributor III

I was trying to debug their post-install script to try and fix it, but it's just not worth it.....
It's totally trying to do a bunch of things that are not kosher for a command line install.....
weak.
(works with a GUI install)

I just ripped out the scripts also.