Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2526 - (show annotations) (download)
Mon Sep 14 14:56:37 2015 UTC (8 years, 8 months ago) by niro
File size: 2423 byte(s)
-initial citrix-cron script
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/citrix-enumerate.conf
7 source @@SYSCONFDIR@@/mcore/control.conf
8 source ${MCORE_LIBDIR}/include/common.global.class
9 source ${MCORE_LIBDIR}/include/daemon.global.class
10 source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
11
12 : ${CITRIX_BROWSER=""}
13 : ${CITRIX_USER=""}
14 : ${CITRIX_PASS=""}
15 : ${CITRIX_DOMAIN=""}
16
17 export IMPORTED_IDS=""
18
19 is_not_an_import_id()
20 {
21 local id="$1"
22 local entry
23
24 for entry in ${IMPORTED_IDS}
25 do
26 if [[ ${entry} = ${id} ]]
27 then
28 return 1
29 fi
30 done
31
32 return 0
33 }
34
35 # get default settings from configs
36 [[ -z ${CITRIX_BROWSER} ]] && export CITRIX_BROWSER="${PNABROWSE_CITRIX_BROWSER}"
37 [[ -z ${CITRIX_USER} ]] && export CITRIX_USER="${MCORE_CITRIX_USER}"
38 [[ -z ${CITRIX_PASS} ]] && export CITRIX_PASS="${MCORE_CITRIX_PASS}"
39 [[ -z ${CITRIX_DOMAIN} ]] && export CITRIX_DOMAIN="${MCORE_CITRIX_DOMAIN}"
40
41 OPT=""
42 [[ -n ${CITRIX_USER} ]] && OPT+=" -U ${CITRIX_USER}"
43 [[ -n ${CITRIX_PASS} ]] && OPT+=" -P ${CITRIX_PASS}"
44 [[ -n ${CITRIX_DOMAIN} ]] && OPT+=" -D ${CITRIX_DOMAIN}"
45 SESSION_LIST=$(pnabrowse -A ${OPT} ${CITRIX_BROWSER} 2> /dev/null)
46 if [[ $? != 0 ]]
47 then
48 echo "could not retrieve session list"
49 exit 1
50 fi
51
52 # exclude the desktop session, which is always the first
53 declare -i counter=0
54 while read line
55 do
56 if [[ ${counter} -gt 0 ]]
57 then
58 session=$(echo ${line} | cut -d"'" -f 2)
59 description=""
60
61 # import or update db entry
62 id=$(mysqldo "select id from values_citrix_session where session='${session}';")
63 if [[ -z ${id} ]]
64 then
65 mysqldo "insert into values_citrix_session (session,description,enabled) values('${session}','${description}','1');"
66 else
67 mysqldo "update values_citrix_session set session='${session}',description='${description}',enabled='1' where id='${id}';"
68 fi
69
70 # get and save id
71 id=$(mysqldo "select id from values_citrix_session where session='${session}';")
72 export IMPORTED_IDS+=" ${id}"
73 fi
74 (( counter++ ))
75 done << EOF
76 $(echo "${SESSION_LIST}")
77 EOF
78
79 # now disable all other ids in the database
80 DATABASE_IDS=$(mysqldo "select id from values_citrix_session")
81 for id in ${DATABASE_IDS}
82 do
83 if is_not_an_import_id "${id}"
84 then
85 # disable this one, not imported=not existing on the storefront-server in the moment
86 mysqldo "update values_citrix_session set enabled='0' where id='${id}';"
87 fi
88 done