Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/citrix.client.class.in
Parent Directory | Revision Log
Revision 2263 -
(hide annotations)
(download)
Mon Jan 13 15:36:41 2014 UTC (10 years, 8 months ago) by niro
File size: 8210 byte(s)
Mon Jan 13 15:36:41 2014 UTC (10 years, 8 months ago) by niro
File size: 8210 byte(s)
-fixed c&p typo
1 | niro | 1266 | # $Id$ |
2 | |||
3 | provide citrix ica | ||
4 | |||
5 | # needs fluxbox! | ||
6 | require fluxbox basic-video | ||
7 | |||
8 | niro | 2259 | # citrix global config |
9 | include @@SYSCONFDIR@@/mcore/citrix.conf | ||
10 | |||
11 | niro | 1266 | help_citrix_serverlist() |
12 | { | ||
13 | niro | 2259 | mecho "get citrix.serverlist [action]" |
14 | niro | 1266 | mecho " Shows all hosts added on the serverlist." |
15 | niro | 2259 | mecho " [actions]:" |
16 | mecho " print - prints local configured serverlist" | ||
17 | mecho " query - get serverlist of the farm from given [server]" | ||
18 | niro | 1266 | mecho |
19 | mecho "set citrix.serverlist [action] [host]" | ||
20 | mecho " Adds or deletes a server from the ica serverlist." | ||
21 | mecho " [actions]:" | ||
22 | mecho " add - adds a server" | ||
23 | mecho " del - deletes a server" | ||
24 | niro | 2259 | mecho " auto - queries given [server] for the serverlist and adds all of them" |
25 | niro | 1266 | mecho |
26 | mecho " host - dns hostname or ip of the server" | ||
27 | mecho | ||
28 | mecho " If no [host] was given, all entries are deleted." | ||
29 | } | ||
30 | |||
31 | help_citrix_session() | ||
32 | { | ||
33 | mecho "get citrix.session" | ||
34 | mecho " Shows all configured ICA sessions" | ||
35 | niro | 2259 | mecho " print - prints all local configured sessions" |
36 | mecho " query - get sessionlist of the farm from given [server]" | ||
37 | niro | 1266 | mecho |
38 | niro | 2038 | mecho "set citrix.session [action] [name] [session] [mode] [user] [domain] [password]" |
39 | niro | 1266 | mecho " Adds or delets a ICA session." |
40 | mecho " Available actions:" | ||
41 | mecho " add - adds a new ica session" | ||
42 | mecho " del - deletes ica session with file name [file]" | ||
43 | mecho " if no [file] given, all sessions will be deleted" | ||
44 | mecho | ||
45 | mecho " Available modes:" | ||
46 | mecho " fullscreen - fullscreen session" | ||
47 | mecho " seamless - seamless windows session" | ||
48 | mecho " *x* - windowed session with given resolution" | ||
49 | mecho " any resonable resolution is fine like:" | ||
50 | mecho " 1024x768, 1280x1024, 1440x900 etc" | ||
51 | mecho | ||
52 | mecho " session - name of the Citrix session" | ||
53 | mecho " user - user inside the session - optional" | ||
54 | mecho " domain - logon domain of the user - optional" | ||
55 | mecho " password - password of the user - optional" | ||
56 | } | ||
57 | |||
58 | set_citrix_session() | ||
59 | { | ||
60 | local action="$1" | ||
61 | niro | 2038 | local name="$2" |
62 | local session="$3" | ||
63 | local mode="$4" | ||
64 | local user="$5" | ||
65 | local domain="$6" | ||
66 | local password="$7" | ||
67 | niro | 1266 | local serverlist |
68 | local server | ||
69 | local server_num | ||
70 | niro | 2021 | local icafile |
71 | niro | 1266 | local CONFIG |
72 | local i | ||
73 | |||
74 | [[ -z ${action} ]] && help_citrix_session && return 1 | ||
75 | niro | 2038 | [[ -z ${name} ]] && help_citrix_session && return 1 |
76 | niro | 1266 | |
77 | case "${action}" in | ||
78 | add) | ||
79 | # action 'add' need mode too | ||
80 | [[ -z ${mode} ]] && help_citrix_session && return 1 | ||
81 | niro | 2038 | # and session |
82 | [[ -z ${session} ]] && help_citrix_session && return 1 | ||
83 | niro | 1266 | |
84 | # other sanity checks | ||
85 | case "${mode}" in | ||
86 | fullscreen) ;; | ||
87 | seamless) ;; | ||
88 | *x*) ;; | ||
89 | *) help_citrix_session && return 1 | ||
90 | esac | ||
91 | |||
92 | niro | 2038 | icafile="${MCORE_CONFIG_PATH}/citrix/ica/${name}.ica" |
93 | niro | 2021 | CONFIG="${MROOT}/${icafile}" |
94 | niro | 1266 | clearconfig |
95 | |||
96 | addconfig '[WFClient]' | ||
97 | addconfig 'Version=2' | ||
98 | |||
99 | serverlist=$(NOCOLORS=true get_citrix_serverlist) | ||
100 | declare -i i=0 | ||
101 | for server in ${serverlist} | ||
102 | do | ||
103 | (( i++ )) | ||
104 | server_num="${i}" | ||
105 | [[ ${i} -eq 1 ]] && server_num="" | ||
106 | addconfig "TcpBrowserAddress${server_num}=${server}" | ||
107 | done | ||
108 | addconfig 'ScreenPercent=0' | ||
109 | addconfig '[ApplicationServers]' | ||
110 | addconfig "${session}=" | ||
111 | addconfig "[${session}]" | ||
112 | addconfig "Address=${session}" | ||
113 | addconfig "InitialProgram=#${session}" | ||
114 | |||
115 | # mapping table xorg -> citrix | ||
116 | # citrix 1 = 16 colors | ||
117 | # citrix 2 = 256 colors | ||
118 | # citrix 4 = 16 bit | ||
119 | # citrix 8 = 32 bit | ||
120 | # try always 16 bit | ||
121 | addconfig "DesiredColor=4" | ||
122 | |||
123 | addconfig 'TransportDriver=TCP/IP' | ||
124 | addconfig 'WinStationDriver=ICA 3.0' | ||
125 | |||
126 | [[ -n ${user} ]] && addconfig "Username=${user}" | ||
127 | [[ -n ${domain} ]] && addconfig "Domain=${domain}" | ||
128 | [[ -n ${password} ]] && addconfig "ClearPassword=${password}" | ||
129 | |||
130 | # use the right display settings | ||
131 | case "${mode}" in | ||
132 | # fullscreen mode | ||
133 | fullscreen) | ||
134 | addconfig 'UseFullScreen=Yes' | ||
135 | addconfig 'NoWindowManager=True' | ||
136 | addconfig "DesiredHRES=65535" | ||
137 | addconfig "DesiredVRES=65535" | ||
138 | ;; | ||
139 | # seamless window mode | ||
140 | seamless) | ||
141 | addconfig 'TWIMode=On' | ||
142 | ;; | ||
143 | # a desired resolution | ||
144 | *x*) | ||
145 | addconfig "DesiredHRES=${mode%x*}" | ||
146 | addconfig "DesiredVRES=${mode#*x}" | ||
147 | ;; | ||
148 | esac | ||
149 | |||
150 | # generate fluxbox menu entry | ||
151 | niro | 2038 | set_fluxbox_menuitem add "${name}" "wfica ${icafile}" |
152 | niro | 1266 | ;; |
153 | |||
154 | del) | ||
155 | niro | 2038 | if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica ] |
156 | niro | 1266 | then |
157 | niro | 2038 | rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica |
158 | set_fluxbox_menuitem del "${name}" | ||
159 | niro | 1266 | |
160 | elif [[ -z ${file} ]] | ||
161 | then | ||
162 | # delete all items, needed to loop through every session | ||
163 | # or we delete *all* fluxbox menuitem too | ||
164 | niro | 2023 | for i in $(find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica -type f) |
165 | niro | 1266 | do |
166 | rm ${i} | ||
167 | set_fluxbox_menuitem del "$(basename ${i} .ica)" | ||
168 | done | ||
169 | fi | ||
170 | ;; | ||
171 | |||
172 | *) help_citrix_session && return 1 ;; | ||
173 | esac | ||
174 | } | ||
175 | |||
176 | get_citrix_session() | ||
177 | { | ||
178 | niro | 2259 | local action="$1" |
179 | local server="$2" | ||
180 | local sessionlist | ||
181 | local sessioncount | ||
182 | local i | ||
183 | local exclude | ||
184 | |||
185 | [[ -z ${action} ]] && help_citrix_serverlist && return 1 | ||
186 | |||
187 | case "${action}" in | ||
188 | print) list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica ;; | ||
189 | query) | ||
190 | [[ -n ${PNABROWSE_EXECUTABLE} ]] || eecho "\$PNABROWSE_EXECUTABLE not defined" | ||
191 | [[ -n ${PNABROWSE_CITRIX_BROWSER} ]] || eecho "\$PNABROWSE_CITRIX_BROWSER not defined" | ||
192 | niro | 2262 | if [ -x ${MROOT}/${PNABROWSE_EXECUTABLE} ] |
193 | niro | 2259 | then |
194 | if [[ -n ${PNABROWSE_SESSION_EXCLUDE} ]] | ||
195 | then | ||
196 | exclude="| grep -v '${PNABROWSE_SESSION_EXCLUDE}'" | ||
197 | fi | ||
198 | sessionlist=( $(${MROOT}/${PNABROWSE_EXECUTABLE} -A "${PNABROWSE_CITRIX_BROWSER}" ${exclude}) ) | ||
199 | sessioncount="${#sessionlist[*]}" | ||
200 | for (( i=0; i<sessioncount; i++)) | ||
201 | do | ||
202 | rvecho -n "${sessionlist[${i}]} " | ||
203 | done | ||
204 | rvecho | ||
205 | else | ||
206 | eecho "'${MROOT}/${PNABROWSE_EXECUTABLE}' executable not found." | ||
207 | fi | ||
208 | ;; | ||
209 | niro | 2261 | *) help_citrix_session && return 1 ;; |
210 | niro | 2259 | esac |
211 | niro | 1266 | } |
212 | |||
213 | set_citrix_serverlist() | ||
214 | { | ||
215 | local action="$1" | ||
216 | local server="$2" | ||
217 | local CONFIG | ||
218 | niro | 2259 | local serverlist |
219 | local servercount | ||
220 | local i | ||
221 | local exclude | ||
222 | niro | 1266 | |
223 | [[ -z ${action} ]] && help_citrix_serverlist && return 1 | ||
224 | |||
225 | case "${action}" in | ||
226 | add) | ||
227 | [[ -z ${server} ]] && help_citrix_serverlist && return 1 | ||
228 | niro | 2021 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server}" |
229 | niro | 1266 | clearconfig |
230 | addconfig "${server}" | ||
231 | ;; | ||
232 | |||
233 | del) | ||
234 | niro | 2259 | if [ ! -d ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist ] |
235 | niro | 1266 | then |
236 | niro | 2259 | eecho "'${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist' directory not found." |
237 | elif [ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server} ] | ||
238 | then | ||
239 | niro | 2021 | rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/"${server}" |
240 | niro | 1266 | elif [[ -z ${server} ]] |
241 | then | ||
242 | # delete all items | ||
243 | niro | 2023 | find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist -type f | xargs --no-run-if-empty rm |
244 | niro | 1266 | fi |
245 | ;; | ||
246 | |||
247 | niro | 2259 | auto) |
248 | niro | 2262 | if [ -x ${MROOT}/${PNABROWSE_EXECUTABLE} ] |
249 | niro | 2259 | then |
250 | if [[ -n ${PNABROWSE_SERVER_EXCLUDE} ]] | ||
251 | then | ||
252 | exclude="| grep -v '${PNABROWSE_SERVER_EXCLUDE}'" | ||
253 | fi | ||
254 | niro | 2262 | serverlist=( $(${MROOT}/${PNABROWSE_EXECUTABLE} -S ${PNABROWSE_CITRIX_BROWSER} ${exclude}) ) |
255 | niro | 2259 | servercount="${#serverlist[*]}" |
256 | for (( i=0; i<servercount; i++)) | ||
257 | do | ||
258 | server="${serverlist[${i}]}" | ||
259 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server}" | ||
260 | clearconfig | ||
261 | addconfig "${server}" | ||
262 | done | ||
263 | else | ||
264 | niro | 2262 | eecho "'${MROOT}/${PNABROWSE_SERVER_EXCLUDE}' executable not found." |
265 | niro | 2259 | fi |
266 | ;; | ||
267 | |||
268 | niro | 1266 | *) help_citrix_serverlist && return 1 ;; |
269 | esac | ||
270 | } | ||
271 | |||
272 | get_citrix_serverlist() | ||
273 | { | ||
274 | niro | 2259 | local action="$1" |
275 | local server="$2" | ||
276 | niro | 2263 | local serverlist |
277 | niro | 2259 | local servercount |
278 | local i | ||
279 | local exclude | ||
280 | |||
281 | [[ -z ${action} ]] && help_citrix_serverlist && return 1 | ||
282 | |||
283 | case "${action}" in | ||
284 | print) | ||
285 | list_files_in_directory ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist ;; | ||
286 | query) | ||
287 | [[ -n ${PNABROWSE_EXECUTABLE} ]] || eecho "\$PNABROWSE_EXECUTABLE not defined" | ||
288 | [[ -n ${PNABROWSE_CITRIX_BROWSER} ]] || eecho "\$PNABROWSE_CITRIX_BROWSER not defined" | ||
289 | if [ -x ${MROOT}/${PNABROWSE_EXECUTABLE} ] | ||
290 | then | ||
291 | serverlist=( $(${MROOT}/${PNABROWSE_EXECUTABLE} -S ${PNABROWSE_CITRIX_BROWSER}) ) | ||
292 | servercount="${#serverlist[*]}" | ||
293 | for (( i=0; i<servercount; i++)) | ||
294 | do | ||
295 | rvecho -n "${serverlist[${i}]} " | ||
296 | done | ||
297 | rvecho | ||
298 | else | ||
299 | eecho "'${MROOT}/${PNABROWSE_EXECUTABLE}' executable not found." | ||
300 | fi | ||
301 | ;; | ||
302 | niro | 2261 | *) help_citrix_session && return 1 ;; |
303 | niro | 2259 | esac |
304 | niro | 1266 | } |