Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-store.in
Parent Directory | Revision Log
Revision 2607 -
(hide annotations)
(download)
Mon Sep 21 14:00:37 2015 UTC (8 years, 7 months ago) by niro
File size: 4213 byte(s)
Mon Sep 21 14:00:37 2015 UTC (8 years, 7 months ago) by niro
File size: 4213 byte(s)
-always create an .eula_accepted file if missing
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 | niro | 2607 | 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 | niro | 2605 | |
37 | niro | 2593 | CONFIG="${MCORE_UNPRIV_HOME}/.ICAClient/cache/Stores/StoreCache.ctx" |
38 | clearconfig | ||
39 | addconfig '<StoreCache>' | ||
40 | if [[ -L ${STOREFRONT_DIR}/default-store ]] | ||
41 | then | ||
42 | niro | 2606 | store=$(source ${STOREFRONT_DIR}/default-store; echo "${STORE}" | tr '[A-Z]' '[a-z]') |
43 | niro | 2603 | addconfig " <DefaultStore>${store}</DefaultStore>" |
44 | niro | 2593 | else |
45 | # use the first one which gets found | ||
46 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
47 | niro | 2593 | do |
48 | niro | 2606 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}" | tr '[A-Z]' '[a-z]') |
49 | niro | 2603 | if [[ -n ${store} ]] |
50 | niro | 2593 | then |
51 | niro | 2603 | addconfig " <DefaultStore>${store}</DefaultStore>" |
52 | niro | 2593 | 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 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
64 | niro | 2593 | do |
65 | niro | 2606 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}" | tr '[A-Z]' '[a-z]') |
66 | niro | 2603 | if [[ -n ${store} ]] |
67 | niro | 2593 | then |
68 | niro | 2603 | addconfig " <Store name=\"${store}\" type=\"PNA\">" |
69 | addconfig " ${store}" | ||
70 | niro | 2593 | 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 | niro | 2604 | --store) shift; store="$1" ;; |
85 | niro | 2593 | esac |
86 | shift | ||
87 | done | ||
88 | |||
89 | [[ -n ${method} ]] || die "No method given" | ||
90 | |||
91 | niro | 2594 | # always create the STOREFRONT_STORES_DIR |
92 | install -d "${STOREFRONT_STORES_DIR}" | ||
93 | |||
94 | niro | 2593 | case "${method}" in |
95 | add) | ||
96 | # requires name and store | ||
97 | niro | 2603 | [[ -n ${store} ]] || die "No store uri given" |
98 | niro | 2593 | |
99 | # only pna stores are allowed at the moment | ||
100 | niro | 2603 | if [[ ${store/config.xml} = ${store} ]] |
101 | niro | 2593 | then |
102 | die "Only PNA Stores are allowed." | ||
103 | fi | ||
104 | |||
105 | niro | 2603 | store_name="$(normalize_store ${store})" |
106 | niro | 2593 | config="${STOREFRONT_STORES_DIR}/${store_name}.conf" |
107 | CONFIG="${MROOT}/${config}" | ||
108 | clearconfig | ||
109 | niro | 2603 | addconfig "STORE=\"${store}\"" |
110 | niro | 2593 | ;; |
111 | |||
112 | del) | ||
113 | niro | 2603 | if [[ -z ${store} ]] |
114 | niro | 2593 | then |
115 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
116 | niro | 2593 | do |
117 | if [ -f ${config} ] && [[ ${config/.conf} != ${config} ]] | ||
118 | then | ||
119 | rm ${config} | ||
120 | fi | ||
121 | done | ||
122 | else | ||
123 | niro | 2603 | store_name="$(normalize_store ${store})" |
124 | niro | 2593 | 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 | niro | 2603 | # requires store |
135 | [[ -n ${store} ]] || die "No store uri given" | ||
136 | niro | 2593 | |
137 | niro | 2603 | store_name="$(normalize_store ${store})" |
138 | niro | 2593 | 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 | niro | 2601 | for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
148 | niro | 2593 | do |
149 | niro | 2600 | if [ -f ${STOREFRONT_STORES_DIR}/${config} ] |
150 | niro | 2598 | then |
151 | niro | 2603 | store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
152 | rvecho "${store}" | ||
153 | niro | 2598 | fi |
154 | niro | 2593 | done |
155 | ;; | ||
156 | |||
157 | regen) generate_storefront_xml ;; | ||
158 | esac |