Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-store.in
Parent Directory | Revision Log
Revision 2604 -
(hide annotations)
(download)
Fri Sep 18 13:12:56 2015 UTC (8 years, 8 months ago) by niro
File size: 3982 byte(s)
Fri Sep 18 13:12:56 2015 UTC (8 years, 8 months ago) by niro
File size: 3982 byte(s)
-renamed store_uri variable and flags to store
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 | niro | 2603 | local store |
28 | niro | 2593 | 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 | niro | 2604 | store=$(source ${STOREFRONT_DIR}/default-store; echo "${STORE}") |
37 | niro | 2603 | addconfig " <DefaultStore>${store}</DefaultStore>" |
38 | niro | 2593 | else |
39 | # use the first one which gets found | ||
40 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
41 | niro | 2593 | do |
42 | niro | 2603 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
43 | if [[ -n ${store} ]] | ||
44 | niro | 2593 | then |
45 | niro | 2603 | addconfig " <DefaultStore>${store}</DefaultStore>" |
46 | niro | 2593 | 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 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
58 | niro | 2593 | do |
59 | niro | 2603 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
60 | if [[ -n ${store} ]] | ||
61 | niro | 2593 | then |
62 | niro | 2603 | addconfig " <Store name=\"${store}\" type=\"PNA\">" |
63 | addconfig " ${store}" | ||
64 | niro | 2593 | 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 | niro | 2604 | --store) shift; store="$1" ;; |
79 | niro | 2593 | esac |
80 | shift | ||
81 | done | ||
82 | |||
83 | [[ -n ${method} ]] || die "No method given" | ||
84 | |||
85 | niro | 2594 | # always create the STOREFRONT_STORES_DIR |
86 | install -d "${STOREFRONT_STORES_DIR}" | ||
87 | |||
88 | niro | 2593 | case "${method}" in |
89 | add) | ||
90 | # requires name and store | ||
91 | niro | 2603 | [[ -n ${store} ]] || die "No store uri given" |
92 | niro | 2593 | |
93 | # only pna stores are allowed at the moment | ||
94 | niro | 2603 | if [[ ${store/config.xml} = ${store} ]] |
95 | niro | 2593 | then |
96 | die "Only PNA Stores are allowed." | ||
97 | fi | ||
98 | |||
99 | niro | 2603 | store_name="$(normalize_store ${store})" |
100 | niro | 2593 | config="${STOREFRONT_STORES_DIR}/${store_name}.conf" |
101 | CONFIG="${MROOT}/${config}" | ||
102 | clearconfig | ||
103 | niro | 2603 | addconfig "STORE=\"${store}\"" |
104 | niro | 2593 | ;; |
105 | |||
106 | del) | ||
107 | niro | 2603 | if [[ -z ${store} ]] |
108 | niro | 2593 | then |
109 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
110 | niro | 2593 | do |
111 | if [ -f ${config} ] && [[ ${config/.conf} != ${config} ]] | ||
112 | then | ||
113 | rm ${config} | ||
114 | fi | ||
115 | done | ||
116 | else | ||
117 | niro | 2603 | store_name="$(normalize_store ${store})" |
118 | niro | 2593 | 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 | niro | 2603 | # requires store |
129 | [[ -n ${store} ]] || die "No store uri given" | ||
130 | niro | 2593 | |
131 | niro | 2603 | store_name="$(normalize_store ${store})" |
132 | niro | 2593 | 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 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
142 | niro | 2593 | do |
143 | niro | 2600 | if [ -f ${STOREFRONT_STORES_DIR}/${config} ] |
144 | niro | 2598 | then |
145 | niro | 2603 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
146 | rvecho "${store}" | ||
147 | niro | 2598 | fi |
148 | niro | 2593 | done |
149 | ;; | ||
150 | |||
151 | regen) generate_storefront_xml ;; | ||
152 | esac |