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