Magellan Linux

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

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

alx-src/trunk/alxconfig-ng/functions/config_sessions.sh revision 317 by niro, Thu Sep 1 18:27:44 2005 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.13 2005-09-01 18:27:44 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  # helper function to create citrix session files
11   all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  generate_ica_session_file()
12   "select filename from cfg_sessions where serial='${ALX_SERIAL}'")  {
13     local i
14     local num
15     local server
16     local ses_session
17     local ses_filename
18     local ses_username
19     local ses_domain
20     local ses_password
21     local ses_browseradrs
22     local ses_colors
23     local CONFIG
24    
25   # split'em up and put in an array (only if $all not zero)   # very basic getops
26   declare -i i=0   for i in $*
27   if [ -n "${all}" ]   do
28   then   case $1 in
29   for x in ${all}   --session) shift; ses_session="$1" ;;
30   do   --filename) shift; ses_filename="$1" ;;
31   ALX_SESSIONS[${i}]=${x}   --username) shift; ses_username="$1" ;;
32   ((i++))   --password) shift; ses_password="$1" ;;
33   done   --domain) shift; ses_domain="$1" ;;
34   count=${i}   --server) shift; ses_browseradrs="$1" ;;
35   else   --colordepth) shift; ses_colors="$1" ;;
36   count=0   esac
37   fi   shift
38     done
39    
40   # get settings from database   # abort if session, filename or server not given
41   ALX_PROGRAMS=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   [[ -z ${ses_session} ]] && return 1
42   "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")   [[ -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   export ALX_SESSIONS   addconfig '[WFClient]'
50   export ALX_PROGRAMS   addconfig 'Version=2'
 }  
51    
52  get_autostart_settings()   # use ';' as ifs
53  {   declare -i i=0
54   # get settings from database   for server in ${ses_browseradrs//;/ }
55   ALX_AUTOSTART=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   do
56   "select session from cfg_autostart where serial='${ALX_SERIAL}'")   (( 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   export ALX_AUTOSTART   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  generate_ica_session_files()  generate_storefront_sh()
90  {  {
  local all_ids  
  local i  
  local x  
91   local server   local server
92   local ses_session   local ses_session
93   local ses_filename   local ses_filename
# Line 55  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  
98    
99   # get settings from database   # very basic getops
100   all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   for i in $*
101   "select id from cfg_sessions where serial='${ALX_SERIAL}'")   do
102     case $1 in
103   for i in ${all_ids}   --session) shift; ses_session="$1" ;;
104   do   --filename) shift; ses_filename="$1" ;;
105   # get settings   --username) shift; ses_username="$1" ;;
106   ses_session=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   --password) shift; ses_password="$1" ;;
107   "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   --domain) shift; ses_domain="$1" ;;
108     --server) shift; ses_browseradrs="$1" ;;
  ses_filename=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_username=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_domain=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_password=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  ses_browseradrs=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  # get the right colors  
  ses_colors=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select depth from cfg_graphic where serial='${ALX_SERIAL}'")  
  case ${ses_colors} in  
  24) ses_colors="8";;  
  16) ses_colors="4";;  
  8) ses_colors="2";;  
  *) ses_colors="2";;  
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++ ))  
  echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  done  
  IFS="${OLD_IFS}"  
  unset x  
  unset OLD_IFS  
   
  echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
   
  echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
   
  echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "DesiredColor=${ses_colors}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'TransportDriver=TCP/IP' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'WinStationDriver=ICA 3.0' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "ClearPassword=${ses_password}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Username=${ses_username}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo "Domain=${ses_domain}" >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
  echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename}  
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 132  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 140  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=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
   
  exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
   
  workdir=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
   
  icon=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")  
   
  # debug only  
  #echo "DEBUG: ${x}: name:'${name}' exec:'${exec}' workdir:'${workdir}' ic$  
   
  # now echo config line for fluxbox-menu  
  # make it "configureable" :P  
  #[ -n "${workdir}" ] && workdir="cd ${workdir};"  
  [ -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 227  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 241  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=20   [[ -z ${xres} ]] && xres=50
201   [ -z "${yres}" ] && xres=20   [[ -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 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=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")
  "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")  
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=20   declare -i x=50
271   declare -i y=20   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  
  icon_list="${icon_list} $(basename ${ALX_SESSIONS[${i}]} .ica)"  
  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=20   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=20   y=50
294    
295   # re-check x   # re-check x
296   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=50
297   fi   fi
298    
299   generate_icon \   generate_icon \
300   --name "${item}" \   --name "${cfg_sessions_session}" \
301   --command "${progsh_path}/${item}" \   --command "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \
302   --icon "${ALX_SESSIONS_ICONS}/${item}.png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \
303   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${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=20   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=20   y=50
330    
331   # re-check x   # re-check x
332   [ ${x} -ge ${xres} ] && x=20   [ ${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 400  generate_all_desktop_icons() Line 439  generate_all_desktop_icons()
439   local osversion   local osversion
440    
441   osversion="$(< /etc/mageversion)"   osversion="$(< /etc/mageversion)"
442   hostname=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'")
  "select hostname from cfg_network where serial='${ALX_SERIAL}'")  
443   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
444    
445   # now get the right position:   # now get the right position:
# Line 417  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 426  generate_all_desktop_icons() Line 464  generate_all_desktop_icons()
464    
465  config_sessions()  config_sessions()
466  {  {
  # generate ica session files  
  generate_ica_session_files  
   
  # first of all get the vars  
  get_sessions_settings  
  get_autostart_settings  
   
  local count=${#ALX_SESSIONS[*]}  
  local icon  
467   local i   local i
468     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     progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
477    
478   # DEBUG   # get all session ids from database
479  # declare -i i=0   all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")
480  # echo count=${count}   # get all other_menuitem ids from database
481  # echo "Number of new sessions: ${count}"   all_other_ids=$(mysqldo "select id from cfg_other_menuitems where serial='${ALX_SERIAL}'")
482  # for ((i=0; i < count; i++))   # get all plugin ids from database
483  # do   all_plugin_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'")
484  # echo "${i} - ${ALX_SESSIONS[${i}]}"  
485  # done   # 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 455  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
524     if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]]
525     then
526     if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]]
527     then
528     screensaver_passwd_cmd="-nolock"
529     else
530     screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})"
531     fi
532    
533     addconfig "[startup] {nohup xautolock -time ${cfg_screensaver_timeout} -locker 'xlock -mode ${cfg_screensaver_screensaver} ${screensaver_passwd_cmd}' > /dev/null &}"
534     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] {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/apps \   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)) {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  
709  }  }

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