Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-store.in
Parent Directory | Revision Log
Revision 2607 -
(show annotations)
(download)
Mon Sep 21 14:00:37 2015 UTC (9 years ago) by niro
File size: 4213 byte(s)
Mon Sep 21 14:00:37 2015 UTC (9 years ago) by niro
File size: 4213 byte(s)
-always create an .eula_accepted file if missing
1 | #!/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 |
28 | local xml |
29 | |
30 | install -d "${MCORE_UNPRIV_HOME}"/.ICAClient/cache/Stores |
31 | if [[ ! -f ${MCORE_UNPRIV_HOME}/.ICAClient/.eula_accepted ]] |
32 | then |
33 | touch "${MCORE_UNPRIV_HOME}"/.ICAClient/.eula_accepted |
34 | fi |
35 | chown -R "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" "${MCORE_UNPRIV_HOME}"/.ICAClient |
36 | |
37 | CONFIG="${MCORE_UNPRIV_HOME}/.ICAClient/cache/Stores/StoreCache.ctx" |
38 | clearconfig |
39 | addconfig '<StoreCache>' |
40 | if [[ -L ${STOREFRONT_DIR}/default-store ]] |
41 | then |
42 | store=$(source ${STOREFRONT_DIR}/default-store; echo "${STORE}" | tr '[A-Z]' '[a-z]') |
43 | addconfig " <DefaultStore>${store}</DefaultStore>" |
44 | else |
45 | # use the first one which gets found |
46 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
47 | do |
48 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}" | tr '[A-Z]' '[a-z]') |
49 | if [[ -n ${store} ]] |
50 | then |
51 | addconfig " <DefaultStore>${store}</DefaultStore>" |
52 | break |
53 | fi |
54 | done |
55 | fi |
56 | addconfig ' <ReconnectOnLogon>False</ReconnectOnLogon>' |
57 | addconfig ' <ReconnectOnLaunchOrRefresh>False</ReconnectOnLaunchOrRefresh>' |
58 | addconfig ' <SharedUserMode>False</SharedUserMode>' |
59 | addconfig ' <FullscreenMode>0</FullscreenMode>' |
60 | addconfig ' <SelfSelection>True</SelfSelection>' |
61 | addconfig ' <SessionWindowedMode>False</SessionWindowedMode>' |
62 | addconfig ' <VisibleStores>' |
63 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
64 | do |
65 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}" | tr '[A-Z]' '[a-z]') |
66 | if [[ -n ${store} ]] |
67 | then |
68 | addconfig " <Store name=\"${store}\" type=\"PNA\">" |
69 | addconfig " ${store}" |
70 | addconfig ' </Store>' |
71 | fi |
72 | done |
73 | addconfig ' </VisibleStores>' |
74 | addconfig '</StoreCache>' |
75 | |
76 | chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" "${CONFIG}" |
77 | } |
78 | |
79 | # very basic getops |
80 | for argv in $* |
81 | do |
82 | case $1 in |
83 | --add|--del|--default|--print|--regen) method="${1//--}" ;; |
84 | --store) shift; store="$1" ;; |
85 | esac |
86 | shift |
87 | done |
88 | |
89 | [[ -n ${method} ]] || die "No method given" |
90 | |
91 | # always create the STOREFRONT_STORES_DIR |
92 | install -d "${STOREFRONT_STORES_DIR}" |
93 | |
94 | case "${method}" in |
95 | add) |
96 | # requires name and store |
97 | [[ -n ${store} ]] || die "No store uri given" |
98 | |
99 | # only pna stores are allowed at the moment |
100 | if [[ ${store/config.xml} = ${store} ]] |
101 | then |
102 | die "Only PNA Stores are allowed." |
103 | fi |
104 | |
105 | store_name="$(normalize_store ${store})" |
106 | config="${STOREFRONT_STORES_DIR}/${store_name}.conf" |
107 | CONFIG="${MROOT}/${config}" |
108 | clearconfig |
109 | addconfig "STORE=\"${store}\"" |
110 | ;; |
111 | |
112 | del) |
113 | if [[ -z ${store} ]] |
114 | then |
115 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
116 | do |
117 | if [ -f ${config} ] && [[ ${config/.conf} != ${config} ]] |
118 | then |
119 | rm ${config} |
120 | fi |
121 | done |
122 | else |
123 | store_name="$(normalize_store ${store})" |
124 | if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] |
125 | then |
126 | rm ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf |
127 | else |
128 | eecho "No configured store named '${store_name}' exists." |
129 | fi |
130 | fi |
131 | ;; |
132 | |
133 | default) |
134 | # requires store |
135 | [[ -n ${store} ]] || die "No store uri given" |
136 | |
137 | store_name="$(normalize_store ${store})" |
138 | if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] |
139 | then |
140 | ln -snf ${STOREFRONT_STORES_DIR}/"${store_name}".conf ${STOREFRONT_DIR}/default-store |
141 | else |
142 | eecho "No configured store named '${store_name}' exists." |
143 | fi |
144 | ;; |
145 | |
146 | print) |
147 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
148 | do |
149 | if [ -f ${STOREFRONT_STORES_DIR}/${config} ] |
150 | then |
151 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
152 | rvecho "${store}" |
153 | fi |
154 | done |
155 | ;; |
156 | |
157 | regen) generate_storefront_xml ;; |
158 | esac |