Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-resolver.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2396 - (show annotations) (download)
Thu Aug 27 08:32:40 2015 UTC (8 years, 8 months ago) by niro
File size: 3889 byte(s)
-setup a proper runtime for the citrix client
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 # create required citrix runtime with an accepted eula
108 # and remove all temp files
109 install -d ~/.ICAClient
110 touch ~/.ICAClient/.eula_accepted
111 if [[ -d ~/ICAClient/.tmp ]]
112 then
113 rm -r ~/ICAClient/.tmp
114 fi
115
116 case ${CMD} in
117 enumerate)
118 # enumerate apps
119 if [[ ${ADDSTORE_REQUIRED} = 1 ]]
120 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 if [[ ${ADDSTORE_REQUIRED} = 1 ]]
136 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 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 *)
189 echo "Unknown command '${CMD}'."
190 exit 1
191 ;;
192 esac