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

Legend:
Removed from v.1704  
changed lines
  Added in v.6780