Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-resolver.in
Parent Directory | Revision Log
Revision 2391 -
(show annotations)
(download)
Thu Aug 27 07:38:22 2015 UTC (8 years, 8 months ago) by niro
File size: 3686 byte(s)
Thu Aug 27 07:38:22 2015 UTC (8 years, 8 months ago) by niro
File size: 3686 byte(s)
--added basic getopts to clarify and ease things, fixed broken config include and resulting missing variables and renamed STOREFRONT_STORE to DEFAULT_STOREFRONT_STORE in citrix.conf
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 | ADDSTORE_REQUIRED=1 |
18 | # use old pnabrowse |
19 | elif [[ -e ${PNABROWSE_EXECUTABLE} ]] |
20 | then |
21 | BROWSER=${PNABROWSE_EXECUTABLE} |
22 | ADDSTORE_REQUIRED=0 |
23 | 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 | storefront_list_store() |
35 | { |
36 | "${BROWSER}" -l | cut -d"'" -f1-3 | sed "s:'::g" |
37 | } |
38 | |
39 | storefront_add_store() |
40 | { |
41 | if [[ -z $("${BROWSER}" -l "${STOREFRONT_STORE}" | grep "'${STOREFRONT_STORE}'") ]] |
42 | 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 | if [[ -n $("${BROWSER}" -l "${STOREFRONT_STORE}" | grep "'${STOREFRONT_STORE}'") ]] |
52 | 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 | # 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 | case ${CMD} in |
108 | enumerate) |
109 | # enumerate apps |
110 | if [[ ${ADDSTORE_REQUIRED} = 1 ]] |
111 | then |
112 | storefront_add_store |
113 | fi |
114 | storefront_enumerate |
115 | ;; |
116 | |
117 | launch) |
118 | # launch apps |
119 | if [[ ${USE_XMESSAGE} = 1 ]] |
120 | then |
121 | xmessage -center -title "ICA-Client" -buttons "" " |
122 | Starting session '${APP}' ... |
123 | |
124 | " & |
125 | fi |
126 | if [[ ${ADDSTORE_REQUIRED} = 1 ]] |
127 | then |
128 | storefront_add_store |
129 | storefront_subscribe_app |
130 | else |
131 | # always enumerate all apps to fill the cache or launch will not work |
132 | # and always enumerate if the cache is older than one day |
133 | if [ ! -f ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml ] || |
134 | [[ ! -z $(find ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml -mtime +1) ]] |
135 | then |
136 | storefront_enumerate |
137 | fi |
138 | fi |
139 | if storefront_launch |
140 | then |
141 | if [[ ${USE_XMESSAGE} = 1 ]] |
142 | then |
143 | killall xmessage |
144 | fi |
145 | else |
146 | if [[ ${USE_XMESSAGE} = 1 ]] |
147 | then |
148 | killall xmessage |
149 | xmessage -center -title "ICA-Client" -buttons " |
150 | Abort" "Failed to start session '${APP}'. |
151 | |
152 | " & |
153 | else |
154 | echo "Failed to start session '${APP}'." |
155 | fi |
156 | fi |
157 | ;; |
158 | |
159 | liststore) |
160 | storefront_list_store |
161 | ;; |
162 | |
163 | addstore) |
164 | if [[ -n $2 ]] |
165 | then |
166 | STOREFRONT_STORE="$2" |
167 | fi |
168 | storefront_add_store |
169 | ;; |
170 | |
171 | delstore) |
172 | if [[ -n $2 ]] |
173 | then |
174 | STOREFRONT_STORE="$2" |
175 | fi |
176 | storefront_delete_store |
177 | ;; |
178 | |
179 | *) |
180 | echo "Unknown command '${CMD}'." |
181 | exit 1 |
182 | ;; |
183 | esac |