Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-cron.in
Parent Directory | Revision Log
Revision 2519 -
(hide annotations)
(download)
Mon Sep 14 12:12:48 2015 UTC (8 years, 8 months ago) by niro
File size: 2320 byte(s)
Mon Sep 14 12:12:48 2015 UTC (8 years, 8 months ago) by niro
File size: 2320 byte(s)
-import session to mysql database
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 | 2519 | 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 | 2514 | # get default store |
17 | if [[ -z ${STOREFRONT_STORE} ]] | ||
18 | niro | 2511 | then |
19 | niro | 2514 | export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}" |
20 | niro | 2511 | fi |
21 | |||
22 | niro | 2517 | if ! storebrowse &> /dev/null |
23 | niro | 2511 | then |
24 | niro | 2514 | if [ -d ~/.ICAClient ] |
25 | niro | 2511 | then |
26 | niro | 2516 | rm -r ~/.ICAClient |
27 | niro | 2511 | fi |
28 | |||
29 | niro | 2514 | install -d ~/.ICAClient |
30 | touch ~/.ICAClient/.eula_accepted | ||
31 | |||
32 | niro | 2511 | # kill running instances |
33 | niro | 2517 | pidof AuthManagerDaemon > /dev/null && killall AuthManagerDaemon |
34 | niro | 2511 | pidof ServiceRecord > /dev/null && killall ServiceRecord |
35 | pidof storebrowse > /dev/null && killall storebrowse | ||
36 | |||
37 | niro | 2514 | # register eula and add default store |
38 | xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}" | ||
39 | niro | 2511 | fi |
40 | |||
41 | niro | 2514 | # 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 | niro | 2517 | [[ -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 | niro | 2519 | if [[ $? != 0 ]] |
52 | then | ||
53 | echo "could not retrieve session list" | ||
54 | exit 1 | ||
55 | fi | ||
56 | niro | 2518 | |
57 | # exclude the desktop session, which is always the first | ||
58 | declare -i counter=0 | ||
59 | niro | 2519 | IMPORTED_IDS="" |
60 | niro | 2518 | 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 | niro | 2519 | |
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 | niro | 2518 | fi |
75 | (( counter++ )) | ||
76 | done | ||
77 | niro | 2519 | |
78 | # now disable all other ids in the database | ||
79 | |||
80 | niro | 2514 | fi |