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/branches/alxconf_20060908/functions/config_sessions.sh revision 1594 by niro, Thu Dec 2 13:27:09 2010 UTC alx-src/branches/alxconf-060/functions/config_sessions.sh revision 6759 by niro, Fri Jul 17 07:38:49 2015 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.18 2006-01-26 19:55: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=$(mysqldo "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  
   
  # get settings from database  
  ALX_PROGRAMS=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")  
   
  export ALX_SESSIONS  
  export ALX_PROGRAMS  
 }  
   
 get_autostart_settings()  
 {  
  # get settings from database  
  ALX_AUTOSTART=$(mysqldo "select session from cfg_autostart where serial='${ALX_SERIAL}'")  
   
  export ALX_AUTOSTART  
 }  
   
 get_screensaver_settings()  
 {  
  ALX_SCRN_SAVER=$(mysqldo "select screensaver from cfg_screensaver where serial='${ALX_SERIAL}'")  
  ALX_SCRN_TIMEOUT=$(mysqldo "select timeout from cfg_screensaver where serial='${ALX_SERIAL}'")  
  ALX_SCRN_PASSWD=$(mysqldo "select password from cfg_screensaver where serial='${ALX_SERIAL}'")  
   
  export ALX_SCRN_SAVER  
  export ALX_SCRN_TIMEOUT  
  export ALX_SCRN_PASSWD  
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 64  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=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")   for i in $*
   
  for i in ${all_ids}  
27   do   do
28   # get settings   case $1 in
29   ses_session=$(mysqldo "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --session) shift; ses_session="$1" ;;
30   ses_filename=$(mysqldo "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --filename) shift; ses_filename="$1" ;;
31   ses_username=$(mysqldo "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --username) shift; ses_username="$1" ;;
32   ses_domain=$(mysqldo "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --password) shift; ses_password="$1" ;;
33   ses_password=$(mysqldo "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --domain) shift; ses_domain="$1" ;;
34   ses_browseradrs=$(mysqldo "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --server) shift; ses_browseradrs="$1" ;;
35     --colordepth) shift; ses_colors="$1" ;;
36   # get the right colors           esac
37   ses_colors=$(mysqldo "select depth from cfg_graphic where serial='${ALX_SERIAL}'")   shift
38   # convert to ica session file values   done
  case ${ses_colors} in  
  24) ses_colors="8";;  
  16) ses_colors="4";;  
  8) ses_colors="2";;  
  *) ses_colors="2";;  
  esac  
39    
40   # write session files   # abort if session, filename or server not given
41   echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename}   [[ -z ${ses_session} ]] && return 1
42   echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename}   [[ -z ${ses_filename} ]] && return 1
43   OLD_IFS="$IFS"   [[ -z ${ses_browseradrs} ]] && return 1
44   IFS=";"  
45   declare -i x=0   # write session files
46   for server in ${ses_browseradrs}   CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}"
47   do   clearconfig
48   (( x++ ))  
49   echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   addconfig '[WFClient]'
50   done   addconfig 'Version=2'
51   IFS="${OLD_IFS}"  
52   unset x   # use ';' as ifs
53   unset OLD_IFS   declare -i i=0
54     for server in ${ses_browseradrs//;/ }
55   echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}   do
56     (( i++ ))
57   echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}   num="${i}"
58   echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}   # support newer ica-clients:
59     # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !!
60   echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}   [[ ${i} -eq 1 ]] && num=""
61   echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   addconfig "TcpBrowserAddress${num}=${server}"
62   echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   addconfig "HttpBrowserAddress${num}=${server}"
  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}  
