# $Id$ provide citrix ica # needs fluxbox! require fluxbox basic-video # citrix global config include @@SYSCONFDIR@@/mcore/citrix.conf help_citrix_serverlist() { mecho "get citrix.serverlist [action]" mecho " Shows all hosts added on the serverlist." mecho " [actions]:" mecho " print - prints local configured serverlist" mecho " query - get serverlist of the farm from given [server]" mecho mecho "set citrix.serverlist [action] [host]" mecho " Adds or deletes a server from the ica serverlist." mecho " [actions]:" mecho " add - adds a server" mecho " del - deletes a server" mecho " auto - queries given [server] for the serverlist and adds all of them" mecho mecho " host - dns hostname or ip of the server" mecho mecho " If no [host] was given, all entries are deleted." } help_citrix_session() { mecho "get citrix.session" mecho " Shows all configured ICA sessions" mecho " print - prints all local configured sessions" mecho " query - get sessionlist of the farm from given [server]" mecho mecho "set citrix.session [action] [name] [session] [mode] [user] [domain] [password]" mecho " Adds or delets a ICA session." mecho " Available actions:" mecho " add - adds a new ica session" mecho " del - deletes ica session with file name [file]" mecho " if no [file] given, all sessions will be deleted" mecho mecho " Available modes:" mecho " fullscreen - fullscreen session" mecho " seamless - seamless windows session" mecho " *x* - windowed session with given resolution" mecho " any resonable resolution is fine like:" mecho " 1024x768, 1280x1024, 1440x900 etc" mecho mecho " session - name of the Citrix session" mecho " user - user inside the session - optional" mecho " domain - logon domain of the user - optional" mecho " password - password of the user - optional" } set_citrix_session() { local action="$1" local name="$2" local session="$3" local mode="$4" local user="$5" local domain="$6" local password="$7" local serverlist local server local server_num local icafile local CONFIG local i [[ -z ${action} ]] && help_citrix_session && return 1 [[ -z ${name} ]] && help_citrix_session && return 1 case "${action}" in add) # action 'add' need mode too [[ -z ${mode} ]] && help_citrix_session && return 1 # and session [[ -z ${session} ]] && help_citrix_session && return 1 # other sanity checks case "${mode}" in fullscreen) ;; seamless) ;; *x*) ;; *) help_citrix_session && return 1 esac icafile="${MCORE_CONFIG_PATH}/citrix/ica/${name}.ica" CONFIG="${MROOT}/${icafile}" clearconfig addconfig '[WFClient]' addconfig 'Version=2' serverlist=$(NOCOLORS=true get_citrix_serverlist) declare -i i=0 for server in ${serverlist} do (( i++ )) server_num="${i}" [[ ${i} -eq 1 ]] && server_num="" addconfig "TcpBrowserAddress${server_num}=${server}" done addconfig 'ScreenPercent=0' addconfig '[ApplicationServers]' addconfig "${session}=" addconfig "[${session}]" addconfig "Address=${session}" addconfig "InitialProgram=#${session}" # mapping table xorg -> citrix # citrix 1 = 16 colors # citrix 2 = 256 colors # citrix 4 = 16 bit # citrix 8 = 32 bit # try always 16 bit addconfig "DesiredColor=4" addconfig 'TransportDriver=TCP/IP' addconfig 'WinStationDriver=ICA 3.0' [[ -n ${user} ]] && addconfig "Username=${user}" [[ -n ${domain} ]] && addconfig "Domain=${domain}" [[ -n ${password} ]] && addconfig "ClearPassword=${password}" # use the right display settings case "${mode}" in # fullscreen mode fullscreen) addconfig 'UseFullScreen=Yes' addconfig 'NoWindowManager=True' addconfig "DesiredHRES=65535" addconfig "DesiredVRES=65535" ;; # seamless window mode seamless) addconfig 'TWIMode=On' ;; # a desired resolution *x*) addconfig "DesiredHRES=${mode%x*}" addconfig "DesiredVRES=${mode#*x}" ;; esac # generate fluxbox menu entry set_fluxbox_menuitem add "${name}" "wfica ${icafile}" ;; del) if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica ] then rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica set_fluxbox_menuitem del "${name}" elif [[ -z ${file} ]] then # delete all items, needed to loop through every session # or we delete *all* fluxbox menuitem too for i in $(find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica -type f) do rm ${i} set_fluxbox_menuitem del "$(basename ${i} .ica)" done fi ;; *) help_citrix_session && return 1 ;; esac } get_citrix_session() { local action="$1" local server="$2" local sessionlist local sessioncount local i local exclude [[ -z ${action} ]] && help_citrix_serverlist && return 1 case "${action}" in print) list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica ;; query) [[ -n ${PNABROWSE_EXECUTABLE} ]] || eecho "\$PNABROWSE_EXECUTABLE not defined" [[ -n ${PNABROWSE_CITRIX_BROWSER} ]] || eecho "\$PNABROWSE_CITRIX_BROWSER not defined" if [ -x ${MROOT}/opt/ica-client/util/pnabrowse ] then if [[ -n ${PNABROWSE_SESSION_EXCLUDE} ]] then exclude="| grep -v '${PNABROWSE_SESSION_EXCLUDE}'" fi sessionlist=( $(${MROOT}/${PNABROWSE_EXECUTABLE} -A "${PNABROWSE_CITRIX_BROWSER}" ${exclude}) ) sessioncount="${#sessionlist[*]}" for (( i=0; i