5 |
# needs fluxbox! |
# needs fluxbox! |
6 |
require fluxbox basic-video |
require fluxbox basic-video |
7 |
|
|
8 |
|
# citrix global config |
9 |
|
include @@SYSCONFDIR@@/mcore/citrix.conf |
10 |
|
|
11 |
help_citrix_serverlist() |
help_citrix_serverlist() |
12 |
{ |
{ |
13 |
mecho "get citrix.serverlist" |
mecho "get citrix.serverlist [action]" |
14 |
mecho " Shows all hosts added on the serverlist." |
mecho " Shows all hosts added on the serverlist." |
15 |
|
mecho " [actions]:" |
16 |
|
mecho " print - prints local configured serverlist" |
17 |
|
mecho " query - get serverlist of the farm from given [server]" |
18 |
mecho |
mecho |
19 |
mecho "set citrix.serverlist [action] [host]" |
mecho "set citrix.serverlist [action] [host]" |
20 |
mecho " Adds or deletes a server from the ica serverlist." |
mecho " Adds or deletes a server from the ica serverlist." |
21 |
mecho " [actions]:" |
mecho " [actions]:" |
22 |
mecho " add - adds a server" |
mecho " add - adds a server" |
23 |
mecho " del - deletes a server" |
mecho " del - deletes a server" |
24 |
|
mecho " auto - queries given [server] for the serverlist and adds all of them" |
25 |
mecho |
mecho |
26 |
mecho " host - dns hostname or ip of the server" |
mecho " host - dns hostname or ip of the server" |
27 |
mecho |
mecho |
32 |
{ |
{ |
33 |
mecho "get citrix.session" |
mecho "get citrix.session" |
34 |
mecho " Shows all configured ICA sessions" |
mecho " Shows all configured ICA sessions" |
35 |
|
mecho " print - prints all local configured sessions" |
36 |
|
mecho " query - get sessionlist of the farm from given [server]" |
37 |
mecho |
mecho |
38 |
mecho "set citrix.session [action] [session] [mode] [user] [domain] [password]" |
mecho "set citrix.session [action] [name] [session] [mode] [user] [domain] [password]" |
39 |
mecho " Adds or delets a ICA session." |
mecho " Adds or delets a ICA session." |
40 |
mecho " Available actions:" |
mecho " Available actions:" |
41 |
mecho " add - adds a new ica session" |
mecho " add - adds a new ica session" |
58 |
set_citrix_session() |
set_citrix_session() |
59 |
{ |
{ |
60 |
local action="$1" |
local action="$1" |
61 |
local session="$2" |
local name="$2" |
62 |
local mode="$3" |
local session="$3" |
63 |
local user="$4" |
local mode="$4" |
64 |
local domain="$5" |
local user="$5" |
65 |
local password="$6" |
local domain="$6" |
66 |
|
local password="$7" |
67 |
local serverlist |
local serverlist |
68 |
local server |
local server |
69 |
local server_num |
local server_num |
70 |
|
local icafile |
71 |
local CONFIG |
local CONFIG |
72 |
local i |
local i |
73 |
|
|
74 |
[[ -z ${action} ]] && help_citrix_session && return 1 |
[[ -z ${action} ]] && help_citrix_session && return 1 |
75 |
[[ -z ${session} ]] && help_citrix_session && return 1 |
[[ -z ${name} ]] && help_citrix_session && return 1 |
76 |
|
|
77 |
case "${action}" in |
case "${action}" in |
78 |
add) |
add) |
79 |
# action 'add' need mode too |
# action 'add' need mode too |
80 |
[[ -z ${mode} ]] && help_citrix_session && return 1 |
[[ -z ${mode} ]] && help_citrix_session && return 1 |
81 |
|
# and session |
82 |
|
[[ -z ${session} ]] && help_citrix_session && return 1 |
83 |
|
|
84 |
# other sanity checks |
# other sanity checks |
85 |
case "${mode}" in |
case "${mode}" in |
89 |
*) help_citrix_session && return 1 |
*) help_citrix_session && return 1 |
90 |
esac |
esac |
91 |
|
|
92 |
CONFIG="${MCORE_CONFIG_PATH}/citrix/ica/${session}.ica" |
icafile="${MCORE_CONFIG_PATH}/citrix/ica/${name}.ica" |
93 |
|
CONFIG="${MROOT}/${icafile}" |
94 |
clearconfig |
clearconfig |
95 |
|
|
96 |
addconfig '[WFClient]' |
addconfig '[WFClient]' |
148 |
esac |
esac |
149 |
|
|
150 |
# generate fluxbox menu entry |
# generate fluxbox menu entry |
151 |
set_fluxbox_menuitem add "${session}" "wfica ${CONFIG}" |
set_fluxbox_menuitem add "${name}" "wfica ${icafile}" |
152 |
;; |
;; |
153 |
|
|
154 |
del) |
del) |
155 |
if [[ -f ${MCORE_CONFIG_PATH}/citrix/ica/${session}.ica ]] |
if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica ] |
156 |
then |
then |
157 |
rm ${MCORE_CONFIG_PATH}/citrix/ica/"${session}".ica |
rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica/"${name}".ica |
158 |
set_fluxbox_menuitem del "${session}" |
set_fluxbox_menuitem del "${name}" |
159 |
|
|
160 |
elif [[ -z ${file} ]] |
elif [[ -z ${file} ]] |
161 |
then |
then |
162 |
# delete all items, needed to loop through every session |
# delete all items, needed to loop through every session |
163 |
# or we delete *all* fluxbox menuitem too |
# or we delete *all* fluxbox menuitem too |
164 |
for i in ${MCORE_CONFIG_PATH}/citrix/ica/* |
for i in $(find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/ica -type f) |
165 |
do |
do |
166 |
rm ${i} |
rm ${i} |
167 |
set_fluxbox_menuitem del "$(basename ${i} .ica)" |
set_fluxbox_menuitem del "$(basename ${i} .ica)" |
175 |
|
|
176 |
get_citrix_session() |
get_citrix_session() |
177 |
{ |
{ |
178 |
|
local action="$1" |
179 |
|
local server="$2" |
180 |
|
local sessionlist |
181 |
|
local sessioncount |
182 |
local i |
local i |
183 |
local item |
local exclude |
184 |
|
|
185 |
for i in $(find ${MCORE_CONFIG_PATH}/citrix/ica -type f) |
[[ -z ${action} ]] && help_citrix_serverlist && return 1 |
|
do |
|
|
item="${item} $(basename ${i} .ica)" |
|
|
done |
|
186 |
|
|
187 |
mecho "${item}" |
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 |
|
if [ -x ${MROOT}/${PNABROWSE_EXECUTABLE} ] |
193 |
|
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 |
|
*) help_citrix_session && return 1 ;; |
210 |
|
esac |
211 |
} |
} |
212 |
|
|
213 |
set_citrix_serverlist() |
set_citrix_serverlist() |
215 |
local action="$1" |
local action="$1" |
216 |
local server="$2" |
local server="$2" |
217 |
local CONFIG |
local CONFIG |
218 |
|
local serverlist |
219 |
|
local servercount |
220 |
|
local i |
221 |
|
local exclude |
222 |
|
|
223 |
[[ -z ${action} ]] && help_citrix_serverlist && return 1 |
[[ -z ${action} ]] && help_citrix_serverlist && return 1 |
224 |
|
|
225 |
case "${action}" in |
case "${action}" in |
226 |
add) |
add) |
227 |
[[ -z ${server} ]] && help_citrix_serverlist && return 1 |
[[ -z ${server} ]] && help_citrix_serverlist && return 1 |
228 |
CONFIG="${MCORE_CONFIG_PATH}/citrix/serverlist/${server}" |
CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server}" |
229 |
clearconfig |
clearconfig |
230 |
addconfig "${server}" |
addconfig "${server}" |
231 |
;; |
;; |
232 |
|
|
233 |
del) |
del) |
234 |
if [[ -f ${MCORE_CONFIG_PATH}/citrix/serverlist/${server} ]] |
if [ ! -d ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist ] |
235 |
then |
then |
236 |
rm ${MCORE_CONFIG_PATH}/citrix/serverlist/"${server}" |
eecho "'${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist' directory not found." |
237 |
|
elif [ -f ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/${server} ] |
238 |
|
then |
239 |
|
rm ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist/"${server}" |
240 |
elif [[ -z ${server} ]] |
elif [[ -z ${server} ]] |
241 |
then |
then |
242 |
# delete all items |
# delete all items |
243 |
rm ${MCORE_CONFIG_PATH}/citrix/serverlist/* |
find ${MROOT}/${MCORE_CONFIG_PATH}/citrix/serverlist -type f | xargs --no-run-if-empty rm |
244 |
|
fi |
245 |
|
;; |
246 |
|
|
247 |
|
auto) |
248 |
|
if [ -x ${MROOT}/${PNABROWSE_EXECUTABLE} ] |
249 |
|
then |
250 |
|
if [[ -n ${PNABROWSE_SERVER_EXCLUDE} ]] |
251 |
|
then |
252 |
|
exclude="| grep -v '${PNABROWSE_SERVER_EXCLUDE}'" |
253 |
|
fi |
254 |
|
serverlist=( $(${MROOT}/${PNABROWSE_EXECUTABLE} -S ${PNABROWSE_CITRIX_BROWSER} ${exclude}) ) |
255 |
|
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 |
|
eecho "'${MROOT}/${PNABROWSE_SERVER_EXCLUDE}' executable not found." |
265 |
fi |
fi |
266 |
;; |
;; |
267 |
|
|
271 |
|
|
272 |
get_citrix_serverlist() |
get_citrix_serverlist() |
273 |
{ |
{ |
274 |
|
local action="$1" |
275 |
|
local server="$2" |
276 |
|
local serverlist |
277 |
|
local servercount |
278 |
local i |
local i |
279 |
local item |
local exclude |
280 |
|
|
281 |
for i in $(find ${MCORE_CONFIG_PATH}/citrix/serverlist -type f) |
[[ -z ${action} ]] && help_citrix_serverlist && return 1 |
|
do |
|
|
item="${item} $(basename ${i})" |
|
|
done |
|
282 |
|
|
283 |
mecho "${item}" |
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 |
|
*) help_citrix_session && return 1 ;; |
303 |
|
esac |
304 |
} |
} |