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 2520 by niro, Mon Sep 14 12:14:34 2015 UTC revision 2525 by niro, Mon Sep 14 13:49:29 2015 UTC
# Line 3  Line 3 
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  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  source ${MCORE_LIBDIR}/include/common.global.class
9  source ${MCORE_LIBDIR}/include/daemon.global.class  source ${MCORE_LIBDIR}/include/daemon.global.class
10  source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class  source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
# Line 12  source ${MCORE_LIBDIR}/include/mysqlfunc Line 14  source ${MCORE_LIBDIR}/include/mysqlfunc
14  : ${STOREFRONT_PASS=""}  : ${STOREFRONT_PASS=""}
15  : ${STOREFRONT_DOMAIN=""}  : ${STOREFRONT_DOMAIN=""}
16    
17  # get default store  export IMPORTED_IDS=""
18  if [[ -z ${STOREFRONT_STORE} ]]  
19  then  is_not_an_import_id()
20   export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}"  {
21  fi   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 ${STOREFRONT_STORE} ]] && export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}"
37    [[ -z ${STOREFRONT_USER} ]] && export STOREFRONT_USER="${MCORE_STOREFRONT_USER}"
38    [[ -z ${STOREFRONT_PASS} ]] && export STOREFRONT_PASS="${MCORE_STOREFRONT_PASS}"
39    [[ -z ${STOREFRONT_DOMAIN} ]] && export STOREFRONT_DOMAIN="${MCORE_STOREFRONT_DOMAIN}"
40    
41  if ! storebrowse &> /dev/null  if ! storebrowse &> /dev/null
42  then  then
# Line 34  then Line 54  then
54   pidof storebrowse > /dev/null && killall storebrowse   pidof storebrowse > /dev/null && killall storebrowse
55    
56   # register eula and add default store   # register eula and add default store
57   xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}"   xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}" > /dev/null
58  fi  fi
59    
60  # get all sessions  # get all sessions
# Line 46  else Line 66  else
66   [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}"   [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}"
67   [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}"   [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}"
68   [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}"   [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}"
69   SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE})   SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE} 2> /dev/null)
70     if [[ $? != 0 ]]
71     then
72     echo "could not retrieve session list"
73     exit 1
74     fi
75    
76   # exclude the desktop session, which is always the first   # exclude the desktop session, which is always the first
77   declare -i counter=0   declare -i counter=0
78   echo "${SESSION_LIST}" | while read line   while read line
79   do   do
80   if [[ ${counter} -gt 0 ]]   if [[ ${counter} -gt 0 ]]
81   then   then
82   session=$(echo ${line} | cut -d"'" -f 2)   session=$(echo ${line} | cut -d"'" -f 2)
83   description=$(echo ${line} | cut -d"'" -f 4)   description=$(echo ${line} | cut -d"'" -f 4)
84   echo "Session: '${session}' -> Description '${description}'"   decho "Session: '${session}' -> Description '${description}'"
85    
86     # import or update db entry
87     id=$(mysqldo "select id from values_storefront_session where session='${session}';")
88     if [[ -z ${id} ]]
89     then
90     mysqldo "insert into values_storefront_session (session,description,enabled) values('${session}','${description}','1');"
91     else
92     mysqldo "update values_storefront_session set session='${session}',description='${description}',enabled='1' where id='${id}';"
93     fi
94    
95     # get and save id
96     id=$(mysqldo "select id from values_storefront_session where session='${session}';")
97     export IMPORTED_IDS+=" ${id}"
98   fi   fi
99   (( counter++ ))   (( counter++ ))
100     done << EOF
101    $(echo "${SESSION_LIST}")
102    EOF
103    
104     # now disable all other ids in the database
105     DATABASE_IDS=$(mysqldo "select id from values_storefront_session")
106     for id in ${DATABASE_IDS}
107     do
108     if is_not_an_import_id "${id}"
109     then
110     # disable this one, not imported=not existing on the storefront-server in the moment
111     mysqldo "update values_storefront_session set enabled='0' where id='${id}';"
112     fi
113   done   done
114  fi  fi

Legend:
Removed from v.2520  
changed lines
  Added in v.2525