Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-resolver.in
Parent Directory | Revision Log
Revision 2513 -
(show annotations)
(download)
Mon Sep 14 10:01:10 2015 UTC (8 years, 9 months ago) by niro
File size: 4209 byte(s)
Mon Sep 14 10:01:10 2015 UTC (8 years, 9 months ago) by niro
File size: 4209 byte(s)
-make storefront tmp removal configurable
1 | #!/bin/bash |
2 | |
3 | BROWSER="" |
4 | : ${STOREFRONT_STORE=""} |
5 | : ${REMOVE_STOREFRONT_TMP=1} |
6 | |
7 | source @@SYSCONFDIR@@/mcore/citrix.conf |
8 | |
9 | if [[ -z ${STOREFRONT_STORE} ]] |
10 | then |
11 | STOREFRONT_STORE="${DEFAULT_STOREFRONT_STORE}" |
12 | fi |
13 | |
14 | # prefer storebrowse |
15 | if [[ -e ${STOREBROWSE_EXECUTABLE} ]] |
16 | then |
17 | BROWSER=${STOREBROWSE_EXECUTABLE} |
18 | # use old pnabrowse |
19 | elif [[ -e ${PNABROWSE_EXECUTABLE} ]] |
20 | then |
21 | BROWSER=${PNABROWSE_EXECUTABLE} |
22 | # newer use storefront subscriptions with pnabrowse |
23 | STOREFRONT_ADDSTORE_REQUIRED=0 |
24 | STOREFRONT_SUBSCRIBE_APP=0 |
25 | else |
26 | echo "No Citrix browser found." |
27 | exit 1 |
28 | fi |
29 | |
30 | USE_XMESSAGE=0 |
31 | if [[ -x $(type -P xmessage) ]] |
32 | then |
33 | USE_XMESSAGE=1 |
34 | fi |
35 | |
36 | die() { echo "ERROR: $@"; exit 1; } |
37 | |
38 | storefront_list_store() |
39 | { |
40 | "${BROWSER}" -l | cut -d"'" -f1-3 | sed "s:'::g" |
41 | } |
42 | |
43 | storefront_add_store() |
44 | { |
45 | if [[ -z $("${BROWSER}" -l "${STOREFRONT_STORE}" | grep "'${STOREFRONT_STORE}'") ]] |
46 | then |
47 | "${BROWSER}" -a "${STOREFRONT_STORE}" |
48 | else |
49 | echo "Store '${STOREFRONT_STORE}' already added." |
50 | fi |
51 | } |
52 | |
53 | storefront_delete_store() |
54 | { |
55 | if [[ -n $("${BROWSER}" -l "${STOREFRONT_STORE}" | grep "'${STOREFRONT_STORE}'") ]] |
56 | then |
57 | "${BROWSER}" -d "${STOREFRONT_STORE}" |
58 | else |
59 | echo "Store '${STOREFRONT_STORE}' not found." |
60 | fi |
61 | } |
62 | |
63 | storefront_subscribe_app() |
64 | { |
65 | # already subscribed? |
66 | if [[ -z $("${BROWSER}" -S -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" | grep "'${APP}'") ]] |
67 | then |
68 | "${BROWSER}" -s "${APP}" -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" |
69 | else |
70 | echo "'${APP}' already subscribed.'" |
71 | fi |
72 | } |
73 | |
74 | storefront_unsubscribe_app() |
75 | { |
76 | # already subscribed? |
77 | if [[ -n $("${BROWSER}" -S -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" | grep "'${APP}'") ]] |
78 | then |
79 | "${BROWSER}" -u "${APP}" -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" |
80 | else |
81 | echo "'${APP}' not subscribed.'" |
82 | fi |
83 | } |
84 | |
85 | storefront_enumerate() |
86 | { |
87 | "${BROWSER}" -E -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" |
88 | } |
89 | |
90 | storefront_launch() |
91 | { |
92 | "${BROWSER}" -L "${APP}" -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" |
93 | } |
94 | |
95 | # very basic getops |
96 | for argv in $* |
97 | do |
98 | case $1 in |
99 | --enumerate|--launch|--liststore|--addstore|--delstore) CMD="${1//--}" ;; |
100 | --user) shift; USER="$1" ;; |
101 | --password) shift; PASS="$1" ;; |
102 | --domain) shift; DOMAIN="$1" ;; |
103 | --app) shift; APP="$1" ;; |
104 | --store) shift; STOREFRONT_STORE="$1" ;; #override all envvars and configuration vars |
105 | esac |
106 | shift |
107 | done |
108 | |
109 | [[ -n ${CMD} ]] || die "No CMD given" |
110 | |
111 | # create required citrix runtime with an accepted eula |
112 | # and remove all temp files |
113 | install -d ~/.ICAClient |
114 | touch ~/.ICAClient/.eula_accepted |
115 | if [[ ${REMOVE_STOREFRONT_TMP} = 1 ]] |
116 | then |
117 | if [[ -d ~/.ICAClient/.tmp ]] |
118 | then |
119 | rm -r ~/.ICAClient/.tmp |
120 | fi |
121 | fi |
122 | |
123 | case ${CMD} in |
124 | enumerate) |
125 | # enumerate apps |
126 | if [[ ${STOREFRONT_ADDSTORE_REQUIRED} = 1 ]] |
127 | then |
128 | storefront_add_store |
129 | fi |
130 | storefront_enumerate |
131 | ;; |
132 | |
133 | launch) |
134 | # launch apps |
135 | if [[ ${USE_XMESSAGE} = 1 ]] |
136 | then |
137 | xmessage -center -title "ICA-Client" -buttons "" " |
138 | Starting session '${APP}' ... |
139 | |
140 | " & |
141 | fi |
142 | if [[ ${STOREFRONT_ADDSTORE_REQUIRED} = 1 ]] |
143 | then |
144 | storefront_add_store |
145 | fi |
146 | if [[ ${STOREFRONT_SUBSCRIBE_APP} = 1 ]] |
147 | then |
148 | storefront_subscribe_app |
149 | fi |
150 | if [[ ${BROWSER} = ${PNABROWSE_EXECUTABLE} ]] |
151 | then |
152 | # always enumerate all apps to fill the cache or launch will not work |
153 | # and always enumerate if the cache is older than one day |
154 | if [ ! -f ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml ] || |
155 | [[ ! -z $(find ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml -mtime +1) ]] |
156 | then |
157 | storefront_enumerate |
158 | fi |
159 | fi |
160 | if storefront_launch |
161 | then |
162 | if [[ ${USE_XMESSAGE} = 1 ]] |
163 | then |
164 | killall xmessage |
165 | fi |
166 | else |
167 | if [[ ${USE_XMESSAGE} = 1 ]] |
168 | then |
169 | killall xmessage |
170 | xmessage -center -title "ICA-Client" -buttons " |
171 | Abort" "Failed to start session '${APP}'. |
172 | |
173 | " & |
174 | else |
175 | echo "Failed to start session '${APP}'." |
176 | fi |
177 | fi |
178 | ;; |
179 | |
180 | liststore) |
181 | storefront_list_store |
182 | ;; |
183 | |
184 | addstore) |
185 | if [[ -n $2 ]] |
186 | then |
187 | STOREFRONT_STORE="$2" |
188 | fi |
189 | storefront_add_store |
190 | ;; |
191 | |
192 | delstore) |
193 | if [[ -n $2 ]] |
194 | then |
195 | STOREFRONT_STORE="$2" |
196 | fi |
197 | storefront_delete_store |
198 | ;; |
199 | |
200 | *) |
201 | echo "Unknown command '${CMD}'." |
202 | exit 1 |
203 | ;; |
204 | esac |