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 1654 by niro, Sat Jan 22 17:57:49 2011 UTC alx-src/branches/alxconf-060/functions/config_sessions.sh revision 6765 by niro, Tue Jul 21 12:18:38 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//\ /_}"
8   # all arrays:  }
  # ->  session1 session2 ... sessionN  
   
  # get settings from database  
  all=$(mysqldo "select filename from cfg_sessions where serial='${ALX_SERIAL}'")  
9    
10   # split'em up and put in an array (only if $all not zero)  # helper function to create citrix session files
11   declare -i i=0  generate_ica_session_file()
12   if [ -n "${all}" ]  {
13   then   local i
14   for x in ${all}   local num
15   do   local server
16   ALX_SESSIONS[${i}]=${x}   local ses_session
17   ((i++))   local ses_filename
18   done   local ses_username
19   count=${i}   local ses_domain
20   else   local ses_password
21   count=0   local ses_browseradrs
22   fi   local ses_colors
23     local CONFIG
24    
25   # get settings from database   # very basic getops
26   ALX_PROGRAMS=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")   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   export ALX_SESSIONS   # abort if session, filename or server not given
41   export ALX_PROGRAMS   [[ -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  get_autostart_settings()   addconfig '[WFClient]'
50  {   addconfig 'Version=2'
  # get settings from database  
  ALX_AUTOSTART=$(mysqldo "select session from cfg_autostart where serial='${ALX_SERIAL}'")  
51    
52   export ALX_AUTOSTART   # use ';' as ifs
53  }   declare -i i=0
54     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_screensaver_settings()   addconfig 'ScreenPercent=0'
66  {   addconfig '[ApplicationServers]'
67   ALX_SCRN_SAVER=$(mysqldo "select screensaver from cfg_screensaver where serial='${ALX_SERIAL}'")   addconfig "${ses_session}="
68   ALX_SCRN_TIMEOUT=$(mysqldo "select timeout from cfg_screensaver where serial='${ALX_SERIAL}'")   addconfig "[${ses_session}]"
69   ALX_SCRN_PASSWD=$(mysqldo "select password from cfg_screensaver where serial='${ALX_SERIAL}'")   addconfig "Address=${ses_session}"
70     addconfig "InitialProgram=#${ses_session}"
71   export ALX_SCRN_SAVER  
72   export ALX_SCRN_TIMEOUT   # convert to ica session file values
73   export ALX_SCRN_PASSWD   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  generate_ica_session_files()  generate_storefront_sh()
90  {  {
  local all_ids  
  local i  
  local x  
  local browser_address_num  
91   local server   local server
92   local ses_session   local ses_session
93   local ses_filename   local ses_filename
# Line 64  generate_ica_session_files() Line 95  generate_ica_session_files()
95   local ses_domain   local ses_domain
96   local ses_password   local ses_password
97   local ses_browseradrs   local ses_browseradrs
  local ses_colors  
   
  # get settings from database  
  all_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")  
98    
99   for i in ${all_ids}   # very basic getops
100     for i in $*
101   do   do
102   # get settings   case $1 in
103   ses_session=$(mysqldo "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --session) shift; ses_session="$1" ;;
104   ses_filename=$(mysqldo "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --filename) shift; ses_filename="$1" ;;
105   ses_username=$(mysqldo "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --username) shift; ses_username="$1" ;;
106   ses_domain=$(mysqldo "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --password) shift; ses_password="$1" ;;
107   ses_password=$(mysqldo "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --domain) shift; ses_domain="$1" ;;
108   ses_browseradrs=$(mysqldo "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --server) shift; ses_browseradrs="$1" ;;
   
  # get the right colors  
  ses_colors=$(mysqldo "select depth from cfg_graphic where serial='${ALX_SERIAL}'")  
  # convert to ica session file values  
  case ${ses_colors} in  
  24) ses_colors="8";;  
  16) ses_colors="4";;  
  8) ses_colors="2";;  
  *) ses_colors="2";;  
109   esac   esac
110     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++ ))  
  browser_address_num="${x}"  
  # support newer ica-clients:  
  # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !!  
  [[ ${x} -eq 1 ]] && browser_address_num=""  
  echo "TcpBrowserAddress${browser_address_num}=${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}  
111   done   done
112    
113     generate_program_sh \
114     --name "${ses_session}" \
115     --exec "storefront-resolver" \
116     --param "launch '${ses_username}' '${ses_password}' '${ses_domain}' '${ses_session}'" \
117     --dest "${ALX_UNPRIV_HOME}/.alxprogs/$(fix_whitespaces ${ses_filename})" \
118     --environment "STORE=${ses_browseradrs}"
119  }  }
120    
121  # generates a sh file to start programs  # generates a sh file to start programs
# Line 133  generate_program_sh() Line 124  generate_program_sh()
124   local dest   local dest
125   local name   local name
126   local exec   local exec
127     local param
128   local workdir   local workdir
129     local CONFIG
130    
131   # very basic getops   # very basic getops
132   for i in $*   for i in $*
# Line 141  generate_program_sh() Line 134  generate_program_sh()
134   case $1 in   case $1 in
135   --name|-n) shift; name="$1" ;;   --name|-n) shift; name="$1" ;;
136   --exec|-x) shift; exec="$1" ;;   --exec|-x) shift; exec="$1" ;;
137     --param|-p) shift; param="$1" ;;
138   --dest|-d) shift; dest="$1" ;;   --dest|-d) shift; dest="$1" ;;
139   --workdir|-w) shift; workdir="$1" ;;   --workdir|-w) shift; workdir="$1" ;;
140           esac   --environment|-e)  shift; environment="$1" ;;
141     esac
142   shift   shift
143   done   done
144    
145   # abort if name, dest or exec not given   # abort if name, dest or exec not given
146   [ -z "${name}" ] && return 1   [[ -z ${name} ]] && return 1
147   [ -z "${exec}" ] && return 1   [[ -z ${exec} ]] && return 1
148   [ -z "${dest}" ] && return 1   [[ -z ${dest} ]] && return 1
149    
150   echo "#!/bin/sh" > ${dest}   CONFIG="${dest}"
151   [ -n "${workdir}" ] && echo "cd ${workdir}" >> ${dest}   addconfig "#!/bin/sh"
152   echo "exec ${exec}" >> ${dest}   [[ -n ${environment} ]] && addconfig "export ${environment}"
153     [[ -n ${workdir} ]] && addconfig "cd ${workdir}"
154     addconfig "exec ${exec} ${param}"
155    
156   chmod 0755 ${dest}   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}"  
   
  echo "[exec] (${name}) {${progsh_path}/${name}} ${icon}"  
  done  
