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