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