1 |
# $Id$ |
# $Id$ |
2 |
# configures ica-sessions on the host via mysql db settings |
# configures ica-sessions on the host via mysql db settings |
3 |
|
|
4 |
|
fix_whitespaces() |
5 |
|
{ |
6 |
|
local var="$@" |
7 |
|
echo "${var//\ /_}" |
8 |
|
} |
9 |
|
|
10 |
# helper function to create citrix session files |
# helper function to create citrix session files |
11 |
generate_ica_session_file() |
generate_ica_session_file() |
12 |
{ |
{ |
30 |
--username) shift; ses_username="$1" ;; |
--username) shift; ses_username="$1" ;; |
31 |
--password) shift; ses_password="$1" ;; |
--password) shift; ses_password="$1" ;; |
32 |
--domain) shift; ses_domain="$1" ;; |
--domain) shift; ses_domain="$1" ;; |
33 |
--server) ses_browseradrs="$1" ;; |
--server) shift; ses_browseradrs="$1" ;; |
34 |
esac |
esac |
35 |
shift |
shift |
36 |
done |
done |
37 |
|
|
38 |
# abort if session, filename or server not given |
# abort if session, filename or server not given |
39 |
[[ -z ${session} ]] && return 1 |
[[ -z ${ses_session} ]] && return 1 |
40 |
[[ -z ${file} ]] && return 1 |
[[ -z ${ses_filename} ]] && return 1 |
41 |
[[ -z ${server} ]] && return 1 |
[[ -z ${ses_browseradrs} ]] && return 1 |
42 |
|
|
43 |
# write session files |
# write session files |
44 |
CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}" |
CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}" |
80 |
local dest |
local dest |
81 |
local name |
local name |
82 |
local exec |
local exec |
83 |
|
local param |
84 |
local workdir |
local workdir |
85 |
local CONFIG |
local CONFIG |
86 |
|
|
90 |
case $1 in |
case $1 in |
91 |
--name|-n) shift; name="$1" ;; |
--name|-n) shift; name="$1" ;; |
92 |
--exec|-x) shift; exec="$1" ;; |
--exec|-x) shift; exec="$1" ;; |
93 |
|
--param|-p) shift; param="$1" ;; |
94 |
--dest|-d) shift; dest="$1" ;; |
--dest|-d) shift; dest="$1" ;; |
95 |
--workdir|-w) shift; workdir="$1" ;; |
--workdir|-w) shift; workdir="$1" ;; |
96 |
esac |
esac |
105 |
CONFIG="${dest}" |
CONFIG="${dest}" |
106 |
addconfig "#!/bin/sh" |
addconfig "#!/bin/sh" |
107 |
[ -n "${workdir}" ] && addconfig "cd ${workdir}" |
[ -n "${workdir}" ] && addconfig "cd ${workdir}" |
108 |
addconfig "exec ${exec}" |
addconfig "exec ${exec} ${param}" |
109 |
|
|
110 |
chmod 0755 "${dest}" |
chmod 0755 "${dest}" |
111 |
} |
} |
158 |
icon="${ALX_SESSIONS_ICONS}/${deficon}" |
icon="${ALX_SESSIONS_ICONS}/${deficon}" |
159 |
fi |
fi |
160 |
|
|
161 |
CONFIG=${dest} |
CONFIG="${dest}" |
162 |
clearconfig |
clearconfig |
163 |
|
|
164 |
addconfig 'table Icon' |
addconfig 'table Icon' |
188 |
local yres |
local yres |
189 |
local x |
local x |
190 |
local y |
local y |
191 |
local item |
local i |
192 |
local name |
local name |
193 |
local progsh_path |
local progsh_path |
194 |
|
|
195 |
# progsh path |
# progsh path |
196 |
progsh_path=${ALX_UNPRIV_HOME}/.alxprogs |
progsh_path="${ALX_UNPRIV_HOME}/.alxprogs" |
197 |
|
|
198 |
# get the resolution |
# get the resolution |
199 |
res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'") |
res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'") |
219 |
declare -i y=30 |
declare -i y=30 |
220 |
|
|
221 |
# ica icons |
# ica icons |
222 |
for item in ${session_list} |
for i in ${session_list} |
223 |
do |
do |
224 |
# abort if empty |
# abort if empty |
225 |
[[ -z ${item} ]] && continue |
[[ -z ${i} ]] && continue |
226 |
|
|
227 |
|
# get database information |
228 |
|
evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" |
229 |
|
|
230 |
# new line if x > xres |
# new line if x > xres |
231 |
if [ ${x} -ge ${xres} ] |
if [ ${x} -ge ${xres} ] |
244 |
[ ${x} -ge ${xres} ] && x=30 |
[ ${x} -ge ${xres} ] && x=30 |
245 |
fi |
fi |
246 |
|
|
|
name="$(basename ${item} .ica)" |
|
247 |
generate_icon \ |
generate_icon \ |
248 |
--name "${name}" \ |
--name "${cfg_session_session}" \ |
249 |
--command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \ |
--command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_session_filename})" \ |
250 |
--icon "${ALX_SESSIONS_ICONS}/${name}.png" \ |
--icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_session_session}).png" \ |
251 |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" \ |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/$(fix_whitespaces ${cfg_session_session}).lnk" \ |
252 |
--xres "${x}" \ |
--xres "${x}" \ |
253 |
--yres "${y}" |
--yres "${y}" |
254 |
|
|
255 |
y=$((${y} + 80)) |
y=$((${y} + 80)) |
256 |
done |
done |
257 |
|
|
258 |
for item in ${other_menuitem_list} |
for i in ${other_menuitem_list} |
259 |
do |
do |
260 |
# abort if empty |
# abort if empty |
261 |
[[ -z ${item} ]] && continue |
[[ -z ${i} ]] && continue |
262 |
|
|
263 |
|
# get database information |
264 |
|
evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" |
265 |
|
|
266 |
# new line if x > xres |
# new line if x > xres |
267 |
if [ ${x} -ge ${xres} ] |
if [ ${x} -ge ${xres} ] |
281 |
fi |
fi |
282 |
|
|
283 |
generate_icon \ |
generate_icon \ |
284 |
--name "${item}" \ |
--name "${cfg_other_menuitems_name}" \ |
285 |
--command "${progsh_path}/${item}" \ |
--command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_exec})" \ |
286 |
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
--icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_name}).png" \ |
287 |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \ |
288 |
--xres "${x}" \ |
--xres "${x}" \ |
289 |
--yres "${y}" \ |
--yres "${y}" \ |
290 |
--default-icon "default_item.png" |
--default-icon "default_item.png" |
328 |
local all_other_ids |
local all_other_ids |
329 |
local CONFIG |
local CONFIG |
330 |
local screensaver_passwd_cmd |
local screensaver_passwd_cmd |
|
local all_sessions |
|
|
local all_other_menuitems |
|
331 |
|
|
332 |
# get all session ids from database |
# get all session ids from database |
333 |
all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'") |
all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'") |
370 |
# add autostart session |
# add autostart session |
371 |
if [[ ! -z ${cfg_autostart_session} ]] |
if [[ ! -z ${cfg_autostart_session} ]] |
372 |
then |
then |
373 |
addconfig "[startup] {nohup nice -n 19 wfica ${ALX_ICA_SESSIONS}/${cfg_autostart_session} &}" |
addconfig "[startup] {nohup nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_autostart_session}) &}" |
374 |
fi |
fi |
375 |
|
|
376 |
# fluxbox hotkeys |
# fluxbox hotkeys |
377 |
cat ${ALX_SKELETONS}/fluxbox/keys > ${ALX_UNPRIV_HOME}/.fluxbox/keys |
cat ${ALX_SKELETONS}/fluxbox/keys > ${ALX_UNPRIV_HOME}/.fluxbox/keys |
378 |
|
|
379 |
# generate a fluxbox menu |
# generate a fluxbox menu |
380 |
CONFIG=${ALX_UNPRIV_HOME}/.fluxbox/menu |
CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu" |
381 |
clearconfig |
clearconfig |
382 |
|
|
383 |
# fluxbox menu header |
# fluxbox menu header |
394 |
evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" |
evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" |
395 |
generate_ica_session_file \ |
generate_ica_session_file \ |
396 |
--session "${cfg_sessions_session}" \ |
--session "${cfg_sessions_session}" \ |
397 |
--filename "${cfg_sessions_filename}" \ |
--filename "$(fix_whitespaces ${cfg_sessions_filename})" \ |
398 |
--username "${cfg_sessions_username}" \ |
--username "${cfg_sessions_username}" \ |
399 |
--password "${cfg_sessions_password}" \ |
--password "${cfg_sessions_password}" \ |
400 |
--domain "${cfg_sessions_domain}" \ |
--domain "${cfg_sessions_domain}" \ |
401 |
--server "${cfg_sessions_browseradrs}" |
--server "${cfg_sessions_browseradrs}" |
402 |
|
|
403 |
# fluxbox menusession |
# fluxbox menusession |
404 |
addconfig "[exec] (${cfg_sessions_session}) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${cfg_sessions_filename}}" |
addconfig "[exec] (${cfg_sessions_session}) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})}" |
|
|
|
|
# add to all_sessions variable to create icons later for these |
|
|
all_sessions="${all_sessions} ${cfg_sessions_filename}" |
|
405 |
done |
done |
406 |
|
|
407 |
# delete all progs |
# delete all progs |
429 |
generate_program_sh \ |
generate_program_sh \ |
430 |
--name "${cfg_other_menuitems_name}" \ |
--name "${cfg_other_menuitems_name}" \ |
431 |
--exec "${cfg_other_menuitems_exec}" \ |
--exec "${cfg_other_menuitems_exec}" \ |
432 |
--dest "${progsh_path}/${cfg_other_menuitems_name}" \ |
--param "${cfg_other_menuitems_param}" \ |
433 |
"${cfg_other_menuitems_workdir}" |
--dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \ |
434 |
|
"${workdir}" |
|
addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/${cfg_other_menuitems_name}} ${cfg_other_menuitems_icon}" |
|
435 |
|
|
436 |
# add to all_other_menuitems variable to create icons later for these |
addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}" |
|
all_other_menuitems="${all_other_menuitems} ${cfg_other_menuitems_name}" |
|
437 |
done |
done |
438 |
|
|
439 |
# fluxbox menu footer |
# fluxbox menu footer |
442 |
addconfig |
addconfig |
443 |
|
|
444 |
# now it's a good time to generate *all* icons :) |
# now it's a good time to generate *all* icons :) |
445 |
generate_all_desktop_icons "${all_sessions}" "${all_other_menuitems}" |
generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}" |
446 |
|
|
447 |
# fix permissions |
# fix permissions |
448 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |