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 304 by niro, Sun Aug 28 19:29:35 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.11 2005-08-28 19:29:35 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}'")  
   
  # 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_AUTOSTART  
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
15   local server   local server
16   local ses_session   local ses_session
17   local ses_filename   local ses_filename
# Line 51  generate_ica_session_files() Line 20  generate_ica_session_files()
20   local ses_password   local ses_password
21   local ses_browseradrs   local ses_browseradrs
22   local ses_colors   local ses_colors
23     local CONFIG
24    
25   # get settings from database   # very basic getops
26   all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   for i in $*
27   "select id from cfg_sessions where serial='${ALX_SERIAL}'")   do
28     case $1 in
29   for i in ${all_ids}   --session) shift; ses_session="$1" ;;
30   do   --filename) shift; ses_filename="$1" ;;
31   # get settings   --username) shift; ses_username="$1" ;;
32   ses_session=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   --password) shift; ses_password="$1" ;;
33   "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --domain) shift; ses_domain="$1" ;;
34     --server) shift; ses_browseradrs="$1" ;;
35   ses_filename=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   --colordepth) shift; ses_colors="$1" ;;
  "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_username=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_domain=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_password=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_browseradrs=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  # get the right colors  
  ses_colors=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select depth from cfg_graphic where serial='${ALX_SERIAL}'")  
  case ${ses_colors} in  
  24) ses_colors="8";;  
  16) ses_colors="4";;  
  8) ses_colors="2";;  
  *) ses_colors="2";;  
36   esac   esac
37     shift
  # write session files  
  echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  OLD_IFS="$IFS"  
  IFS=";"  
  declare -i x=0  
  for server in ${ses_browseradrs}  
  do  
  (( x++ ))  
  echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  done  
  IFS="${OLD_IFS}"  
  unset x  
  unset OLD_IFS  
   
  echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
   
  echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
   
  echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "DesiredColor=${ses_colors}" >> ${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}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Username=${ses_username}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Domain=${ses_domain}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
38   done   done
 }  
39    
40  get_other_menuitems()   # abort if session, filename or server not given
41  {   [[ -z ${ses_session} ]] && return 1
42   local x i count name exec icon workdir   [[ -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   # all arrays:   addconfig '[WFClient]'
50   # ->  session1 session2 ... sessionN   addconfig 'Version=2'
51    
52   # get settings from database   # use ';' as ifs
53   count=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   declare -i i=0
54   "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")   for server in ${ses_browseradrs//;/ }
55     do
56     (( i++ ))
57     num="${i}"
58     # support newer ica-clients:
59     # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !!
60     [[ ${i} -eq 1 ]] && num=""
61     addconfig "TcpBrowserAddress${num}=${server}"
62     addconfig "HttpBrowserAddress${num}=${server}"
63     done
64    
65   # get all instances and put them into an array   addconfig 'ScreenPercent=0'
66   if [ -n "${count}" ]   addconfig '[ApplicationServers]'
67   then   addconfig "${ses_session}="
68   for x in ${count}   addconfig "[${ses_session}]"
69   do   addconfig "Address=${ses_session}"
70   # to be sure   addconfig "InitialProgram=#${ses_session}"
71   unset name  
72   unset exec   # convert to ica session file values
73   unset workdir   case ${ses_colors} in
74   unset icon   24|32) ses_colors="8";;
75     16) ses_colors="4";;
76   name=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   8) ses_colors="2";;
77   "select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")   *) ses_colors="4";; # default to 16bit
78     esac
79   exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   addconfig "DesiredColor=${ses_colors}"
80   "select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")   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   workdir=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  # generates a sh file to start programs
90   "select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  generate_program_sh()
91    {
92     local dest
93     local name
94     local exec
95     local param
96     local workdir
97     local CONFIG
98    
99   icon=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   # very basic getops
100   "select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")   for i in $*
101     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   # debug only   # abort if name, dest or exec not given
113   #echo "DEBUG: ${x}: name:'${name}' exec:'${exec}' workdir:'${workdir}' ic$   [[ -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   # now echo config line for fluxbox-menu   chmod 0755 "${dest}"
  # make it "configureable" :P  
  [ -n "${workdir}" ] && workdir="cd ${workdir};"  
  [ -n "${icon}" ] && icon="[${icon}]"  
  echo "[exec] (${name}) {${workdir}${exec}} ${icon}"  
  done  
  fi  
123  }  }
124    
   
