Scripts: Citrix - IGEL-Community/IGEL-Community.github.io GitHub Wiki
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]+$ ]] ](/IGEL-Community/IGEL-Community.github.io/wiki/|-[[-$TIMEOUT--eq-0-) && TIMEOUT=60
INCREMENT=$2 ; [ ! $INCREMENT =~ ^[0-9]+$ ]] ](/IGEL-Community/IGEL-Community.github.io/wiki/|-[[-$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