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