Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-cron.in
Parent Directory | Revision Log
Revision 2522 -
(hide annotations)
(download)
Mon Sep 14 13:16:02 2015 UTC (8 years, 8 months ago) by niro
File size: 3023 byte(s)
Mon Sep 14 13:16:02 2015 UTC (8 years, 8 months ago) by niro
File size: 3023 byte(s)
-fixed session import into database and disable all non-imported sessions, because they do not exist on the storefront-server and are not available for clients
1 | niro | 2511 | #!/bin/bash |
2 | |||
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" | ||
4 | source @@SYSCONFDIR@@/mcore/mcore.conf | ||
5 | niro | 2514 | source @@SYSCONFDIR@@/mcore/citrix.conf |
6 | niro | 2521 | source @@SYSCONFDIR@@/mcore/control.conf |
7 | niro | 2511 | source ${MCORE_LIBDIR}/include/common.global.class |
8 | niro | 2515 | source ${MCORE_LIBDIR}/include/daemon.global.class |
9 | niro | 2514 | source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class |
10 | niro | 2511 | |
11 | niro | 2514 | : ${STOREFRONT_STORE=""} |
12 | : ${STOREFRONT_USER=""} | ||
13 | : ${STOREFRONT_PASS=""} | ||
14 | : ${STOREFRONT_DOMAIN=""} | ||
15 | niro | 2511 | |
16 | niro | 2522 | export IMPORTED_IDS="" |
17 | |||
18 | is_not_an_import_id() | ||
19 | { | ||
20 | local id="$1" | ||
21 | local entry | ||
22 | |||
23 | for entry in ${IMPORTED_IDS} | ||
24 | do | ||
25 | if [[ ${entry} = ${id} ]] | ||
26 | then | ||
27 | return 1 | ||
28 | fi | ||
29 | done | ||
30 | |||
31 | return 0 | ||
32 | } | ||
33 | |||
34 | niro | 2514 | # get default store |
35 | if [[ -z ${STOREFRONT_STORE} ]] | ||
36 | niro | 2511 | then |
37 | niro | 2514 | export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}" |
38 | niro | 2511 | fi |
39 | |||
40 | niro | 2517 | if ! storebrowse &> /dev/null |
41 | niro | 2511 | then |
42 | niro | 2514 | if [ -d ~/.ICAClient ] |
43 | niro | 2511 | then |
44 | niro | 2516 | rm -r ~/.ICAClient |
45 | niro | 2511 | fi |
46 | |||
47 | niro | 2514 | install -d ~/.ICAClient |
48 | touch ~/.ICAClient/.eula_accepted | ||
49 | |||
50 | niro | 2511 | # kill running instances |
51 | niro | 2517 | pidof AuthManagerDaemon > /dev/null && killall AuthManagerDaemon |
52 | niro | 2511 | pidof ServiceRecord > /dev/null && killall ServiceRecord |
53 | pidof storebrowse > /dev/null && killall storebrowse | ||
54 | |||
55 | niro | 2514 | # register eula and add default store |
56 | niro | 2522 | xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}" > /dev/null |
57 | niro | 2511 | fi |
58 | |||
59 | niro | 2514 | # get all sessions |
60 | if [[ -z $(storebrowse -l | grep -i ${STOREFRONT_STORE}) ]] | ||
61 | then | ||
62 | echo "Store ${STOREFRONT_STORE} unknown, perhaps not added. Run 'rm -r ~/.ICAClient'." | ||
63 | else | ||
64 | OPT="" | ||
65 | niro | 2517 | [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}" |
66 | [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}" | ||
67 | [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}" | ||
68 | niro | 2522 | SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE} 2> /dev/null) |
69 | niro | 2521 | if [[ $? != 0 ]] |
70 | then | ||
71 | echo "could not retrieve session list" | ||
72 | exit 1 | ||
73 | fi | ||
74 | niro | 2518 | |
75 | # exclude the desktop session, which is always the first | ||
76 | declare -i counter=0 | ||
77 | niro | 2522 | while read line |
78 | niro | 2518 | do |
79 | if [[ ${counter} -gt 0 ]] | ||
80 | then | ||
81 | session=$(echo ${line} | cut -d"'" -f 2) | ||
82 | description=$(echo ${line} | cut -d"'" -f 4) | ||
83 | echo "Session: '${session}' -> Description '${description}'" | ||
84 | niro | 2521 | |
85 | # import or update db entry | ||
86 | niro | 2522 | id=$(mysqldo "select id from values_storefront_session where session='${session}';") |
87 | if [[ -z ${id} ]] | ||
88 | then | ||
89 | mysqldo "insert into values_storefront_session (session,description,enabled) values('${session}','${description}','1');" | ||
90 | else | ||
91 | mysqldo "update values_storefront_session set session='${session}',description='${description}',enabled='1' where id='${id}';" | ||
92 | fi | ||
93 | niro | 2521 | |
94 | # get and save id | ||
95 | id=$(mysqldo "select id from values_storefront_session where session='${session}';") | ||
96 | niro | 2522 | export IMPORTED_IDS+=" ${id}" |
97 | niro | 2518 | fi |
98 | (( counter++ )) | ||
99 | niro | 2522 | done << EOF |
100 | $(echo "${SESSION_LIST}") | ||
101 | EOF | ||
102 | niro | 2521 | |
103 | # now disable all other ids in the database | ||
104 | niro | 2522 | DATABASE_IDS=$(mysqldo "select id from values_storefront_session") |
105 | for id in ${DATABASE_IDS} | ||
106 | do | ||
107 | if is_not_an_import_id "${id}" | ||
108 | then | ||
109 | # disable this one, not imported=not existing on the storefront-server in the moment | ||
110 | mysqldo "update values_storefront_session set enabled='0' where id='${id}';" | ||
111 | fi | ||
112 | done | ||
113 | niro | 2514 | fi |