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/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 |
source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class |
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 |
37 |
export STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}" |
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 ] |
if [ -d ~/.ICAClient ] |
43 |
then |
then |
48 |
touch ~/.ICAClient/.eula_accepted |
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 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 |
62 |
echo "Store ${STOREFRONT_STORE} unknown, perhaps not added. Run 'rm -r ~/.ICAClient'." |
echo "Store ${STOREFRONT_STORE} unknown, perhaps not added. Run 'rm -r ~/.ICAClient'." |
63 |
else |
else |
64 |
OPT="" |
OPT="" |
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 |
echo "${SESSION_LIST}" |
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 |
fi |