Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

alx-src/trunk/alxconfig-ng/functions/config_sessions.sh revision 246 by niro, Wed Apr 13 16:09:53 2005 UTC alx-src/branches/alxconf-060/functions/config_sessions.sh revision 6763 by niro, Tue Jul 21 09:22:02 2015 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.5 2005-04-13 16:09:53 niro Exp $  # $Id$
2  # configures ica-sessions on the host via mysql db settings  # configures ica-sessions on the host via mysql db settings
3    
4  get_sessions_settings()  fix_whitespaces()
5  {  {
6   local x i all count   local var="$@"
7     echo "${var//\ /_}"
  #all arrays:  
  # ->  session1 session2 ... sessionN  
   
  #get settings from database  
  all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select filename from cfg_sessions where serial='${ALX_SERIAL}'")  
  #"select session from cfg_sessions where serial='${ALX_SERIAL}'")  
   
  #split'em up and put in an array (only if $all not zero)  
  declare -i i=0  
  if [ -n "${all}" ]  
  then  
  for x in ${all}  
  do  
  ALX_SESSIONS[${i}]=${x}  
  ((i++))  
  done  
  count=${i}  
  else  
  count=0  
  fi  
   
  export ALX_SESSIONS  
 }  
   
 get_autostart_settings()  
 {  
  #get settings from database  
  ALX_AUTOSTART=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select session from cfg_autostart where serial='${ALX_SERIAL}'")  
   
  export ALX_SESSIONS  
8  }  }
9    
10  generate_ica_session_files()  # helper function to create citrix session files
11    generate_ica_session_file()
12  {  {
  local all_ids  
13   local i   local i
14   local x   local num
  local k  
15   local server   local server
16   local ses_session   local ses_session
17   local ses_filename   local ses_filename
# Line 52  generate_ica_session_files() Line 19  generate_ica_session_files()
19   local ses_domain   local ses_domain
20   local ses_password   local ses_password
21   local ses_browseradrs   local ses_browseradrs
22     local ses_colors
23     local CONFIG
24    
25     # very basic getops
26     for i in $*
27     do
28     case $1 in
29     --session) shift; ses_session="$1" ;;
30     --filename) shift; ses_filename="$1" ;;
31     --username) shift; ses_username="$1" ;;
32     --password) shift; ses_password="$1" ;;
33     --domain) shift; ses_domain="$1" ;;
34     --server) shift; ses_browseradrs="$1" ;;
35     --colordepth) shift; ses_colors="$1" ;;
36     esac
37     shift
38     done
39    
40     # abort if session, filename or server not given
41     [[ -z ${ses_session} ]] && return 1
42     [[ -z ${ses_filename} ]] && return 1
43     [[ -z ${ses_browseradrs} ]] && return 1
44    
45     # write session files
46     CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}"
47     clearconfig
48    
49     addconfig '[WFClient]'
50     addconfig 'Version=2'
51    
52   #get settings from database   # use ';' as ifs
53   all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   declare -i i=0
54   "select id from cfg_sessions where serial='${ALX_SERIAL}'")   for server in ${ses_browseradrs//;/ }
55     do
56   declare -i x=0   (( i++ ))
57   for i in ${all_ids}   num="${i}"
58   do   # support newer ica-clients:
59   # get settings   # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !!
60   ses_session[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   [[ ${i} -eq 1 ]] && num=""
61   "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   addconfig "TcpBrowserAddress${num}=${server}"
62     addconfig "HttpBrowserAddress${num}=${server}"
  ses_filename[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_username[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_domain[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_password[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_browseradrs[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  # write session files  
  echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  OLD_IFS="$IFS"  
  IFS=";"  
  declare -i k=0  
  for server in ${ses_browseradrs[${x}]}  
  do  
  (( k++ ))  
  echo "TcpBrowserAddress${k}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  done  
  IFS="${OLD_IFS}"  
  unset k  
  unset OLD_IFS  
   
  echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
   
  echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "${ses_session[${x}]}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
   
  echo "[${ses_session[${x}]}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Address=${ses_session[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "InitialProgram=#${ses_session[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'DesiredColor=3' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'TransportDriver=TCP/IP' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'WinStationDriver=ICA 3.0' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "ClearPassword=${ses_password[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Username=${ses_username[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Domain=${ses_domain[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
63   done   done
64    
65   (( x++ ))   addconfig 'ScreenPercent=0'
66     addconfig '[ApplicationServers]'
67     addconfig "${ses_session}="
68     addconfig "[${ses_session}]"
69     addconfig "Address=${ses_session}"
70     addconfig "InitialProgram=#${ses_session}"
71    
72     # convert to ica session file values
73     case ${ses_colors} in
74     24|32) ses_colors="8";;
75     16) ses_colors="4";;
76     8) ses_colors="2";;
77     *) ses_colors="4";; # default to 16bit
78     esac
79     addconfig "DesiredColor=${ses_colors}"
80     addconfig 'TransportDriver=TCP/IP'
81     addconfig 'WinStationDriver=ICA 3.0'
82     addconfig "ClearPassword=${ses_password}"
83     addconfig "Username=${ses_username}"
84     addconfig "Domain=${ses_domain}"
85     addconfig 'UseFullScreen=Yes'
86     addconfig 'NoWindowManager=True'
87  }  }
88    
89  config_sessions()  # generates a sh file to start programs
90    generate_program_sh()
91  {  {
92   # generate ica session files   local dest
93   generate_ica_session_files   local name
94     local exec
95     local param
96     local workdir
97     local CONFIG
98    
99   #first of all get the vars   # very basic getops
100   get_sessions_settings   for i in $*
101   get_autostart_settings   do
102     case $1 in
103     --name|-n) shift; name="$1" ;;
104     --exec|-x) shift; exec="$1" ;;
105     --param|-p) shift; param="$1" ;;
106     --dest|-d) shift; dest="$1" ;;
107     --workdir|-w) shift; workdir="$1" ;;
108     esac
109     shift
110     done
111    
112     # abort if name, dest or exec not given
113     [[ -z ${name} ]] && return 1
114     [[ -z ${exec} ]] && return 1
115     [[ -z ${dest} ]] && return 1
116    
117     CONFIG="${dest}"
118     addconfig "#!/bin/sh"
119     [ -n "${workdir}" ] && addconfig "cd ${workdir}"
120     addconfig "exec ${exec} ${param}"
121    
122     chmod 0755 "${dest}"
123    }
124    
125   local count=${#ALX_SESSIONS[*]}  # helper functions for generate all desktop icons
126    generate_icon()
127    {
128     local name
129   local icon   local icon
130     local command
131     local dest
132     local yres
133     local xres
134     local iwidth
135     local iheight
136     local deficon
137     local CONFIG
138     local utility
139    
140     # very basic getops
141     for i in $*
142     do
143     case $1 in
144     --name|-n) shift; name="$1" ;;
145     --command|-c) shift; command="$1" ;;
146     --icon|-i) shift; icon="$1" ;;
147     --dest|-d) shift; dest="$1" ;;
148     --xres|-x) shift; xres="$1" ;;
149     --yres|-y) shift; yres="$1" ;;
150     --icon-width|-w) shift; iwidth="$1" ;;
151     --icon-height|-h) shift; iheight="$1" ;;
152     --default-icon) shift; deficon="$1" ;;
153     esac
154     shift
155     done
156    
157     # some sanity checks:
158    
159     # abort if name or command not given
160     [[ -z ${name} ]] && return 1
161     [[ -z ${command} ]] && return 1
162    
163     [[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk"
164    
165     # use some defaults for icon, dest, {x,y}res
166     [[ -z ${xres} ]] && xres=50
167     [[ -z ${yres} ]] && xres=50
168     if [[ -z ${icon} ]] || [ ! -f ${icon} ]
169     then
170     # if no default icon is given use default.png
171     [[ -z ${deficon} ]] && deficon="default.png"
172     icon="${ALX_SESSIONS_ICONS}/${deficon}"
173     fi
174    
175     CONFIG="${dest}"
176     clearconfig
177    
178     addconfig 'table Icon'
179     addconfig "  Caption: ${name}"
180     addconfig "  Command: ${command}"
181     addconfig "  Icon: ${icon}"
182     addconfig "  X: ${xres}"
183     addconfig "  Y: ${yres}"
184    
185     # add these only if not zero
186     if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]
187     then
188     addconfig "  Width: ${iwidth}"
189     addconfig "  Height: ${iheight}"
190     fi
191    
192     addconfig 'end'
193    }
194    
195    generate_all_desktop_icons()
196    {
197     local session_list="$1"
198     local other_menuitem_list="$2"
199     local plugin_list="$3"
200     local res
201     local xres
202     local yres
203     local x
204     local y
205     local i
206     local name
207     local progsh_path
208     local utility
209     local dest
210     local rc
211    
212     dest="${ALX_UNPRIV_HOME}/.idesktop"
213     rc="${ALX_UNPRIV_HOME}/.ideskrc"
214    
215     # progsh path
216     progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
217    
218     # get the resolution
219     res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")
220    
221     # split res to x & y
222     xres="${res%x*}"
223     yres="${res#*x}"
224    
225     # top left edge of the icon is given in config file
226     # remove a little bit to simulate the bottom-right edge
227     xres="$(( ${xres} - 120 ))"
228     yres="$(( ${yres} - 80 ))"
229    
230     # clean desktop icon location
231     [ -d ${dest} ] && rm -rf ${dest}
232     [ -f ${rc} ] && rm -f ${rc}
233     install -d ${dest}
234    
235     # default settings
236     declare -i x=50
237     declare -i y=50
238    
239     # ica icons
240     for i in ${session_list}
241     do
242     # abort if empty
243     [[ -z ${i} ]] && continue
244    
245     # get database information
246     evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
247    
248     # new line if x > xres
249     if [ ${x} -ge ${xres} ]
250     then
251     x=50
252     y=$((${y} + 80))
253     fi
254    
255     # new row if y > yres
256     if [ ${y} -ge ${yres} ]
257     then
258     x=$((${x} + 120))
259     y=50
260    
261     # re-check x
262     [ ${x} -ge ${xres} ] && x=50
263     fi
264    
265     generate_icon \
266     --name "${cfg_sessions_session}" \
267     --command "wfica-launcher ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \
268     --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \
269     --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \
270     --xres "${x}" \
271     --yres "${y}"
272    
273     y=$((${y} + 80))
274     done
275    
276     for i in ${other_menuitem_list}
277     do
278     # abort if empty
279     [[ -z ${i} ]] && continue
280    
281     # get database information
282     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
283    
284     # new line if x > xres
285     if [ ${x} -ge ${xres} ]
286     then
287     x=50
288     y=$((${y} + 80))
289     fi
290    
291     # new row if y > yres
292     if [ ${y} -ge ${yres} ]
293     then
294     x=$((${x} + 120))
295     y=50
296    
297     # re-check x
298     [ ${x} -ge ${xres} ] && x=50
299     fi
300    
301     generate_icon \
302     --name "${cfg_other_menuitems_name}" \
303     --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
304     --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_icon}).png" \
305     --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \
306     --xres "${x}" \
307     --yres "${y}" \
308     --default-icon "default_item.png"
309    
310   # DEBUG   y=$((${y} + 80))
311  # declare -i i=0   done
312  # echo count=${count}  
313  # echo "Number of new sessions: ${count}"   for i in ${plugin_list}
314  # for ((i=0; i < count; i++))   do
315  # do   # abort if empty
316  # echo "${i} - ${ALX_SESSIONS[${i}]}"   [[ -z ${i} ]] && continue
317  # done  
318     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
319     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
320     then
321     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem)
322    
323     # abort if name or exec is empty
324     [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue
325     [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue
326    
327     # new line if x > xres
328     if [ ${x} -ge ${xres} ]
329     then
330     x=50
331     y=$((${y} + 80))
332     fi
333    
334     # new row if y > yres
335     if [ ${y} -ge ${yres} ]
336     then
337     x=$((${x} + 120))
338     y=50
339    
340     # re-check x
341     [ ${x} -ge ${xres} ] && x=50
342     fi
343    
344     generate_icon \
345     --name "${PLUGIN_MENUITEM_NAME}" \
346     --command "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \
347     --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).png" \
348     --dest "${dest}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).lnk" \
349     --xres "${x}" \
350     --yres "${y}" \
351     --default-icon "default_item.png"
352    
353     y=$((${y} + 80))
354     fi
355    
356     # unset all variables
357     unset PLUGIN_MENUITEM_NAME
358     unset PLUGIN_MENUITEM_EXEC
359     unset PLUGIN_MENUITEM_PARAM
360     unset PLUGIN_MENUITEM_WORKDIR
361     unset PLUGIN_MENUITEM_ICON
362     done
363    
364     # add shutdown, reboot icons
365     for i in shutdown reboot
366     do
367     # new line if x > xres
368     if [ ${x} -ge ${xres} ]
369     then
370     x=50
371     y=$((${y} + 80))
372     fi
373    
374     # new row if y > yres
375     if [ ${y} -ge ${yres} ]
376     then
377     x=$((${x} + 120))
378     y=50
379    
380     # re-check x
381     [ ${x} -ge ${xres} ] && x=50
382     fi
383    
384     case ${i} in
385     shutdown) name="Herunterfahren" ;;
386     reboot) name="Neustarten" ;;
387     esac
388    
389     generate_icon \
390     --name "${name}" \
391     --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \
392     --icon "${ALX_SESSIONS_ICONS}/${i}.png" \
393     --dest "${dest}/${i}.lnk" \
394     --xres "${x}" \
395     --yres "${y}" \
396     --icon-width "40" \
397     --icon-height "40"
398    
399     y=$((${y} + 80))
400     done
401    
402     # last but not least gen a icon with some sys informations
403     local sysinfo
404     local hostname
405     local osversion
406    
407     osversion="$(< /etc/mageversion)"
408     hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'")
409     sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
410    
411     # now get the right position:
412     # restore orig values of xres
413     xres="$(( ${xres} + 120 ))"
414     # default y pos (full yres -22 = cur yres + 58 !)
415     yres="$(( ${yres} + 58 ))"
416     # middle of the screen
417     # (no txt - length required, xtdesk manage that itself)
418     xres="$(( ${xres} / 2))"
419    
420     generate_icon \
421     --name "${sysinfo}" \
422     --command "exit 0" \
423     --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
424     --dest "${dest}/sysinfo.lnk" \
425     --xres "${xres}" \
426     --yres "${yres}" \
427     --icon-width "1" \
428     --icon-height "1"
429    }
430    
431    config_sessions()
432    {
433     local i
434     local all_ses_ids
435     local all_other_ids
436     local CONFIG
437     local screensaver_passwd_cmd
438     local fbinit
439     local fbkeys
440     local progsh_path
441    
442     progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
443    
444     # get all session ids from database
445     all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")
446     # get all other_menuitem ids from database
447     all_other_ids=$(mysqldo "select id from cfg_other_menuitems where serial='${ALX_SERIAL}'")
448     # get all plugin ids from database
449     all_plugin_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'")
450    
451     # get screensaver settings
452     evaluate_table cfg_screensaver
453     # get autostart settings
454     evaluate_table cfg_autostart
455     # get current color depth
456     evaluate_table cfg_graphic
457    
458   # now setup fluxbox for user station   # now setup fluxbox for user station
459    
# Line 145  config_sessions() Line 464  config_sessions()
464   # now generate fluxbox config files   # now generate fluxbox config files
465    
466   # fluxbox main config   # fluxbox main config
467   cat ${ALX_SKELETONS}/fluxbox/init \   if [ -f ${ALX_SKELETONS}/fluxbox/init ]
468   > ${ALX_UNPRIV_HOME}/.fluxbox/init   then
469     fbinit="${ALX_SKELETONS}/fluxbox/init"
470     else
471     fbinit="/usr/share/fluxbox/init"
472     fi
473     cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init
474    
475   # fluxbox autostart   # fluxbox autostart
476   cat ${ALX_SKELETONS}/fluxbox/apps \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
477   > ${ALX_UNPRIV_HOME}/.fluxbox/apps   # do not show decorations on messages generated with xmessage
478     if [ -x /usr/bin/xmessage ]
479     then
480     addconfig '[app] (xmessage)'
481     addconfig ' [Deco] {NONE}'
482     addconfig '[end]'
483     fi
484     # add icon utility
485     [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
486     # add numlock utility
487     [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
488    
489     # add screensaver
490     if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]]
491     then
492     if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]]
493     then
494     screensaver_passwd_cmd="-nolock"
495     else
496     screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})"
497     fi
498    
499     addconfig "[startup] {nohup xautolock -time ${cfg_screensaver_timeout} -locker 'xlock -mode ${cfg_screensaver_screensaver} ${screensaver_passwd_cmd}' > /dev/null &}"
500     fi
501    
502     # add plugins autostart
503     for i in ${all_plugin_ids}
504     do
505     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
506     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
507     then
508     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh autostart)
509    
510     if [[ ${PLUGIN_AUTOSTART} = 1 ]]
511     then
512     addconfig "[startup] {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}) &}"
513     fi
514     # unset all variables
515     unset PLUGIN_AUTOSTART
516     unset PLUGIN_MENUITEM_NAME
517     fi
518     done
519    
520   # add autostart session   # add autostart session
521   if [[ ${ALX_AUTOSTART} != "" ]]   if [[ ! -z ${cfg_autostart_session} ]]
522   then   then
523   echo "[startup] {wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \   # sleep one second to wait until busybox is fully initialized and the screen is really centered
524   >> ${ALX_UNPRIV_HOME}/.fluxbox/apps   addconfig "[startup] {sleep 1 && wfica-launcher ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_autostart_session}) &}"
525   fi   fi
526    
527   # fluxbox hotkeys   # fluxbox hotkeys
528   cat ${ALX_SKELETONS}/fluxbox/apps \   if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
529   > ${ALX_UNPRIV_HOME}/.fluxbox/keys   then
530     fbkeys="${ALX_SKELETONS}/fluxbox/keys"
531     else
532     fbkeys="/usr/share/fluxbox/keys"
533     fi
534     cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys
535    
536   # fluxbox menu header   # generate a fluxbox menu
537   cat ${ALX_SKELETONS}/fluxbox/menu.header \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
538   > ${ALX_UNPRIV_HOME}/.fluxbox/menu   clearconfig
539    
540     # fluxbox menu header
541     cat ${ALX_SKELETONS}/fluxbox/menu.header >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
542     # now fix it with proper messages :P
543     local ver="$(< /etc/mageversion)"
544     sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu
545   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
546   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   addconfig
547    
548   # fluxbox menu sessions   # first generate session files
549   for (( i=0; i < count; i++ ))   for i in ${all_ses_ids}
550   do   do
551   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \   evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
552   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   generate_ica_session_file \
553     --session "${cfg_sessions_session}" \
554     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
555     --username "${cfg_sessions_username}" \
556     --password "${cfg_sessions_password}" \
557     --domain "${cfg_sessions_domain}" \
558     --server "${cfg_sessions_browseradrs}" \
559     --colordepth "${cfg_graphic_depth}"
560    
561     # fluxbox menusession
562     addconfig "[exec] (${cfg_sessions_session}) {wfica-launcher ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})}"
563   done   done
564    
565   # fluxbox menu footer   # delete all progs
566   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   [ -d ${progsh_path} ] && rm -rf ${progsh_path}
567   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   install -d ${progsh_path}
568    
569   # add a newline (maybe there is no crlf in the footer)   # add other menuitems
570   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   for i in ${all_other_ids}
571     do
572     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
573    
574   # now we generate the desktop icons   # now echo config line for fluxbox-menu
575   cat ${ALX_SKELETONS}/idesk/ideskrc \   # make it "configureable" :p
576   > ${ALX_UNPRIV_HOME}/.ideskrc   if [[ -n ${cfg_other_menuitems_workdir} ]]
577     then
578   # whipe out old stuff and install a fresh directory   workdir="--workdir ${cfg_other_menuitems_workdir}"
579   [ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop   fi
580   install -d ${ALX_UNPRIV_HOME}/.idesktop   if [[ -n ${cfg_other_menuitems_icon} ]]
581     then
582     cfg_other_menuitems_icon="<${cfg_other_menuitems_icon}>"
583     fi
584    
585   local name   # gen prog startup wrapper
586   for (( i=0; i < count; i++ ))   generate_program_sh \
587   do   --name "${cfg_other_menuitems_name}" \
588   name="$(basename ${ALX_SESSIONS[${i}]} .ica)"   --exec "${cfg_other_menuitems_exec}" \
589     --param "${cfg_other_menuitems_param}" \
590     --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
591     "${workdir}"
592    
593   if [ -f ${ALX_SESSIONS_ICONS}/${name}.png ]   addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}"
594     done
595    
596     # add plugins
597     for i in ${all_plugin_ids}
598     do
599     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
600     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
601   then   then
602   icon="${ALX_SESSIONS_ICONS}/${name}.png"   eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem)
603   else  
604   icon="${ALX_SESSIONS_ICONS}/default.png"   # abort if name or exec is empty
605     [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue
606     [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue
607    
608     # now echo config line for fluxbox-menu
609     # make it "configureable" :p
610     if [[ -n ${PLUGIN_MENUITEM_WORKDIR} ]]
611     then
612     workdir="--workdir ${PLUGIN_MENUITEM_WORKDIR}"
613     fi
614     if [[ -n ${PLUGIN_MENUITEM_ICON} ]]
615     then
616     PLUGIN_MENUITEM_ICON="<${PLUGIN_MENUITEM_ICON}>"
617     fi
618    
619     # gen prog startup wrapper
620     generate_program_sh \
621     --name "${PLUGIN_MENUITEM_NAME}" \
622     --exec "${PLUGIN_MENUITEM_EXEC}" \
623     --param "${PLUGIN_MENUITEM_PARAM}" \
624     --dest "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \
625     "${workdir}"
626    
627     addconfig "[exec] (${PLUGIN_MENUITEM_NAME}) {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})} ${PLUGIN_MENUITEM_ICON}"
628   fi   fi
629    
630   echo "table Icon   # unset all variables
631  Caption: ${name}   unset PLUGIN_MENUITEM_NAME
632  Command: wfica ${ALX_ICA_SESSIONS}/${name}.ica   unset PLUGIN_MENUITEM_EXEC
633  Icon: ${icon}   unset PLUGIN_MENUITEM_PARAM
634  end" > ${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk   unset PLUGIN_MENUITEM_WORKDIR
635     unset PLUGIN_MENUITEM_ICON
636   done   done
637    
638   # set correct permissions   # fluxbox menu footer
639     cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
640     # add a newline (maybe there is no crlf in the footer)
641     addconfig
642    
643     # now it's a good time to generate *all* icons :)
644     generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}" "${all_plugin_ids}"
645    
646     # fix permissions
647   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
648   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
649   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
650   chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop
  chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc  
   
   
  # unset vars  
  unset ALX_SESSIONS  
651  }  }

Legend:
Removed from v.246  
changed lines
  Added in v.6763