#!/bin/bash MCORE_LIBDIR="@@MCORE_LIBDIR@@" source @@SYSCONFDIR@@/mcore/mcore.conf source @@SYSCONFDIR@@/mcore/citrix.conf source @@SYSCONFDIR@@/mcore/control.conf source ${MCORE_LIBDIR}/include/common.global.class source ${MCORE_LIBDIR}/include/daemon.global.class source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class : ${STOREFRONT_STORE=""} : ${STOREFRONT_USER=""} : ${STOREFRONT_PASS=""} : ${STOREFRONT_DOMAIN=""} # get default store if [[ -z ${STOREFRONT_STORE} ]] then export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}" fi if ! storebrowse &> /dev/null then if [ -d ~/.ICAClient ] then rm -r ~/.ICAClient fi install -d ~/.ICAClient touch ~/.ICAClient/.eula_accepted # kill running instances pidof AuthManagerDaemon > /dev/null && killall AuthManagerDaemon pidof ServiceRecord > /dev/null && killall ServiceRecord pidof storebrowse > /dev/null && killall storebrowse # register eula and add default store xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}" fi # get all sessions if [[ -z $(storebrowse -l | grep -i ${STOREFRONT_STORE}) ]] then echo "Store ${STOREFRONT_STORE} unknown, perhaps not added. Run 'rm -r ~/.ICAClient'." else OPT="" [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}" [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}" [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}" SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE}) if [[ $? != 0 ]] then echo "could not retrieve session list" exit 1 fi # exclude the desktop session, which is always the first declare -i counter=0 IMPORTED_IDS="" echo "${SESSION_LIST}" | while read line do if [[ ${counter} -gt 0 ]] then session=$(echo ${line} | cut -d"'" -f 2) description=$(echo ${line} | cut -d"'" -f 4) echo "Session: '${session}' -> Description '${description}'" # import or update db entry mysqldo "insert into values_storefront_session (session,description,enabled) values('${session}','${description}','1') on duplicate key update session='${session}',description='${description}',enabled='1';" # get and save id id=$(mysqldo "select id from values_storefront_session where session='${session}';") IMPORTED_IDS+=" ${id}" fi (( counter++ )) done # now disable all other ids in the database fi