Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-resolver.in
Parent Directory | Revision Log
Revision 2356 -
(show annotations)
(download)
Mon Aug 24 14:11:26 2015 UTC (9 years, 1 month ago) by niro
File size: 3290 byte(s)
Mon Aug 24 14:11:26 2015 UTC (9 years, 1 month ago) by niro
File size: 3290 byte(s)
-fixed spelling
1 | #!/bin/bash |
2 | |
3 | CMD="$1" |
4 | USER="$2" |
5 | PASS="$3" |
6 | DOMAIN="$4" |
7 | APP="$5" |
8 | |
9 | BROWSER="" |
10 | : ${STOREFRONT_STORE=""} |
11 | |
12 | if [[ -z ${STOREFRONT_STORE} ]] |
13 | then |
14 | source @@SYSCONFDIR@@/mcore/citrix.conf |
15 | fi |
16 | |
17 | # prefer storebrowse |
18 | if [[ -e ${STOREBROWSE_EXECUTABLE} ]] |
19 | then |
20 | BROWSER=${STOREBROWSE_EXECUTABLE} |
21 | ADDSTORE_REQUIRED=1 |
22 | # use old pnabrowse |
23 | elif [[ -e ${PNABROWSE_EXECUTABLE} ]] |
24 | then |
25 | BROWSER=${PNABROWSE_EXECUTABLE} |
26 | ADDSTORE_REQUIRED=0 |
27 | else |
28 | echo "No Citrix browser found." |
29 | exit 1 |
30 | fi |
31 | |
32 | USE_XMESSAGE=0 |
33 | if [[ -x $(type -P xmessage) ]] |
34 | then |
35 | USE_XMESSAGE=1 |
36 | fi |
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 | case ${CMD} in |
96 | enumerate) |
97 | # enumerate apps |
98 | if [[ ${ADDSTORE_REQUIRED} = 1 ]] |
99 | then |
100 | storefront_add_store |
101 | fi |
102 | storefront_enumerate |
103 | ;; |
104 | |
105 | launch) |
106 | # launch apps |
107 | if [[ ${USE_XMESSAGE} = 1 ]] |
108 | then |
109 | xmessage -center -title "ICA-Client" -buttons "" " |
110 | Starting session '${APP}' ... |
111 | |
112 | " & |
113 | fi |
114 | if [[ ${ADDSTORE_REQUIRED} = 1 ]] |
115 | then |
116 | storefront_add_store |
117 | storefront_subscribe_app |
118 | else |
119 | # always enumerate all apps to fill the cache or launch will not work |
120 | # and always enumerate if the cache is older than one day |
121 | if [ ! -f ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml ] || |
122 | [[ ! -z $(find ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml -mtime +1) ]] |
123 | then |
124 | storefront_enumerate |
125 | fi |
126 | fi |
127 | if storefront_launch |
128 | then |
129 | if [[ ${USE_XMESSAGE} = 1 ]] |
130 | then |
131 | killall xmessage |
132 | fi |
133 | else |
134 | if [[ ${USE_XMESSAGE} = 1 ]] |
135 | then |
136 | killall xmessage |
137 | xmessage -center -title "ICA-Client" -buttons " |
138 | Abort" "Failed to start session '${APP}'. |
139 | |
140 | " & |
141 | else |
142 | echo "Failed to start session '${APP}'." |
143 | fi |
144 | fi |
145 | ;; |
146 | |
147 | liststore) |
148 | storefront_list_store |
149 | ;; |
150 | |
151 | addstore) |
152 | if [[ -n $2 ]] |
153 | then |
154 | STOREFRONT_STORE="$2" |
155 | fi |
156 | storefront_add_store |
157 | ;; |
158 | |
159 | delstore) |
160 | if [[ -n $2 ]] |
161 | then |
162 | STOREFRONT_STORE="$2" |
163 | fi |
164 | storefront_delete_store |
165 | ;; |
166 | |
167 | *) |
168 | echo "Unknown command '${CMD}'." |
169 | exit 1 |
170 | ;; |
171 | esac |