157  }  }
158    
159  # helper functions for generate all desktop icons  # helper functions for generate all desktop icons
# Line 217  generate_icon() Line 168  generate_icon()
168   local iwidth   local iwidth
169   local iheight   local iheight
170   local deficon   local deficon
171     local CONFIG
172     local utility
173    
174   # very basic getops   # very basic getops
175   for i in $*   for i in $*
# Line 231  generate_icon() Line 184  generate_icon()
184   --icon-width|-w) shift; iwidth="$1" ;;   --icon-width|-w) shift; iwidth="$1" ;;
185   --icon-height|-h) shift; iheight="$1" ;;   --icon-height|-h) shift; iheight="$1" ;;
186   --default-icon) shift; deficon="$1" ;;   --default-icon) shift; deficon="$1" ;;
187           esac   esac
188   shift   shift
189   done   done
190    
191   # some sanity checks :   # some sanity checks:
192    
193   # abort if name or command not given   # abort if name or command not given
194   [ -z "${name}" ] && return 1   [[ -z ${name} ]] && return 1
195   [ -z "${command}" ] && return 1   [[ -z ${command} ]] && return 1
196    
197     [[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk"
198    
199   # use some defaults for icon, dest, {x,y}res   # use some defaults for icon, dest, {x,y}res
200   [ -z "${xres}" ] && xres=30   [[ -z ${xres} ]] && xres=50
201   [ -z "${yres}" ] && xres=30   [[ -z ${yres} ]] && xres=50
202   [ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"   if [[ -z ${icon} ]] || [ ! -f ${icon} ]
  if [ -z "${icon}" ] || [ ! -f "${icon}" ]  
203   then   then
204   # if no default icon is given use default.png   # if no default icon is given use default.png
205   [ -z "${deficon}" ] && deficon="default.png"   [[ -z ${deficon} ]] && deficon="default.png"
206   icon="${ALX_SESSIONS_ICONS}/${deficon}"   icon="${ALX_SESSIONS_ICONS}/${deficon}"
207   fi   fi
208    
209   echo "table Icon" > ${dest}   CONFIG="${dest}"
210   echo "  Type: Program" >> ${dest}   clearconfig
211   echo "  Caption: ${name}" >> ${dest}  
212   echo "  Command: ${command}" >> ${dest}   addconfig 'table Icon'
213   echo "  Icon: ${icon}" >> ${dest}   addconfig "  Caption: ${name}"
214   echo "  X: ${xres}" >> ${dest}   addconfig "  Command: ${command}"
215   echo "  Y: ${yres}" >> ${dest}   addconfig "  Icon: ${icon}"
216     addconfig "  X: ${xres}"
217     addconfig "  Y: ${yres}"
218    
219   # add these only if not zero   # add these only if not zero
220   if [ -n "${iwidth}" ] && [ -n "${iheight}" ]   if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]
221   then   then
222   echo "  IconWidth: ${iwidth}" >> ${dest}   addconfig "  Width: ${iwidth}"
223   echo "  IconHeight: ${iheight}" >> ${dest}   addconfig "  Height: ${iheight}"
224   fi   fi
225    
226   echo "end" >> ${dest}   addconfig 'end'
227  }  }
228    
229  generate_all_desktop_icons()  generate_all_desktop_icons()
230  {  {
231     local session_list="$1"
232     local other_menuitem_list="$2"
233     local plugin_list="$3"
234   local res   local res
235   local xres   local xres
236   local yres   local yres
  local icon_list  
237   local x   local x
238   local y   local y
239   local item   local i
240   local basename_item   local name
241   local progsh_path   local progsh_path
242     local utility
243     local dest
244     local rc
245    
246     dest="${ALX_UNPRIV_HOME}/.idesktop"
247     rc="${ALX_UNPRIV_HOME}/.ideskrc"
248    
249     # progsh path
250     progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
251    
252   # get the resolution   # get the resolution
253   res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")   res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")
254    
255   # split res to x & y   # split res to x & y
256   xres="$(echo ${res} | cut -dx -f1)"   xres="${res%x*}"
257   yres="$(echo ${res} | cut -dx -f2)"   yres="${res#*x}"
258    
259   # top left edge of the icon is given in config file   # top left edge of the icon is given in config file
260   # remove a little bit to simulate the bottom-right edge   # remove a little bit to simulate the bottom-right edge
261   xres="$(( ${xres} - 120 ))"   xres="$(( ${xres} - 120 ))"
262   yres="$(( ${yres} - 80 ))"   yres="$(( ${yres} - 80 ))"
263    
  # basic config  
  cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc  
   
264   # clean desktop icon location   # clean desktop icon location
265   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop   [ -d ${dest} ] && rm -rf ${dest}
266   install -d ${ALX_UNPRIV_HOME}/.xtdesktop   [ -f ${rc} ] && rm -f ${rc}
267     install -d ${dest}
268    
269   # default settings   # default settings
270   declare -i x=30   declare -i x=50
271   declare -i y=30   declare -i y=50
272    
273   # first all ica sessions   # ica icons
274   local count=${#ALX_SESSIONS[*]}   for i in ${session_list}
  for (( i=0; i < count; i++ ))  
  do  
  # filenames !  
  icon_list="${icon_list} ${ALX_SESSIONS[${i}]}"  
  done  
   
  for item in ${icon_list}  
275   do   do
276   # abort if empty   # abort if empty
277   [ -z "${item}" ] && continue   [[ -z ${i} ]] && continue
278    
279     # get database information
280     evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
281    
282   # new line if x > xres   # new line if x > xres
283   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ]
284   x=30   then
285     x=50
286   y=$((${y} + 80))   y=$((${y} + 80))
287   fi   fi
288    
289   # new row if y > yres   # new row if y > yres
290   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ]
291     then
292   x=$((${x} + 120))   x=$((${x} + 120))
293   y=30   y=50
294    
295   # re-check x   # re-check x
296   [ ${x} -ge ${xres} ] && x=30   [ ${x} -ge ${xres} ] && x=50
297   fi   fi
298    
  # ica icons  
  # get basename (.ica must be suffix)  
  basename_item="$(basename ${item} .ica)"  
