Magellan Linux

Annotation of /alx-src/branches/alxconf-060/functions/config_sessions.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7977 - (hide annotations) (download) (as text)
Thu Dec 10 09:09:40 2015 UTC (8 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 20334 byte(s)
-never show window decorations with the ica-client
1 niro 2001 # $Id$
2 niro 236 # configures ica-sessions on the host via mysql db settings
3    
4 niro 2161 fix_whitespaces()
5     {
6     local var="$@"
7     echo "${var//\ /_}"
8     }
9    
10 niro 6780 sanitize_store()
11     {
12     local var="$@"
13     echo "$(fix_whitespaces ${var})" | sed -e 's:\::_:g' -e 's:\/:_:g' | tr '[A-Z]' '[a-z]'
14     }
15    
16 niro 2149 # helper function to create citrix session files
17     generate_ica_session_file()
18 niro 236 {
19 niro 246 local i
20 niro 2149 local num
21 niro 246 local server
22     local ses_session
23     local ses_filename
24     local ses_username
25     local ses_domain
26     local ses_password
27     local ses_browseradrs
28 niro 2435 local ses_colors
29 niro 2035 local CONFIG
30 niro 246
31 niro 2149 # very basic getops
32     for i in $*
33 niro 246 do
34 niro 2149 case $1 in
35     --session) shift; ses_session="$1" ;;
36     --filename) shift; ses_filename="$1" ;;
37     --username) shift; ses_username="$1" ;;
38     --password) shift; ses_password="$1" ;;
39     --domain) shift; ses_domain="$1" ;;
40 niro 2161 --server) shift; ses_browseradrs="$1" ;;
41 niro 2435 --colordepth) shift; ses_colors="$1" ;;
42 niro 6763 esac
43 niro 2149 shift
44     done
45 niro 246
46 niro 2149 # abort if session, filename or server not given
47 niro 2161 [[ -z ${ses_session} ]] && return 1
48     [[ -z ${ses_filename} ]] && return 1
49     [[ -z ${ses_browseradrs} ]] && return 1
50 niro 272
51 niro 2149 # write session files
52     CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}"
53     clearconfig
54 niro 2035
55 niro 2149 addconfig '[WFClient]'
56     addconfig 'Version=2'
57 niro 1654
58 niro 2149 # use ';' as ifs
59     declare -i i=0
60     for server in ${ses_browseradrs//;/ }
61     do
62     (( i++ ))
63     num="${i}"
64     # support newer ica-clients:
65     # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !!
66     [[ ${i} -eq 1 ]] && num=""
67     addconfig "TcpBrowserAddress${num}=${server}"
68 niro 5618 addconfig "HttpBrowserAddress${num}=${server}"
69 niro 246 done
70 niro 2149
71     addconfig 'ScreenPercent=0'
72     addconfig '[ApplicationServers]'
73     addconfig "${ses_session}="
74     addconfig "[${ses_session}]"
75     addconfig "Address=${ses_session}"
76     addconfig "InitialProgram=#${ses_session}"
77 niro 2435
78     # convert to ica session file values
79     case ${ses_colors} in
80     24|32) ses_colors="8";;
81     16) ses_colors="4";;
82     8) ses_colors="2";;
83     *) ses_colors="4";; # default to 16bit
84     esac
85     addconfig "DesiredColor=${ses_colors}"
86 niro 2149 addconfig 'TransportDriver=TCP/IP'
87     addconfig 'WinStationDriver=ICA 3.0'
88 niro 2611 addconfig "ClearPassword=${ses_password}"
89 niro 2149 addconfig "Username=${ses_username}"
90     addconfig "Domain=${ses_domain}"
91     addconfig 'UseFullScreen=Yes'
92     addconfig 'NoWindowManager=True'
93 niro 246 }
94    
95 niro 6765 generate_storefront_sh()
96     {
97     local server
98     local ses_session
99     local ses_filename
100     local ses_username
101     local ses_domain
102     local ses_password
103     local ses_browseradrs
104 niro 6780 local method
105     local ses_method
106     local name
107 niro 6765
108     # very basic getops
109     for i in $*
110     do
111     case $1 in
112     --session) shift; ses_session="$1" ;;
113     --filename) shift; ses_filename="$1" ;;
114     --username) shift; ses_username="$1" ;;
115     --password) shift; ses_password="$1" ;;
116     --domain) shift; ses_domain="$1" ;;
117     --server) shift; ses_browseradrs="$1" ;;
118 niro 6780 --method) shift; method="$1" ;;
119 niro 6765 esac
120     shift
121     done
122    
123 niro 6780 # abort if name, dest or exec not given
124     [[ -z ${ses_filename} ]] && return 1
125     [[ -z ${ses_username} ]] && return 1
126     [[ -z ${ses_password} ]] && return 1
127     [[ -z ${ses_domain} ]] && return 1
128     [[ -z ${ses_browseradrs} ]] && return 1
129    
130     case "${method}" in
131     enumerate)
132     ses_method="${method}"
133     name="store-enumerate"
134     ;;
135     launch)
136     ses_method="${method}"
137     name="${ses_session}"
138     [[ -z ${ses_session} ]] && return 1
139     ;;
140     *) echo "generate_storefront_sh(): wrong method given, either 'launch' or 'enumerate' are allowed."
141     return 1
142     ;;
143     esac
144    
145 niro 6765 generate_program_sh \
146 niro 6780 --name "${name}" \
147 niro 6765 --exec "storefront-resolver" \
148 niro 6780 --param "${method} '${ses_username}' '${ses_password}' '${ses_domain}' '${ses_session}'" \
149 niro 6765 --dest "${ALX_UNPRIV_HOME}/.alxprogs/$(fix_whitespaces ${ses_filename})" \
150     --environment "STORE=${ses_browseradrs}"
151     }
152    
153 niro 317 # generates a sh file to start programs
154     generate_program_sh()
155     {
156     local dest
157     local name
158     local exec
159 niro 2161 local param
160 niro 317 local workdir
161 niro 2035 local CONFIG
162 niro 317
163     # very basic getops
164     for i in $*
165     do
166     case $1 in
167     --name|-n) shift; name="$1" ;;
168     --exec|-x) shift; exec="$1" ;;
169 niro 2161 --param|-p) shift; param="$1" ;;
170 niro 317 --dest|-d) shift; dest="$1" ;;
171     --workdir|-w) shift; workdir="$1" ;;
172 niro 6765 --environment|-e) shift; environment="$1" ;;
173 niro 6763 esac
174 niro 317 shift
175     done
176    
177     # abort if name, dest or exec not given
178 niro 2149 [[ -z ${name} ]] && return 1
179     [[ -z ${exec} ]] && return 1
180     [[ -z ${dest} ]] && return 1
181 niro 317
182 niro 2149 CONFIG="${dest}"
183 niro 2035 addconfig "#!/bin/sh"
184 niro 6765 [[ -n ${environment} ]] && addconfig "export ${environment}"
185     [[ -n ${workdir} ]] && addconfig "cd ${workdir}"
186 niro 2161 addconfig "exec ${exec} ${param}"
187 niro 317
188 niro 2149 chmod 0755 "${dest}"
189 niro 317 }
190    
191 niro 304 # helper functions for generate all desktop icons
192     generate_icon()
193     {
194     local name
195     local icon
196     local command
197     local dest
198     local yres
199     local xres
200     local iwidth
201     local iheight
202 niro 317 local deficon
203 niro 2035 local CONFIG
204 niro 2401 local utility
205 niro 304
206     # very basic getops
207     for i in $*
208     do
209     case $1 in
210     --name|-n) shift; name="$1" ;;
211     --command|-c) shift; command="$1" ;;
212     --icon|-i) shift; icon="$1" ;;
213     --dest|-d) shift; dest="$1" ;;
214     --xres|-x) shift; xres="$1" ;;
215     --yres|-y) shift; yres="$1" ;;
216     --icon-width|-w) shift; iwidth="$1" ;;
217     --icon-height|-h) shift; iheight="$1" ;;
218 niro 317 --default-icon) shift; deficon="$1" ;;
219 niro 6763 esac
220 niro 304 shift
221     done
222    
223 niro 2149 # some sanity checks:
224 niro 2401
225 niro 304 # abort if name or command not given
226 niro 2035 [[ -z ${name} ]] && return 1
227     [[ -z ${command} ]] && return 1
228 niro 304
229 niro 2454 [[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk"
230 niro 2401
231 niro 304 # use some defaults for icon, dest, {x,y}res
232 niro 2495 [[ -z ${xres} ]] && xres=50
233     [[ -z ${yres} ]] && xres=50
234 niro 2035 if [[ -z ${icon} ]] || [ ! -f ${icon} ]
235 niro 304 then
236 niro 317 # if no default icon is given use default.png
237 niro 2035 [[ -z ${deficon} ]] && deficon="default.png"
238 niro 317 icon="${ALX_SESSIONS_ICONS}/${deficon}"
239 niro 304 fi
240    
241 niro 2161 CONFIG="${dest}"
242 niro 2035 clearconfig
243 niro 304
244 niro 2035 addconfig 'table Icon'
245     addconfig " Caption: ${name}"
246     addconfig " Command: ${command}"
247     addconfig " Icon: ${icon}"
248     addconfig " X: ${xres}"
249     addconfig " Y: ${yres}"
250    
251 niro 304 # add these only if not zero
252 niro 2035 if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]
253 niro 304 then
254 niro 2454 addconfig " Width: ${iwidth}"
255     addconfig " Height: ${iheight}"
256 niro 304 fi
257    
258 niro 2035 addconfig 'end'
259 niro 304 }
260    
261     generate_all_desktop_icons()
262     {
263 niro 2149 local session_list="$1"
264     local other_menuitem_list="$2"
265 niro 2747 local plugin_list="$3"
266 niro 304 local res
267     local xres
268     local yres
269     local x
270     local y
271 niro 2161 local i
272 niro 2149 local name
273 niro 317 local progsh_path
274 niro 2401 local utility
275     local dest
276     local rc
277 niro 304
278 niro 2454 dest="${ALX_UNPRIV_HOME}/.idesktop"
279     rc="${ALX_UNPRIV_HOME}/.ideskrc"
280 niro 2401
281 niro 2149 # progsh path
282 niro 2161 progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
283 niro 2149
284 niro 304 # get the resolution
285 niro 342 res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")
286 niro 304
287     # split res to x & y
288 niro 2149 xres="${res%x*}"
289 niro 2166 yres="${res#*x}"
290 niro 304
291     # top left edge of the icon is given in config file
292     # remove a little bit to simulate the bottom-right edge
293     xres="$(( ${xres} - 120 ))"
294     yres="$(( ${yres} - 80 ))"
295    
296     # clean desktop icon location
297 niro 2401 [ -d ${dest} ] && rm -rf ${dest}
298     [ -f ${rc} ] && rm -f ${rc}
299     install -d ${dest}
300 niro 304
301     # default settings
302 niro 2495 declare -i x=50
303     declare -i y=50
304 niro 304
305 niro 2149 # ica icons
306 niro 2161 for i in ${session_list}
307 niro 304 do
308     # abort if empty
309 niro 2161 [[ -z ${i} ]] && continue
310 niro 304
311 niro 2161 # get database information
312     evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
313    
314 niro 304 # new line if x > xres
315 niro 2035 if [ ${x} -ge ${xres} ]
316     then
317 niro 2495 x=50
318 niro 304 y=$((${y} + 80))
319     fi
320    
321     # new row if y > yres
322 niro 2035 if [ ${y} -ge ${yres} ]
323     then
324 niro 304 x=$((${x} + 120))
325 niro 2495 y=50
326 niro 304
327     # re-check x
328 niro 2495 [ ${x} -ge ${xres} ] && x=50
329 niro 304 fi
330    
331     generate_icon \
332 niro 2166 --name "${cfg_sessions_session}" \
333 niro 6765 --command "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \
334 niro 2166 --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \
335 niro 2401 --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \
336 niro 304 --xres "${x}" \
337     --yres "${y}"
338    
339     y=$((${y} + 80))
340     done
341    
342 niro 2161 for i in ${other_menuitem_list}
343 niro 317 do
344     # abort if empty
345 niro 2161 [[ -z ${i} ]] && continue
346 niro 317
347 niro 2161 # get database information
348     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
349    
350 niro 317 # new line if x > xres
351 niro 2035 if [ ${x} -ge ${xres} ]
352     then
353 niro 2495 x=50
354 niro 317 y=$((${y} + 80))
355     fi
356    
357     # new row if y > yres
358 niro 2035 if [ ${y} -ge ${yres} ]
359     then
360 niro 317 x=$((${x} + 120))
361 niro 2495 y=50
362 niro 317
363     # re-check x
364 niro 2495 [ ${x} -ge ${xres} ] && x=50
365 niro 317 fi
366    
367     generate_icon \
368 niro 2161 --name "${cfg_other_menuitems_name}" \
369 niro 2381 --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
370 niro 6759 --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_icon}).png" \
371 niro 2401 --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \
372 niro 317 --xres "${x}" \
373     --yres "${y}" \
374     --default-icon "default_item.png"
375    
376     y=$((${y} + 80))
377     done
378 niro 2747
379     for i in ${plugin_list}
380     do
381     # abort if empty
382     [[ -z ${i} ]] && continue
383 niro 3490
384 niro 2747 evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
385     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
386     then
387     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem)
388 niro 317
389 niro 2747 # abort if name or exec is empty
390     [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue
391     [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue
392    
393     # new line if x > xres
394     if [ ${x} -ge ${xres} ]
395     then
396     x=50
397     y=$((${y} + 80))
398     fi
399    
400     # new row if y > yres
401     if [ ${y} -ge ${yres} ]
402     then
403     x=$((${x} + 120))
404     y=50
405    
406     # re-check x
407     [ ${x} -ge ${xres} ] && x=50
408     fi
409    
410     generate_icon \
411     --name "${PLUGIN_MENUITEM_NAME}" \
412     --command "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \
413     --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).png" \
414     --dest "${dest}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).lnk" \
415     --xres "${x}" \
416     --yres "${y}" \
417     --default-icon "default_item.png"
418    
419     y=$((${y} + 80))
420     fi
421    
422     # unset all variables
423     unset PLUGIN_MENUITEM_NAME
424     unset PLUGIN_MENUITEM_EXEC
425     unset PLUGIN_MENUITEM_PARAM
426     unset PLUGIN_MENUITEM_WORKDIR
427     unset PLUGIN_MENUITEM_ICON
428     done
429    
430 niro 2469 # add shutdown, reboot icons
431     for i in shutdown reboot
432     do
433     # new line if x > xres
434     if [ ${x} -ge ${xres} ]
435     then
436 niro 2495 x=50
437 niro 2469 y=$((${y} + 80))
438     fi
439    
440     # new row if y > yres
441     if [ ${y} -ge ${yres} ]
442     then
443     x=$((${x} + 120))
444 niro 2495 y=50
445 niro 2469
446     # re-check x
447 niro 2495 [ ${x} -ge ${xres} ] && x=50
448 niro 2469 fi
449    
450     case ${i} in
451 niro 2479 shutdown) name="Herunterfahren" ;;
452     reboot) name="Neustarten" ;;
453 niro 2469 esac
454    
455     generate_icon \
456     --name "${name}" \
457     --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \
458     --icon "${ALX_SESSIONS_ICONS}/${i}.png" \
459     --dest "${dest}/${i}.lnk" \
460     --xres "${x}" \
461 niro 2565 --yres "${y}" \
462     --icon-width "40" \
463     --icon-height "40"
464 niro 2469
465     y=$((${y} + 80))
466     done
467    
468 niro 304 # last but not least gen a icon with some sys informations
469     local sysinfo
470     local hostname
471     local osversion
472    
473     osversion="$(< /etc/mageversion)"
474 niro 342 hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'")
475 niro 304 sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
476    
477     # now get the right position:
478     # restore orig values of xres
479     xres="$(( ${xres} + 120 ))"
480     # default y pos (full yres -22 = cur yres + 58 !)
481     yres="$(( ${yres} + 58 ))"
482     # middle of the screen
483     # (no txt - length required, xtdesk manage that itself)
484     xres="$(( ${xres} / 2))"
485    
486     generate_icon \
487     --name "${sysinfo}" \
488     --command "exit 0" \
489     --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
490 niro 2401 --dest "${dest}/sysinfo.lnk" \
491 niro 304 --xres "${xres}" \
492     --yres "${yres}" \
493     --icon-width "1" \
494     --icon-height "1"
495     }
496    
497 niro 236 config_sessions()
498     {
499 niro 272 local i
500 niro 2149 local all_ses_ids
501     local all_other_ids
502 niro 2035 local CONFIG
503 niro 2149 local screensaver_passwd_cmd
504 niro 2469 local fbinit
505     local fbkeys
506 niro 3503 local progsh_path
507 niro 6780 local storefront_enumerate=0
508     local storefront_store
509     local _store
510     local all_storefront_stores=""
511 niro 236
512 niro 3503 progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
513    
514 niro 2149 # get all session ids from database
515     all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")
516 niro 2747 # get all other_menuitem ids from database
517 niro 2149 all_other_ids=$(mysqldo "select id from cfg_other_menuitems where serial='${ALX_SERIAL}'")
518 niro 2747 # get all plugin ids from database
519     all_plugin_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'")
520 niro 2149
521     # get screensaver settings
522     evaluate_table cfg_screensaver
523     # get autostart settings
524     evaluate_table cfg_autostart
525 niro 2435 # get current color depth
526     evaluate_table cfg_graphic
527 niro 2149
528 niro 236 # now setup fluxbox for user station
529    
530     # create a fresh fluxbox directory
531     [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox
532     install -d ${ALX_UNPRIV_HOME}/.fluxbox
533    
534     # now generate fluxbox config files
535    
536     # fluxbox main config
537 niro 2469 if [ -f ${ALX_SKELETONS}/fluxbox/init ]
538     then
539     fbinit="${ALX_SKELETONS}/fluxbox/init"
540     else
541     fbinit="/usr/share/fluxbox/init"
542     fi
543     cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init
544 niro 236
545     # fluxbox autostart
546 niro 2411 CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
547 niro 2454 # do not show decorations on messages generated with xmessage
548     if [ -x /usr/bin/xmessage ]
549     then
550     addconfig '[app] (xmessage)'
551     addconfig ' [Deco] {NONE}'
552     addconfig '[end]'
553     fi
554 niro 7977 # never show decorations with the ica client
555     addconfig '[app] (Wfica)'
556     addconfig ' [Deco] {NONE}'
557     addconfig '[end]'
558 niro 2411 # add icon utility
559 niro 2454 [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
560 niro 2411 # add numlock utility
561 niro 2454 [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
562 niro 236
563 niro 338 # add screensaver
564 niro 2149 if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]]
565 niro 338 then
566 niro 2149 if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]]
567 niro 338 then
568 niro 2149 screensaver_passwd_cmd="-nolock"
569 niro 338 else
570 niro 2149 screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})"
571 niro 338 fi
572    
573 niro 2149 addconfig "[startup] {nohup xautolock -time ${cfg_screensaver_timeout} -locker 'xlock -mode ${cfg_screensaver_screensaver} ${screensaver_passwd_cmd}' > /dev/null &}"
574 niro 338 fi
575    
576 niro 3503 # add plugins autostart
577     for i in ${all_plugin_ids}
578     do
579     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
580     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
581     then
582     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh autostart)
583    
584     if [[ ${PLUGIN_AUTOSTART} = 1 ]]
585     then
586     addconfig "[startup] {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}) &}"
587     fi
588 niro 3504 # unset all variables
589     unset PLUGIN_AUTOSTART
590     unset PLUGIN_MENUITEM_NAME
591 niro 3503 fi
592     done
593    
594 niro 236 # fluxbox hotkeys
595 niro 2469 if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
596     then
597     fbkeys="${ALX_SKELETONS}/fluxbox/keys"
598     else
599     fbkeys="/usr/share/fluxbox/keys"
600     fi
601     cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys
602 niro 236
603 niro 2035 # generate a fluxbox menu
604 niro 2161 CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
605 niro 2035 clearconfig
606    
607 niro 236 # fluxbox menu header
608 niro 2035 cat ${ALX_SKELETONS}/fluxbox/menu.header >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
609 niro 291 # now fix it with proper messages :P
610     local ver="$(< /etc/mageversion)"
611 niro 2035 sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu
612 niro 239 # add a newline (maybe there is no crlf in the header)
613 niro 2035 addconfig
614 niro 239
615 niro 6765 # delete all progs
616     [ -d ${progsh_path} ] && rm -rf ${progsh_path}
617     install -d ${progsh_path}
618    
619 niro 2149 # first generate session files
620     for i in ${all_ses_ids}
621 niro 236 do
622 niro 2149 evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
623    
624 niro 6765 # generate STOREFRONT/PNABROWSE compatible session
625     case "${cfg_sessions_browseradrs}" in
626     "http://"*|"https://"* )
627 niro 6780 # run storefront_enumerate on startup to get all available sessions
628     storefront_enumerate=1
629     storefront_store="$(sanitize_store ${cfg_sessions_browseradrs})"
630     store_found=0
631     for _store in ${all_storefront_stores}
632     do
633     if [[ ${storefront_store} = ${_store} ]]
634     then
635     store_found=1
636     fi
637     done
638     if [[ ${store_found} = 0 ]]
639     then
640     all_storefront_stores="${all_storefront_stores} ${storefront_store}"
641     generate_storefront_sh \
642     --method "enumerate" \
643     --filename "store-enumerate_${storefront_store}_.sh" \
644     --username "${cfg_sessions_username}" \
645     --password "${cfg_sessions_password}" \
646     --domain "${cfg_sessions_domain}" \
647     --server "${cfg_sessions_browseradrs}"
648     fi
649    
650 niro 6765 # generate STOREFRONT/PNABROWSE compatible session
651     generate_storefront_sh \
652 niro 6780 --method "launch" \
653 niro 6765 --session "${cfg_sessions_session}" \
654     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
655     --username "${cfg_sessions_username}" \
656     --password "${cfg_sessions_password}" \
657     --domain "${cfg_sessions_domain}" \
658     --server "${cfg_sessions_browseradrs}"
659     ;;
660     *)
661     # generate ICA compatible session
662     generate_ica_session_file \
663     --session "${cfg_sessions_session}" \
664     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
665     --username "${cfg_sessions_username}" \
666     --password "${cfg_sessions_password}" \
667     --domain "${cfg_sessions_domain}" \
668     --server "${cfg_sessions_browseradrs}" \
669     --colordepth "${cfg_graphic_depth}"
670     # gen prog startup wrapper
671     generate_program_sh \
672     --name "$(fix_whitespaces ${cfg_sessions_filename})" \
673     --exec "wfica-launcher" \
674     --param "${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \
675     --dest "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \
676     "${workdir}"
677     ;;
678     esac
679    
680 niro 2149 # fluxbox menusession
681 niro 6765 addconfig "[exec] (${cfg_sessions_session}) {${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})}"
682 niro 2149 done
683 niro 6780 if [[ ${storefront_enumerate} = 1 ]]
684     then
685     for _store in ${all_storefront_stores}
686     do
687     CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
688     addconfig "[startup] {${progsh_path}/store-enumerate_${_store}_.sh &}"
689     done
690     fi
691 niro 2149
692     # add other menuitems
693     for i in ${all_other_ids}
694     do
695     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
696    
697     # now echo config line for fluxbox-menu
698     # make it "configureable" :p
699     if [[ -n ${cfg_other_menuitems_workdir} ]]
700 niro 2035 then
701 niro 2149 workdir="--workdir ${cfg_other_menuitems_workdir}"
702 niro 2035 fi
703 niro 2149 if [[ -n ${cfg_other_menuitems_icon} ]]
704     then
705     cfg_other_menuitems_icon="<${cfg_other_menuitems_icon}>"
706     fi
707    
708     # gen prog startup wrapper
709     generate_program_sh \
710     --name "${cfg_other_menuitems_name}" \
711     --exec "${cfg_other_menuitems_exec}" \
712 niro 2161 --param "${cfg_other_menuitems_param}" \
713     --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
714     "${workdir}"
715 niro 2149
716 niro 6780 CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
717 niro 2161 addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}"
718 niro 236 done
719    
720 niro 2747 # add plugins
721     for i in ${all_plugin_ids}
722     do
723     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
724     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
725     then
726     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem)
727    
728     # abort if name or exec is empty
729     [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue
730     [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue
731    
732     # now echo config line for fluxbox-menu
733     # make it "configureable" :p
734     if [[ -n ${PLUGIN_MENUITEM_WORKDIR} ]]
735     then
736     workdir="--workdir ${PLUGIN_MENUITEM_WORKDIR}"
737     fi
738     if [[ -n ${PLUGIN_MENUITEM_ICON} ]]
739     then
740     PLUGIN_MENUITEM_ICON="<${PLUGIN_MENUITEM_ICON}>"
741     fi
742    
743     # gen prog startup wrapper
744     generate_program_sh \
745     --name "${PLUGIN_MENUITEM_NAME}" \
746     --exec "${PLUGIN_MENUITEM_EXEC}" \
747 niro 3455 --param "${PLUGIN_MENUITEM_PARAM}" \
748 niro 2747 --dest "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \
749     "${workdir}"
750    
751 niro 6780 CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
752 niro 2747 addconfig "[exec] (${PLUGIN_MENUITEM_NAME}) {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})} ${PLUGIN_MENUITEM_ICON}"
753     fi
754    
755     # unset all variables
756     unset PLUGIN_MENUITEM_NAME
757     unset PLUGIN_MENUITEM_EXEC
758     unset PLUGIN_MENUITEM_PARAM
759     unset PLUGIN_MENUITEM_WORKDIR
760     unset PLUGIN_MENUITEM_ICON
761     done
762    
763 niro 6780 # add autostart session
764     if [[ ! -z ${cfg_autostart_session} ]]
765     then
766     CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
767     # sleep one second to wait until busybox is fully initialized and the screen is really centered
768     addconfig "[startup] {sleep 1 && ${progsh_path}/$(fix_whitespaces ${cfg_autostart_session}) &}"
769     fi
770    
771 niro 236 # fluxbox menu footer
772 niro 6780 CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
773     cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${CONFIG}
774 niro 239 # add a newline (maybe there is no crlf in the footer)
775 niro 2035 addconfig
776 niro 236
777 niro 304 # now it's a good time to generate *all* icons :)
778 niro 2747 generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}" "${all_plugin_ids}"
779 niro 236
780 niro 2149 # fix permissions
781 niro 236 chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
782     chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
783     chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
784 niro 2454 chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop
785 niro 236 }