63   done   done
64    
65     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  # generates a sh file to start programs  # generates a sh file to start programs
# Line 128  generate_program_sh() Line 92  generate_program_sh()
92   local dest   local dest
93   local name   local name
94   local exec   local exec
95     local param
96   local workdir   local workdir
97     local CONFIG
98    
99   # very basic getops   # very basic getops
100   for i in $*   for i in $*
# Line 136  generate_program_sh() Line 102  generate_program_sh()
102   case $1 in   case $1 in
103   --name|-n) shift; name="$1" ;;   --name|-n) shift; name="$1" ;;
104   --exec|-x) shift; exec="$1" ;;   --exec|-x) shift; exec="$1" ;;
105     --param|-p) shift; param="$1" ;;
106   --dest|-d) shift; dest="$1" ;;   --dest|-d) shift; dest="$1" ;;
107   --workdir|-w) shift; workdir="$1" ;;   --workdir|-w) shift; workdir="$1" ;;
108           esac           esac
# Line 143  generate_program_sh() Line 110  generate_program_sh()
110   done   done
111    
112   # abort if name, dest or exec not given   # abort if name, dest or exec not given
113   [ -z "${name}" ] && return 1   [[ -z ${name} ]] && return 1
114   [ -z "${exec}" ] && return 1   [[ -z ${exec} ]] && return 1
115   [ -z "${dest}" ] && return 1   [[ -z ${dest} ]] && return 1
116    
117   echo "#!/bin/sh" > ${dest}   CONFIG="${dest}"
118   [ -n "${workdir}" ] && echo "cd ${workdir}" >> ${dest}   addconfig "#!/bin/sh"
119   echo "exec ${exec}" >> ${dest}   [ -n "${workdir}" ] && addconfig "cd ${workdir}"
120     addconfig "exec ${exec} ${param}"
  chmod 0755 ${dest}  
 }  
   
 get_other_menuitems()  
 {  
  local x i progsh_path name exec icon workdir  
   
  # all arrays:  
  # ->  session1 session2 ... sessionN  
   
  # get settings from database -> now stored in ALX_PROGRAMS  
   
  # abort if empty  
  [ -z "${ALX_PROGRAMS}" ] && return 0  
   
  progsh_path=${ALX_UNPRIV_HOME}/.alxprogs  
  [ -d ${progsh_path} ] && rm -rf ${progsh_path}  
  install -d ${progsh_path}  
   
  # gen menu items  
  for x in ${ALX_PROGRAMS}  
  do  
  # to be sure  
  unset name  
  unset exec  
  unset workdir  
  unset icon  
   
  name=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
  exec=$(mysqldo "select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
  workdir=$(mysqldo "select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
  icon=$(mysqldo "select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
   
  # now echo config line for fluxbox-menu  
  # make it "configureable" :P  
  [ -n "${workdir}" ] && workdir="--workdir ${workdir}"  
  [ -n "${icon}" ] && icon="<${icon}>"  
   
  # gen prog startup wrapper  
  generate_program_sh \  
  --name "${name}" \  
  --exec "${exec}" \  
  --dest "${progsh_path}/${name}" \  
  "${workdir}"  
121    
122   echo "[exec] (${name}) {${progsh_path}/${name}} ${icon}"   chmod 0755 "${dest}"
  done  
123  }  }
124    
125  # helper functions for generate all desktop icons  # helper functions for generate all desktop icons
# Line 212  generate_icon() Line 134  generate_icon()
134   local iwidth   local iwidth
135   local iheight   local iheight
136   local deficon   local deficon
137     local CONFIG
138     local utility
139    
140   # very basic getops   # very basic getops
141   for i in $*   for i in $*
# Line 230  generate_icon() Line 154  generate_icon()
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=30   [[ -z ${xres} ]] && xres=50
167   [ -z "${yres}" ] && xres=30   [[ -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   # if no default icon is given use default.png   # if no default icon is given use default.png
171   [ -z "${deficon}" ] && deficon="default.png"   [[ -z ${deficon} ]] && deficon="default.png"
172   icon="${ALX_SESSIONS_ICONS}/${deficon}"   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 basename_item   local name
207   local progsh_path   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=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")   res=$(mysqldo "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=30   declare -i x=50
237   declare -i y=30   declare -i y=50
   
  # first all ica sessions  
  local count=${#ALX_SESSIONS[*]}  
  for (( i=0; i < count; i++ ))  
  do  
  # filenames !  
  icon_list="${icon_list} ${ALX_SESSIONS[${i}]}"  
  done  
238    
239   for item in ${icon_list}   # ica icons
240     for i in ${session_list}
241   do   do
242   # abort if empty   # abort if empty
243   [ -z "${item}" ] && continue   [[ -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   # new line if x > xres
249   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ]
250   x=30   then
251     x=50
252   y=$((${y} + 80))   y=$((${y} + 80))
253   fi   fi
254    
255   # new row if y > yres   # new row if y > yres
256   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ]
257     then
258   x=$((${x} + 120))   x=$((${x} + 120))
259   y=30   y=50
260    
261   # re-check x   # re-check x
262   [ ${x} -ge ${xres} ] && x=30   [ ${x} -ge ${xres} ] && x=50
263   fi   fi
264    
  # ica icons  
  # get basename (.ica must be suffix)  
  basename_item="$(basename ${item} .ica)"  
265   generate_icon \   generate_icon \
266   --name "${basename_item}" \   --name "${cfg_sessions_session}" \
267   --command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \   --command "wfica-launcher ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \
268   --icon "${ALX_SESSIONS_ICONS}/${basename_item}.png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \
269   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${basename_item}.lnk" \   --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \
270   --xres "${x}" \   --xres "${x}" \
271   --yres "${y}"   --yres "${y}"
272    
273   y=$((${y} + 80))   y=$((${y} + 80))
274   done   done
275    
276     for i in ${other_menuitem_list}
  # generate program icons  
  icon_list="${ALX_PROGRAMS}"  
   
  progsh_path=${ALX_UNPRIV_HOME}/.alxprogs  
   
  for item in ${icon_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=30   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=30   y=50
296    
297   # re-check x   # re-check x
298   [ ${x} -ge ${xres} ] && x=30   [ ${x} -ge ${xres} ] && x=50
299   fi   fi
300    
301   generate_icon \   generate_icon \
302   --name "${item}" \   --name "${cfg_other_menuitems_name}" \
303   --command "${progsh_path}/${item}" \   --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"   --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 405  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 414  generate_all_desktop_icons() Line 430  generate_all_desktop_icons()
430    
431  config_sessions()  config_sessions()
432  {  {
433   # generate ica session files   local i
434   generate_ica_session_files   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   # first of all get the vars   progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
  get_sessions_settings  
  get_autostart_settings  
  get_screensaver_settings  
443    
444   local count=${#ALX_SESSIONS[*]}   # get all session ids from database
445   local icon   all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")
446   local i   # 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 435  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   # add screensaver
490   if [[ -n ${ALX_SCRN_SAVER} ]] && [[ -n ${ALX_SCRN_TIMEOUT} ]]   if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]]
491   then   then
492   local ALX_PASSWD_CMD   if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]]
   
  if [[ -z ${ALX_SCRN_PASSWD} ]] || [[ ${ALX_SCRN_PASSWD} = NULL ]]  
493   then   then
494   ALX_PASSWD_CMD="-nolock"   screensaver_passwd_cmd="-nolock"
495   else   else
496   ALX_PASSWD_CMD="-cpasswd $(openssl passwd ${ALX_SCRN_PASSWD})"   screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})"
497   fi   fi
498    
499   echo "[startup] {nohup xautolock -time ${ALX_SCRN_TIMEOUT} -locker 'xlock -mode ${ALX_SCRN_SAVER} ${ALX_PASSWD_CMD}' > /dev/null &}" \   addconfig "[startup] {nohup xautolock -time ${cfg_screensaver_timeout} -locker 'xlock -mode ${cfg_screensaver_screensaver} ${screensaver_passwd_cmd}' > /dev/null &}"
  >> ${ALX_UNPRIV_HOME}/.fluxbox/apps  
500   fi   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] {nice -n 19 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/keys \   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)) {nice -n 19 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  
  unset ALX_PROGRAMS  
  unset ALX_SCRN_SAVER  
  unset ALX_SCRN_TIMEOUT  
  unset ALX_SCRN_PASSWD  
651  }  }
   

Legend:
Removed from v.1594  
changed lines
  Added in v.6759