299   generate_icon \   generate_icon \
300   --name "${basename_item}" \   --name "${cfg_sessions_session}" \
301   --command "numlockx on && nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \   --command "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \
302   --icon "${ALX_SESSIONS_ICONS}/${basename_item}.png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \
303   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${basename_item}.lnk" \   --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \
304   --xres "${x}" \   --xres "${x}" \
305   --yres "${y}"   --yres "${y}"
306    
307   y=$((${y} + 80))   y=$((${y} + 80))
308   done   done
309    
310     for i in ${other_menuitem_list}
  # generate program icons  
  icon_list="${ALX_PROGRAMS}"  
   
  progsh_path=${ALX_UNPRIV_HOME}/.alxprogs  
   
  for item in ${icon_list}  
311   do   do
312   # abort if empty   # abort if empty
313   [ -z "${item}" ] && continue   [[ -z ${i} ]] && continue
314    
315     # get database information
316     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
317    
318   # new line if x > xres   # new line if x > xres
319   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ]
320   x=30   then
321     x=50
322   y=$((${y} + 80))   y=$((${y} + 80))
323   fi   fi
324    
325   # new row if y > yres   # new row if y > yres
326   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ]
327     then
328   x=$((${x} + 120))   x=$((${x} + 120))
329   y=30   y=50
330    
331   # re-check x   # re-check x
332   [ ${x} -ge ${xres} ] && x=30   [ ${x} -ge ${xres} ] && x=50
333   fi   fi
334    
335   generate_icon \   generate_icon \
336   --name "${item}" \   --name "${cfg_other_menuitems_name}" \
337   --command "${progsh_path}/${item}" \   --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
338   --icon "${ALX_SESSIONS_ICONS}/${item}.png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_icon}).png" \
339   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \   --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \
340   --xres "${x}" \   --xres "${x}" \
341   --yres "${y}" \   --yres "${y}" \
342   --default-icon "default_item.png"   --default-icon "default_item.png"
343    
344   y=$((${y} + 80))   y=$((${y} + 80))
345   done   done
346    
347     for i in ${plugin_list}
348     do
349     # abort if empty
350     [[ -z ${i} ]] && continue
351    
352     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
353     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
354     then
355     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem)
356    
357     # abort if name or exec is empty
358     [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue
359     [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue
360    
361     # new line if x > xres
362     if [ ${x} -ge ${xres} ]
363     then
364     x=50
365     y=$((${y} + 80))
366     fi
367    
368     # new row if y > yres
369     if [ ${y} -ge ${yres} ]
370     then
371     x=$((${x} + 120))
372     y=50
373    
374     # re-check x
375     [ ${x} -ge ${xres} ] && x=50
376     fi
377    
378     generate_icon \
379     --name "${PLUGIN_MENUITEM_NAME}" \
380     --command "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \
381     --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).png" \
382     --dest "${dest}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).lnk" \
383     --xres "${x}" \
384     --yres "${y}" \
385     --default-icon "default_item.png"
386    
387     y=$((${y} + 80))
388     fi
389    
390     # unset all variables
391     unset PLUGIN_MENUITEM_NAME
392     unset PLUGIN_MENUITEM_EXEC
393     unset PLUGIN_MENUITEM_PARAM
394     unset PLUGIN_MENUITEM_WORKDIR
395     unset PLUGIN_MENUITEM_ICON
396     done
397    
398     # add shutdown, reboot icons
399     for i in shutdown reboot
400     do
401     # new line if x > xres
402     if [ ${x} -ge ${xres} ]
403     then
404     x=50
405     y=$((${y} + 80))
406     fi
407    
408     # new row if y > yres
409     if [ ${y} -ge ${yres} ]
410     then
411     x=$((${x} + 120))
412     y=50
413    
414     # re-check x
415     [ ${x} -ge ${xres} ] && x=50
416     fi
417    
418     case ${i} in
419     shutdown) name="Herunterfahren" ;;
420     reboot) name="Neustarten" ;;
421     esac
422    
423     generate_icon \
424     --name "${name}" \
425     --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \
426     --icon "${ALX_SESSIONS_ICONS}/${i}.png" \
427     --dest "${dest}/${i}.lnk" \
428     --xres "${x}" \
429     --yres "${y}" \
430     --icon-width "40" \
431     --icon-height "40"
432    
433     y=$((${y} + 80))
434     done
435    
436   # last but not least gen a icon with some sys informations   # last but not least gen a icon with some sys informations
437   local sysinfo   local sysinfo
# Line 410  generate_all_desktop_icons() Line 455  generate_all_desktop_icons()
455   --name "${sysinfo}" \   --name "${sysinfo}" \
456   --command "exit 0" \   --command "exit 0" \
457   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
458   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \   --dest "${dest}/sysinfo.lnk" \
459   --xres "${xres}" \   --xres "${xres}" \
460   --yres "${yres}" \   --yres "${yres}" \
461   --icon-width "1" \   --icon-width "1" \
# Line 419  generate_all_desktop_icons() Line 464  generate_all_desktop_icons()
464    
465  config_sessions()  config_sessions()
466  {  {
467   # generate ica session files   local i
468   generate_ica_session_files   local all_ses_ids
469     local all_other_ids
470     local CONFIG
471     local screensaver_passwd_cmd
472     local fbinit
473     local fbkeys
474     local progsh_path
475    
476   # first of all get the vars   progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
  get_sessions_settings  
  get_autostart_settings  
  get_screensaver_settings  
477    
478   local count=${#ALX_SESSIONS[*]}   # get all session ids from database
479   local icon   all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")
480   local i   # get all other_menuitem ids from database
481     all_other_ids=$(mysqldo "select id from cfg_other_menuitems where serial='${ALX_SERIAL}'")
482     # get all plugin ids from database
483     all_plugin_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'")
484    
485     # get screensaver settings
486     evaluate_table cfg_screensaver
487     # get autostart settings
488     evaluate_table cfg_autostart
489     # get current color depth
490     evaluate_table cfg_graphic
491    
492   # now setup fluxbox for user station   # now setup fluxbox for user station
493    
# Line 440  config_sessions() Line 498  config_sessions()
498   # now generate fluxbox config files   # now generate fluxbox config files
499    
500   # fluxbox main config   # fluxbox main config
501   cat ${ALX_SKELETONS}/fluxbox/init \   if [ -f ${ALX_SKELETONS}/fluxbox/init ]
502   > ${ALX_UNPRIV_HOME}/.fluxbox/init   then
503     fbinit="${ALX_SKELETONS}/fluxbox/init"
504     else
505     fbinit="/usr/share/fluxbox/init"
506     fi
507     cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init
508    
509   # fluxbox autostart   # fluxbox autostart
510   cat ${ALX_SKELETONS}/fluxbox/apps \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
511   > ${ALX_UNPRIV_HOME}/.fluxbox/apps   # do not show decorations on messages generated with xmessage
512     if [ -x /usr/bin/xmessage ]
513     then
514     addconfig '[app] (xmessage)'
515     addconfig ' [Deco] {NONE}'
516     addconfig '[end]'
517     fi
518     # add icon utility
519     [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
520     # add numlock utility
521     [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
522    
523   # add screensaver   # add screensaver
524   if [[ -n ${ALX_SCRN_SAVER} ]] && [[ -n ${ALX_SCRN_TIMEOUT} ]]   if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]]
525   then   then
526   local ALX_PASSWD_CMD   if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]]
   
  if [[ -z ${ALX_SCRN_PASSWD} ]] || [[ ${ALX_SCRN_PASSWD} = NULL ]]  
527   then   then
528   ALX_PASSWD_CMD="-nolock"   screensaver_passwd_cmd="-nolock"
529   else   else
530   ALX_PASSWD_CMD="-cpasswd $(openssl passwd ${ALX_SCRN_PASSWD})"   screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})"
531   fi   fi
532    
533   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  
534   fi   fi
535    
536     # add plugins autostart
537     for i in ${all_plugin_ids}
538     do
539     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
540     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
541     then
542     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh autostart)
543    
544     if [[ ${PLUGIN_AUTOSTART} = 1 ]]
545     then
546     addconfig "[startup] {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}) &}"
547     fi
548     # unset all variables
549     unset PLUGIN_AUTOSTART
550     unset PLUGIN_MENUITEM_NAME
551     fi
552     done
553    
554   # add autostart session   # add autostart session
555   if [[ ${ALX_AUTOSTART} != "" ]]   if [[ ! -z ${cfg_autostart_session} ]]
556   then   then
557   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
558   >> ${ALX_UNPRIV_HOME}/.fluxbox/apps   addconfig "[startup] {sleep 1 && ${progsh_path}/$(fix_whitespaces ${cfg_autostart_session}) &}"
559   fi   fi
560    
561   # fluxbox hotkeys   # fluxbox hotkeys
562   cat ${ALX_SKELETONS}/fluxbox/keys \   if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
563   > ${ALX_UNPRIV_HOME}/.fluxbox/keys   then
564     fbkeys="${ALX_SKELETONS}/fluxbox/keys"
565     else
566     fbkeys="/usr/share/fluxbox/keys"
567     fi
568     cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys
569    
570   # fluxbox menu header   # generate a fluxbox menu
571   cat ${ALX_SKELETONS}/fluxbox/menu.header \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
572   > ${ALX_UNPRIV_HOME}/.fluxbox/menu   clearconfig
573    
574     # fluxbox menu header
575     cat ${ALX_SKELETONS}/fluxbox/menu.header >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
576   # now fix it with proper messages :P   # now fix it with proper messages :P
577   local ver="$(< /etc/mageversion)"   local ver="$(< /etc/mageversion)"
578   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  
   
