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 2521 by niro, Mon Sep 14 12:15:12 2015 UTC revision 2522 by niro, Mon Sep 14 13:16:02 2015 UTC
# Line 13  source ${MCORE_LIBDIR}/include/mysqlfunc Line 13  source ${MCORE_LIBDIR}/include/mysqlfunc
13  : ${STOREFRONT_PASS=""}  : ${STOREFRONT_PASS=""}
14  : ${STOREFRONT_DOMAIN=""}  : ${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  # get default store  # get default store
35  if [[ -z ${STOREFRONT_STORE} ]]  if [[ -z ${STOREFRONT_STORE} ]]
36  then  then
# Line 35  then Line 53  then
53   pidof storebrowse > /dev/null && killall storebrowse   pidof storebrowse > /dev/null && killall storebrowse
54    
55   # register eula and add default store   # register eula and add default store
56   xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}"   xvfb-run -a -s "-extension RANDR" storebrowse -a "${STOREFRONT_STORE}" > /dev/null
57  fi  fi
58    
59  # get all sessions  # get all sessions
# Line 47  else Line 65  else
65   [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}"   [[ -n ${STOREFRONT_USER} ]] && OPT+=" -U ${STOREFRONT_USER}"
66   [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}"   [[ -n ${STOREFRONT_PASS} ]] && OPT+=" -P ${STOREFRONT_PASS}"
67   [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}"   [[ -n ${STOREFRONT_DOMAIN} ]] && OPT+=" -D ${STOREFRONT_DOMAIN}"
68   SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE})   SESSION_LIST=$(storebrowse -E ${OPT} ${STOREFRONT_STORE} 2> /dev/null)
69   if [[ $? != 0 ]]   if [[ $? != 0 ]]
70   then   then
71   echo "could not retrieve session list"   echo "could not retrieve session list"
# Line 56  else Line 74  else
74    
75   # exclude the desktop session, which is always the first   # exclude the desktop session, which is always the first
76   declare -i counter=0   declare -i counter=0
77   IMPORTED_IDS=""   while read line
  echo "${SESSION_LIST}" | while read line  
78   do   do
79   if [[ ${counter} -gt 0 ]]   if [[ ${counter} -gt 0 ]]
80   then   then
# Line 66  else Line 83  else
83   echo "Session: '${session}' -> Description '${description}'"   echo "Session: '${session}' -> Description '${description}'"
84    
85   # import or update db entry   # import or update db entry
86   mysqldo "insert into values_storefront_session (session,description,enabled) values('${session}','${description}','1') on duplicate key update session='${session}',description='${description}',enabled='1';"   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   # get and save id
95   id=$(mysqldo "select id from values_storefront_session where session='${session}';")   id=$(mysqldo "select id from values_storefront_session where session='${session}';")
96   IMPORTED_IDS+=" ${id}"   export IMPORTED_IDS+=" ${id}"
97   fi   fi
98   (( counter++ ))   (( counter++ ))
99   done   done << EOF
100    $(echo "${SESSION_LIST}")
101    EOF
102    
103   # now disable all other ids in the database   # 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  fi

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