Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-store.in
Parent Directory | Revision Log
Revision 2593 -
(hide annotations)
(download)
Fri Sep 18 12:24:18 2015 UTC (8 years, 8 months ago) by niro
File size: 3923 byte(s)
Fri Sep 18 12:24:18 2015 UTC (8 years, 8 months ago) by niro
File size: 3923 byte(s)
-added storefront-store cmd to add storefront stores via xml file to save a lot of time and workaround serveral issues with the new ica receiver
1 | niro | 2593 | #!/bin/bash |
2 | |||
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" | ||
4 | source @@SYSCONFDIR@@/mcore/mcore.conf | ||
5 | source ${MCORE_LIBDIR}/include/common.global.class | ||
6 | source ${MCORE_LIBDIR}/include/daemon.global.class | ||
7 | |||
8 | STOREFRONT_DIR="${MCORE_CONFIG_PATH}/citrix/storefront" | ||
9 | STOREFRONT_STORES_DIR="${STOREFRONT_DIR}/stores" | ||
10 | |||
11 | die() { echo "ERROR: $@"; exit 1; } | ||
12 | |||
13 | normalize_store() | ||
14 | { | ||
15 | local store="$1" | ||
16 | |||
17 | # remove : and / from uri and replace them with _ | ||
18 | store="${store//:/_}" | ||
19 | store="${store//\//_}" | ||
20 | |||
21 | echo "${store}" | ||
22 | } | ||
23 | |||
24 | generate_storefront_xml() | ||
25 | { | ||
26 | local config | ||
27 | local store_uri | ||
28 | local xml | ||
29 | |||
30 | install -o "${MCORE_UNPRIV_USER}" -g "${MCORE_UNPRIV_GROUP}" -d "${MCORE_UNPRIV_HOME}/.ICAClient/cache/Stores" | ||
31 | CONFIG="${MCORE_UNPRIV_HOME}/.ICAClient/cache/Stores/StoreCache.ctx" | ||
32 | clearconfig | ||
33 | addconfig '<StoreCache>' | ||
34 | if [[ -L ${STOREFRONT_DIR}/default-store ]] | ||
35 | then | ||
36 | store_uri=$(source ${STOREFRONT_DIR}/default-store; echo "${STORE}") | ||
37 | addconfig " <DefaultStore>${store_uri}</DefaultStore>" | ||
38 | else | ||
39 | # use the first one which gets found | ||
40 | for config in $(NOCOLOR=1 list_files_in_directory/${STOREFRONT_STORES_DIR}) | ||
41 | do | ||
42 | store_uri=$(source ${config}; echo "${STORE}") | ||
43 | if [[ -n ${store_uri} ]] | ||
44 | then | ||
45 | addconfig " <DefaultStore>${store_uri}</DefaultStore>" | ||
46 | break | ||
47 | fi | ||
48 | done | ||
49 | fi | ||
50 | addconfig ' <ReconnectOnLogon>False</ReconnectOnLogon>' | ||
51 | addconfig ' <ReconnectOnLaunchOrRefresh>False</ReconnectOnLaunchOrRefresh>' | ||
52 | addconfig ' <SharedUserMode>False</SharedUserMode>' | ||
53 | addconfig ' <FullscreenMode>0</FullscreenMode>' | ||
54 | addconfig ' <SelfSelection>True</SelfSelection>' | ||
55 | addconfig ' <SessionWindowedMode>False</SessionWindowedMode>' | ||
56 | addconfig ' <VisibleStores>' | ||
57 | for config in $(NOCOLOR=1 list_files_in_directory/${STOREFRONT_STORES_DIR}) | ||
58 | do | ||
59 | store_uri=$(source ${config}; echo "${STORE}") | ||
60 | if [[ -n ${store_uri} ]] | ||
61 | then | ||
62 | addconfig " <Store name=\"${store_uri}\" type=\"PNA\">" | ||
63 | addconfig " ${store_uri}" | ||
64 | addconfig ' </Store>' | ||
65 | fi | ||
66 | done | ||
67 | addconfig ' </VisibleStores>' | ||
68 | addconfig '</StoreCache>' | ||
69 | |||
70 | chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" "${CONFIG}" | ||
71 | } | ||
72 | |||
73 | # very basic getops | ||
74 | for argv in $* | ||
75 | do | ||
76 | case $1 in | ||
77 | --add|--del|--default|--print|--regen) method="${1//--}" ;; | ||
78 | --store) shift; store_uri="$1" ;; | ||
79 | esac | ||
80 | shift | ||
81 | done | ||
82 | |||
83 | [[ -n ${method} ]] || die "No method given" | ||
84 | |||
85 | case "${method}" in | ||
86 | add) | ||
87 | # requires name and store | ||
88 | [[ -n ${store_uri} ]] || die "No store uri given" | ||
89 | |||
90 | # only pna stores are allowed at the moment | ||
91 | if [[ ${store_uri/config.xml} = ${store_uri} ]] | ||
92 | then | ||
93 | die "Only PNA Stores are allowed." | ||
94 | fi | ||
95 | |||
96 | [ ! -d ${STOREFRONT_STORES_DIR} | ||
97 | # get a proper name strore[id].conf | ||
98 | |||
99 | store_name="$(normalize_store ${store_uri})" | ||
100 | config="${STOREFRONT_STORES_DIR}/${store_name}.conf" | ||
101 | CONFIG="${MROOT}/${config}" | ||
102 | clearconfig | ||
103 | addconfig "STORE=\"${store_uri}\"" | ||
104 | ;; | ||
105 | |||
106 | del) | ||
107 | if [[ -z ${store_uri} ]] | ||
108 | then | ||
109 | for config in $(NOCOLOR=1 list_files_in_directory/${STOREFRONT_STORES_DIR}) | ||
110 | do | ||
111 | if [ -f ${config} ] && [[ ${config/.conf} != ${config} ]] | ||
112 | then | ||
113 | rm ${config} | ||
114 | fi | ||
115 | done | ||
116 | else | ||
117 | store_name="$(normalize_store ${store_uri})" | ||
118 | if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] | ||
119 | then | ||
120 | rm ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf | ||
121 | else | ||
122 | eecho "No configured store named '${store_name}' exists." | ||
123 | fi | ||
124 | fi | ||
125 | ;; | ||
126 | |||
127 | default) | ||
128 | # requires store_uri | ||
129 | [[ -n ${store_uri} ]] || die "No store uri given" | ||
130 | |||
131 | store_name="$(normalize_store ${store_uri})" | ||
132 | if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] | ||
133 | then | ||
134 | ln -snf ${STOREFRONT_STORES_DIR}/"${store_name}".conf ${STOREFRONT_DIR}/default-store | ||
135 | else | ||
136 | eecho "No configured store named '${store_name}' exists." | ||
137 | fi | ||
138 | ;; | ||
139 | |||
140 | print) | ||
141 | for config in $(NOCOLOR=1 list_files_in_directory/${STOREFRONT_STORES_DIR}) | ||
142 | do | ||
143 | store_uri=$(source ${config}; echo "${STORE}") | ||
144 | rvecho "${store_uri}" | ||
145 | done | ||
146 | ;; | ||
147 | |||
148 | regen) generate_storefront_xml ;; | ||
149 | esac |