579   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
580   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   addconfig
581    
582   # fluxbox menu sessions   # delete all progs
583   for (( i=0; i < count; i++ ))   [ -d ${progsh_path} ] && rm -rf ${progsh_path}
584     install -d ${progsh_path}
585    
586     # first generate session files
587     for i in ${all_ses_ids}
588   do   do
589   [ -n "${ALX_SESSIONS[${i}]}" ] && \   evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
590   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {numlockx on && nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \  
591   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   # generate STOREFRONT/PNABROWSE compatible session
592     case "${cfg_sessions_browseradrs}" in
593     "http://"*|"https://"* )
594     # generate STOREFRONT/PNABROWSE compatible session
595     generate_storefront_sh \
596     --session "${cfg_sessions_session}" \
597     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
598     --username "${cfg_sessions_username}" \
599     --password "${cfg_sessions_password}" \
600     --domain "${cfg_sessions_domain}" \
601     --server "${cfg_sessions_browseradrs}"
602     ;;
603     *)
604     # generate ICA compatible session
605     generate_ica_session_file \
606     --session "${cfg_sessions_session}" \
607     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
608     --username "${cfg_sessions_username}" \
609     --password "${cfg_sessions_password}" \
610     --domain "${cfg_sessions_domain}" \
611     --server "${cfg_sessions_browseradrs}" \
612     --colordepth "${cfg_graphic_depth}"
613     # gen prog startup wrapper
614     generate_program_sh \
615     --name "$(fix_whitespaces ${cfg_sessions_filename})" \
616     --exec "wfica-launcher" \
617     --param "${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \
618     --dest "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \
619     "${workdir}"
620     ;;
621     esac
622    
623     # fluxbox menusession
624     addconfig "[exec] (${cfg_sessions_session}) {${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})}"
625   done   done
626    
627   # add other menuitems   # add other menuitems
628   get_other_menuitems >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   for i in ${all_other_ids}
629     do
630     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
631    
632   # fluxbox menu footer   # now echo config line for fluxbox-menu
633   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   # make it "configureable" :p
634   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   if [[ -n ${cfg_other_menuitems_workdir} ]]
635     then
636     workdir="--workdir ${cfg_other_menuitems_workdir}"
637     fi
638     if [[ -n ${cfg_other_menuitems_icon} ]]
639     then
640     cfg_other_menuitems_icon="<${cfg_other_menuitems_icon}>"
641     fi
642    
643     # gen prog startup wrapper
644     generate_program_sh \
645     --name "${cfg_other_menuitems_name}" \
646     --exec "${cfg_other_menuitems_exec}" \
647     --param "${cfg_other_menuitems_param}" \
648     --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
649     "${workdir}"
650    
651     addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}"
652     done
653    
654     # add plugins
655     for i in ${all_plugin_ids}
656     do
657     evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
658     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
659     then
660     eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem)
661    
662     # abort if name or exec is empty
663     [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue
664     [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue
665    
666     # now echo config line for fluxbox-menu
667     # make it "configureable" :p
668     if [[ -n ${PLUGIN_MENUITEM_WORKDIR} ]]
669     then
670     workdir="--workdir ${PLUGIN_MENUITEM_WORKDIR}"
671     fi
672     if [[ -n ${PLUGIN_MENUITEM_ICON} ]]
673     then
674     PLUGIN_MENUITEM_ICON="<${PLUGIN_MENUITEM_ICON}>"
675     fi
676    
677     # gen prog startup wrapper
678     generate_program_sh \
679     --name "${PLUGIN_MENUITEM_NAME}" \
680     --exec "${PLUGIN_MENUITEM_EXEC}" \
681     --param "${PLUGIN_MENUITEM_PARAM}" \
682     --dest "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \
683     "${workdir}"
684    
685     addconfig "[exec] (${PLUGIN_MENUITEM_NAME}) {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})} ${PLUGIN_MENUITEM_ICON}"
686     fi
687    
688     # unset all variables
689     unset PLUGIN_MENUITEM_NAME
690     unset PLUGIN_MENUITEM_EXEC
691     unset PLUGIN_MENUITEM_PARAM
692     unset PLUGIN_MENUITEM_WORKDIR
693     unset PLUGIN_MENUITEM_ICON
694     done
695    
696     # fluxbox menu footer
697     cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
698   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
699   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   addconfig
700    
701   # now it's a good time to generate *all* icons :)   # now it's a good time to generate *all* icons :)
702   generate_all_desktop_icons   generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}" "${all_plugin_ids}"
703    
704   # set correct permissions   # fix permissions
705   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
706   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
707   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
708   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  
709  }  }
   

Legend:
Removed from v.1654  
changed lines
  Added in v.6765