Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2511 by niro, Mon Sep 14 09:55:43 2015 UTC revision 2522 by niro, Mon Sep 14 13:16:02 2015 UTC
# Line 2  Line 2 
2    
3  MCORE_LIBDIR="@@MCORE_LIBDIR@@"  MCORE_LIBDIR="@@MCORE_LIBDIR@@"
4  source @@SYSCONFDIR@@/mcore/mcore.conf  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  source ${MCORE_LIBDIR}/include/common.global.class
8  source ${MCORE_LIBDIR}/include/daemon.global.class  source ${MCORE_LIBDIR}/include/daemon.global.class
9    source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
10    
11  if [ ! -d ~/.ICAClient ]  : ${STOREFRONT_STORE=""}
12  then  : ${STOREFRONT_USER=""}
13   install -d ~/.ICAClient  : ${STOREFRONT_PASS=""}
14  fi  : ${STOREFRONT_DOMAIN=""}
15    
16    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  if [ ! -f ~/.ICAClient ]  # get default store
35    if [[ -z ${STOREFRONT_STORE} ]]
36  then  then
37   touch ~/.ICAClient/.eula_accepted   export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}"
38  fi  fi
39    
40  if ! storebrowse > /dev/null  if ! storebrowse &> /dev/null
41  then  then
42   if [ -d ~/.ICAClient/.tmp ]   if [ -d ~/.ICAClient ]
43   then   then
44   rm -r ~/ICAClient/.tmp   rm -r ~/.ICAClient
45   fi   fi
46    
47     install -d ~/.ICAClient
48     touch ~/.ICAClient/.eula_accepted
49    
50   # kill running instances   # kill running instances
51   pidof AuthServiceDaemon > /dev/null && killall AuthServiceDaemon   pidof AuthManagerDaemon > /dev/null && killall AuthManagerDaemon
52   pidof ServiceRecord > /dev/null && killall ServiceRecord   pidof ServiceRecord > /dev/null && killall ServiceRecord
53   pidof storebrowse > /dev/null && killall storebrowse   pidof storebrowse > /dev/null && killall storebrowse
54    
55   # register eula   # register eula and add default store
56   xvfb-run -a -s "-extension RANDR" storebrowse   xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}" > /dev/null
57  fi  fi
58    
59  # get all sessions of default store  # get all sessions
60  export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}"  if [[ -z $(storebrowse -l | grep -i ${STOREFRONT_STORE}) ]]
61  ${MCORE_LIBDIR}/storefront-resolver  then
62     echo "Store ${STOREFRONT_STORE} unknown, perhaps not added. Run 'rm -r ~/.ICAClient'."
63    else
64     OPT=""
65     [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}"
66     [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}"
67     [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}"
68     SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE} 2> /dev/null)
69     if [[ $? != 0 ]]
70     then
71     echo "could not retrieve session list"
72     exit 1
73     fi
74    
75     # exclude the desktop session, which is always the first
76     declare -i counter=0
77     while read line
78     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    
85     # import or update db entry
86     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    
94     # get and save id
95     id=$(mysqldo "select id from values_storefront_session where session='${session}';")
96     export IMPORTED_IDS+=" ${id}"
97     fi
98     (( counter++ ))
99     done << EOF
100    $(echo "${SESSION_LIST}")
101    EOF
102    
103     # now disable all other ids in the database
104     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    fi

Legend:
Removed from v.2511  
changed lines
  Added in v.2522