125  # helper functions for generate all desktop icons  # helper functions for generate all desktop icons
126  generate_icon()  generate_icon()
127  {  {
# Line 179  generate_icon() Line 133  generate_icon()
133   local xres   local xres
134   local iwidth   local iwidth
135   local iheight   local iheight
136     local deficon
137     local CONFIG
138     local utility
139    
140   # very basic getops   # very basic getops
141   for i in $*   for i in $*
# Line 192  generate_icon() Line 149  generate_icon()
149   --yres|-y) shift; yres="$1" ;;   --yres|-y) shift; yres="$1" ;;
150   --icon-width|-w) shift; iwidth="$1" ;;   --icon-width|-w) shift; iwidth="$1" ;;
151   --icon-height|-h) shift; iheight="$1" ;;   --icon-height|-h) shift; iheight="$1" ;;
152           esac   --default-icon) shift; deficon="$1" ;;
153     esac
154   shift   shift
155   done   done
156    
157   # some sanity checks :   # some sanity checks:
158    
159   # abort if name or command not given   # abort if name or command not given
160   [ -z "${name}" ] && return 1   [[ -z ${name} ]] && return 1
161   [ -z "${command}" ] && return 1   [[ -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   # use some defaults for icon, dest, {x,y}res
166   [ -z "${xres}" ] && xres=20   [[ -z ${xres} ]] && xres=50
167   [ -z "${yres}" ] && xres=20   [[ -z ${yres} ]] && xres=50
168   [ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"   if [[ -z ${icon} ]] || [ ! -f ${icon} ]
  if [ -z "${icon}" ] || [ ! -f "${icon}" ]  
169   then   then
170   icon="${ALX_SESSIONS_ICONS}/default.png"   # if no default icon is given use default.png
171     [[ -z ${deficon} ]] && deficon="default.png"
172     icon="${ALX_SESSIONS_ICONS}/${deficon}"
173   fi   fi
174    
175   echo "table Icon" > ${dest}   CONFIG="${dest}"
176   echo "  Type: Program" >> ${dest}   clearconfig
177   echo "  Caption: ${name}" >> ${dest}  
178   echo "  Command: ${command}" >> ${dest}   addconfig 'table Icon'
179   echo "  Icon: ${icon}" >> ${dest}   addconfig "  Caption: ${name}"
180   echo "  X: ${xres}" >> ${dest}   addconfig "  Command: ${command}"
181   echo "  Y: ${yres}" >> ${dest}   addconfig "  Icon: ${icon}"
182     addconfig "  X: ${xres}"
183     addconfig "  Y: ${yres}"
184    
185   # add these only if not zero   # add these only if not zero
186   if [ -n "${iwidth}" ] && [ -n "${iheight}" ]   if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]
187   then   then
188   echo "  IconWidth: ${iwidth}" >> ${dest}   addconfig "  Width: ${iwidth}"
189   echo "  IconHeight: ${iheight}" >> ${dest}   addconfig "  Height: ${iheight}"
190   fi   fi
191    
192   echo "end" >> ${dest}   addconfig 'end'
193  }  }
194    
195  generate_all_desktop_icons()  generate_all_desktop_icons()
196  {  {
197     local session_list="$1"
198     local other_menuitem_list="$2"
199     local plugin_list="$3"
200   local res   local res
201   local xres   local xres
202   local yres   local yres
  local icon_list  
203   local x   local x
204   local y   local y
205   local item   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   # get the resolution
219   res=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")
  "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")  
220    
221   # split res to x & y   # split res to x & y
222   xres="$(echo ${res} | cut -dx -f1)"   xres="${res%x*}"
223   yres="$(echo ${res} | cut -dx -f2)"   yres="${res#*x}"
224    
225   # top left edge of the icon is given in config file   # top left edge of the icon is given in config file
226   # remove a little bit to simulate the bottom-right edge   # remove a little bit to simulate the bottom-right edge
227   xres="$(( ${xres} - 120 ))"   xres="$(( ${xres} - 120 ))"
228   yres="$(( ${yres} - 80 ))"   yres="$(( ${yres} - 80 ))"
229    
  # basic config  
  cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc  
   
230   # clean desktop icon location   # clean desktop icon location
231   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop   [ -d ${dest} ] && rm -rf ${dest}
232   install -d ${ALX_UNPRIV_HOME}/.xtdesktop   [ -f ${rc} ] && rm -f ${rc}
233     install -d ${dest}
234    
235   # default settings   # default settings
236   declare -i x=20   declare -i x=50
237   declare -i y=20   declare -i y=50
238    
239   # first all ica sessions   # ica icons
240   local count=${#ALX_SESSIONS[*]}   for i in ${session_list}
  for (( i=0; i < count; i++ ))  
241   do   do
242   icon_list="${icon_list} $(basename ${ALX_SESSIONS[${i}] .ica})"   # 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   done
275    
276   for item in ${icon_list}   for i in ${other_menuitem_list}
277   do   do
278   # abort if empty   # abort if empty
279   [ -z "${item}" ] && continue   [[ -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   # new line if x > xres
285   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ]
286   x=20   then
287     x=50
288   y=$((${y} + 80))   y=$((${y} + 80))
289   fi   fi
290    
291   # new row if y > yres   # new row if y > yres
292   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ]
293     then
294   x=$((${x} + 120))   x=$((${x} + 120))
295   y=20   y=50
296    
297   # re-check x   # re-check x
298   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=50
299   fi   fi
300    
301   generate_icon \   generate_icon \
302   --name "${item}" \   --name "${cfg_other_menuitems_name}" \
303   --command "wfica ${ALX_ICA_SESSIONS}/${item}.ica" \   --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
304   --icon "${ALX_SESSIONS_ICONS}/${item}.png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_icon}).png" \
305   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \   --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \
306   --xres "${x}" \   --xres "${x}" \
307   --yres "${y}"   --yres "${y}" \
308     --default-icon "default_item.png"
309    
310   y=$((${y} + 80))   y=$((${y} + 80))
311   done   done
312    
313     for i in ${plugin_list}
314     do
315     # abort if empty
316     [[ -z ${i} ]] && continue
317    
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   # last but not least gen a icon with some sys informations
403   local sysinfo   local sysinfo
# Line 309  generate_all_desktop_icons() Line 405  generate_all_desktop_icons()
405   local osversion   local osversion
406    
407   osversion="$(< /etc/mageversion)"   osversion="$(< /etc/mageversion)"
408   hostname=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'")
  "select hostname from cfg_network where serial='${ALX_SERIAL}'")  
409   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
410    
411   # now get the right position:   # now get the right position:
# Line 326  generate_all_desktop_icons() Line 421  generate_all_desktop_icons()
421   --name "${sysinfo}" \   --name "${sysinfo}" \
422   --command "exit 0" \   --command "exit 0" \
423   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
424   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \   --dest "${dest}/sysinfo.lnk" \
425   --xres "${xres}" \   --xres "${xres}" \
426   --yres "${yres}" \   --yres "${yres}" \
427   --icon-width "1" \   --icon-width "1" \
# Line 335  generate_all_desktop_icons() Line 430  generate_all_desktop_icons()
430    
431  config_sessions()  config_sessions()
432  {  {
  # generate ica session files  
  generate_ica_session_files  
   
  # first of all get the vars  
  get_sessions_settings  
  get_autostart_settings  
   
  local count=${#ALX_SESSIONS[*]}  
  local icon  
433   local i   local i
434     local all_ses_ids
435   # DEBUG   local all_other_ids
436  # declare -i i=0   local CONFIG
437  # echo count=${count}   local screensaver_passwd_cmd
438  # echo "Number of new sessions: ${count}"   local fbinit
439  # for ((i=0; i < count; i++))   local fbkeys
440  # do   local progsh_path
441  # echo "${i} - ${ALX_SESSIONS[${i}]}"  
442  # done   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 364  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   # now fix it with proper messages :P
543   local ver="$(< /etc/mageversion)"   local ver="$(< /etc/mageversion)"
544   sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" \   sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu
  ${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   [ -n "${ALX_SESSIONS[${i}]}" ] && \   evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
552   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \   generate_ica_session_file \
553   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   --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     # delete all progs
566     [ -d ${progsh_path} ] && rm -rf ${progsh_path}
567     install -d ${progsh_path}
568    
569   # add other menuitems   # add other menuitems
570   get_other_menuitems >> ${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   # fluxbox menu footer   # now echo config line for fluxbox-menu
575   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   # make it "configureable" :p
576   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   if [[ -n ${cfg_other_menuitems_workdir} ]]
577     then
578     workdir="--workdir ${cfg_other_menuitems_workdir}"
579     fi
580     if [[ -n ${cfg_other_menuitems_icon} ]]
581     then
582     cfg_other_menuitems_icon="<${cfg_other_menuitems_icon}>"
583     fi
584    
585     # gen prog startup wrapper
586     generate_program_sh \
587     --name "${cfg_other_menuitems_name}" \
588     --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     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
602     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem)
603    
604     # 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
629    
630     # unset all variables
631     unset PLUGIN_MENUITEM_NAME
632     unset PLUGIN_MENUITEM_EXEC
633     unset PLUGIN_MENUITEM_PARAM
634     unset PLUGIN_MENUITEM_WORKDIR
635     unset PLUGIN_MENUITEM_ICON
636     done
637    
638     # 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)   # add a newline (maybe there is no crlf in the footer)
641   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   addconfig
642    
643   # now it's a good time to generate *all* icons :)   # now it's a good time to generate *all* icons :)
644   generate_all_desktop_icons   generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}" "${all_plugin_ids}"
645    
646   # set correct permissions   # 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}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop
  chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc  
   
  # unset vars  
  unset ALX_SESSIONS  
651  }  }

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