Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-cron.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2521 - (show annotations) (download)
Mon Sep 14 12:15:12 2015 UTC (8 years, 7 months ago) by niro
File size: 2320 byte(s)
-import session to mysql database
1 #!/bin/bash
2
3 MCORE_LIBDIR="@@MCORE_LIBDIR@@"
4 source @@SYSCONFDIR@@/mcore/mcore.conf
5 source @@SYSCONFDIR@@/mcore/citrix.conf
6 source @@SYSCONFDIR@@/mcore/control.conf
7 source ${MCORE_LIBDIR}/include/common.global.class
8 source ${MCORE_LIBDIR}/include/daemon.global.class
9 source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
10
11 : ${STOREFRONT_STORE=""}
12 : ${STOREFRONT_USER=""}
13 : ${STOREFRONT_PASS=""}
14 : ${STOREFRONT_DOMAIN=""}
15
16 # get default store
17 if [[ -z ${STOREFRONT_STORE} ]]
18 then
19 export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}"
20 fi
21
22 if ! storebrowse &> /dev/null
23 then
24 if [ -d ~/.ICAClient ]
25 then
26 rm -r ~/.ICAClient
27 fi
28
29 install -d ~/.ICAClient
30 touch ~/.ICAClient/.eula_accepted
31
32 # kill running instances
33 pidof AuthManagerDaemon > /dev/null && killall AuthManagerDaemon
34 pidof ServiceRecord > /dev/null && killall ServiceRecord
35 pidof storebrowse > /dev/null && killall storebrowse
36
37 # register eula and add default store
38 xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}"
39 fi
40
41 # get all sessions
42 if [[ -z $(storebrowse -l | grep -i ${STOREFRONT_STORE}) ]]
43 then
44 echo "Store ${STOREFRONT_STORE} unknown, perhaps not added. Run 'rm -r ~/.ICAClient'."
45 else
46 OPT=""
47 [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}"
48 [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}"
49 [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}"
50 SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE})
51 if [[ $? != 0 ]]
52 then
53 echo "could not retrieve session list"
54 exit 1
55 fi
56
57 # exclude the desktop session, which is always the first
58 declare -i counter=0
59 IMPORTED_IDS=""
60 echo "${SESSION_LIST}" | while read line
61 do
62 if [[ ${counter} -gt 0 ]]
63 then
64 session=$(echo ${line} | cut -d"'" -f 2)
65 description=$(echo ${line} | cut -d"'" -f 4)
66 echo "Session: '${session}' -> Description '${description}'"
67
68 # import or update db entry
69 mysqldo "insert into values_storefront_session (session,description,enabled) values('${session}','${description}','1') on duplicate key update session='${session}',description='${description}',enabled='1';"
70
71 # get and save id
72 id=$(mysqldo "select id from values_storefront_session where session='${session}';")
73 IMPORTED_IDS+=" ${id}"
74 fi
75 (( counter++ ))
76 done
77
78 # now disable all other ids in the database
79
80 fi