Scripts: Citrix

falkheiland edited this page Mar 16, 2018 · 1 revision

Citrix StoreFront Idle Logoff Script

#!/bin/bash
#
# Daemon script to monitor and logoff Citrix StoreFront when there 
# is no active Citrix session running. The script is designed for 
# use with the native Citrix Receiver on IGEL Linux. The logic tests 
# for the first returned application/desktop returned from StoreFront 
# or Program Neighborhood (pnapp0_0) and if there is no active ICA 
# session, call pnlogoff. 
#
# If the IGEL is configured to authenticate against AD/LDAP, then 
# the script will also logoff the domain.  In such cases, it is 
# recommended that the Citrix StoreFront/XenApp Logoff be removed 
# from the IGEL desktop because Domain Logoff will accomplish the task.
# 
# The timeout and the frequency for which the StoreFront connection is 
# maintained can be passed to the command. These parameters are set in 
# seconds. If not added to the command line, an inactive the StoreFront 
# will timeout in 60 seconds.
#
# To implement the StoreFront connection monitor, copy this script to 
# /wfs/bin/ directory.  Add a Custom Application, and set the Application 
# to Autostart; no other start methods are recommended. Use setsid to 
# launch the script. As an example, the following will logoff StoreFront 
# after 120 seconds of inactivity:
#
#     setsid /wfs/bin/pnmonitor 120 2
#

TIMEOUT=$1 ; [[ ! $TIMEOUT =~ ^[0-9]+$ ]] || [[ $TIMEOUT -eq 0 ]] && TIMEOUT=60
INCREMENT=$2 ; [[ ! $INCREMENT =~ ^[0-9]+$ ]] || [[ $INCREMENT -eq 0 ]] && INCREMENT=2

echo "Connection timeout set to $TIMEOUT seconds."
echo "Timer increment set to $INCREMENT seconds."

while : ; do
[ ! $ACTIVE_SESSION ] && echo "Not logged into Citrix StoreFront..."
if [ -f /config/sessions/pnapp0_0 ] ; then
   TIMER=0
   ACTIVE_SESSION=`ps ax | grep wfica_orig | grep -v grep | head -n 1 | awk '{print $1}'`
   echo "Logged into Citrix StoreFront..."
   while [ -z "$ACTIVE_SESSION" ] ; do
      if [ "$TIMER" -ge "$TIMEOUT" ] ; then
         echo "Inactive Citrix logging off..."
         [ -f /config/sessions/pnapp0_0 ] && . /config/sessions/pnlogoff0
         [ "`get auth.login.krb5`" == "true" ] && /config/bin/setup_cmd /usr/bin/logoff
         sleep 2
         echo "Inactive Citrix logged off."
         break
      else
         ACTIVE_SESSION=`ps ax | grep wfica_orig | grep -v grep | head -n 1 | awk '{print $1}'`
         sleep "$INCREMENT" ; TIMER=$((TIMER+$INCREMENT))
         echo "Inactive Citrix timer running...$TIMER"
         [ ! -f /config/sessions/pnapp0_0 ] && break
      fi
   done
fi
sleep "$INCREMENT"
done
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.