Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-store.in
Parent Directory | Revision Log
Revision 2594 -
(show annotations)
(download)
Fri Sep 18 12:26:41 2015 UTC (9 years ago) by niro
File size: 3931 byte(s)
Fri Sep 18 12:26:41 2015 UTC (9 years ago) by niro
File size: 3931 byte(s)
-always create the storefront store dir
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_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 | # always create the STOREFRONT_STORES_DIR |
86 | install -d "${STOREFRONT_STORES_DIR}" |
87 | |
88 | case "${method}" in |
89 | add) |
90 | # requires name and store |
91 | [[ -n ${store_uri} ]] || die "No store uri given" |
92 | |
93 | # only pna stores are allowed at the moment |
94 | if [[ ${store_uri/config.xml} = ${store_uri} ]] |
95 | then |
96 | die "Only PNA Stores are allowed." |
97 | fi |
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 |