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 338 by niro, Tue Sep 27 22:50:36 2005 UTC alx-src/branches/alxconf_20060908/functions/config_sessions.sh revision 1654 by niro, Sat Jan 22 17:57:49 2011 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.16 2005-09-27 22:50:36 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.18 2006-01-26 19:55:53 niro Exp $
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()  get_sessions_settings()
# Line 9  get_sessions_settings() Line 9  get_sessions_settings()
9   # ->  session1 session2 ... sessionN   # ->  session1 session2 ... sessionN
10    
11   # get settings from database   # get settings from database
12   all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   all=$(mysqldo "select filename from cfg_sessions where serial='${ALX_SERIAL}'")
  "select filename from cfg_sessions where serial='${ALX_SERIAL}'")  
13    
14   # split'em up and put in an array (only if $all not zero)   # split'em up and put in an array (only if $all not zero)
15   declare -i i=0   declare -i i=0
# Line 27  get_sessions_settings() Line 26  get_sessions_settings()
26   fi   fi
27    
28   # get settings from database   # get settings from database
29   ALX_PROGRAMS=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_PROGRAMS=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")
  "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")  
30    
31   export ALX_SESSIONS   export ALX_SESSIONS
32   export ALX_PROGRAMS   export ALX_PROGRAMS
# Line 37  get_sessions_settings() Line 35  get_sessions_settings()
35  get_autostart_settings()  get_autostart_settings()
36  {  {
37   # get settings from database   # get settings from database
38   ALX_AUTOSTART=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_AUTOSTART=$(mysqldo "select session from cfg_autostart where serial='${ALX_SERIAL}'")
  "select session from cfg_autostart where serial='${ALX_SERIAL}'")  
39    
40   export ALX_AUTOSTART   export ALX_AUTOSTART
41  }  }
42    
43  get_screensaver_settings()  get_screensaver_settings()
44  {  {
45   ALX_SCRN_SAVER=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_SCRN_SAVER=$(mysqldo "select screensaver from cfg_screensaver where serial='${ALX_SERIAL}'")
46   "select screensaver from cfg_screensaver where serial='${ALX_SERIAL}'")   ALX_SCRN_TIMEOUT=$(mysqldo "select timeout from cfg_screensaver where serial='${ALX_SERIAL}'")
47   ALX_SCRN_TIMEOUT=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_SCRN_PASSWD=$(mysqldo "select password from cfg_screensaver where serial='${ALX_SERIAL}'")
  "select timeout from cfg_screensaver where serial='${ALX_SERIAL}'")  
  ALX_SCRN_PASSWD=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select password from cfg_screensaver where serial='${ALX_SERIAL}'")  
48    
49   export ALX_SCRN_SAVER   export ALX_SCRN_SAVER
50   export ALX_SCRN_TIMEOUT   export ALX_SCRN_TIMEOUT
# Line 62  generate_ica_session_files() Line 56  generate_ica_session_files()
56   local all_ids   local all_ids
57   local i   local i
58   local x   local x
59     local browser_address_num
60   local server   local server
61   local ses_session   local ses_session
62   local ses_filename   local ses_filename
# Line 72  generate_ica_session_files() Line 67  generate_ica_session_files()
67   local ses_colors   local ses_colors
68    
69   # get settings from database   # get settings from database
70   all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   all_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")
  "select id from cfg_sessions where serial='${ALX_SERIAL}'")  
71    
72   for i in ${all_ids}   for i in ${all_ids}
73   do   do
74   # get settings   # get settings
75   ses_session=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_session=$(mysqldo "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
76   "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   ses_filename=$(mysqldo "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
77     ses_username=$(mysqldo "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
78   ses_filename=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_domain=$(mysqldo "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
79   "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   ses_password=$(mysqldo "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
80     ses_browseradrs=$(mysqldo "select browseradrs 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}'")  
81    
82   # get the right colors   # get the right colors
83   ses_colors=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_colors=$(mysqldo "select depth from cfg_graphic where serial='${ALX_SERIAL}'")
84   "select depth from cfg_graphic where serial='${ALX_SERIAL}'")   # convert to ica session file values
85   case ${ses_colors} in   case ${ses_colors} in
86   24) ses_colors="8";;   24) ses_colors="8";;
87   16) ses_colors="4";;   16) ses_colors="4";;
# Line 115  generate_ica_session_files() Line 98  generate_ica_session_files()
98   for server in ${ses_browseradrs}   for server in ${ses_browseradrs}
99   do   do
100   (( x++ ))   (( x++ ))
101   echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   browser_address_num="${x}"
102     # support newer ica-clients:
103     # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !!
104     [[ ${x} -eq 1 ]] && browser_address_num=""
105     echo "TcpBrowserAddress${browser_address_num}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
106   done   done
107   IFS="${OLD_IFS}"   IFS="${OLD_IFS}"
108   unset x   unset x
109   unset OLD_IFS   unset OLD_IFS
110    
111   echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}
112    
113   echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}
114   echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}
115    
116   echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}
117   echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
118   echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
# Line 197  get_other_menuitems() Line 184  get_other_menuitems()
184   unset workdir   unset workdir
185   unset icon   unset icon
186    
187   name=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   name=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
188   "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}'")
189     workdir=$(mysqldo "select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
190   exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   icon=$(mysqldo "select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
  "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$  
191    
192   # now echo config line for fluxbox-menu   # now echo config line for fluxbox-menu
193   # make it "configureable" :P   # make it "configureable" :P
  #[ -n "${workdir}" ] && workdir="cd ${workdir};"  
194   [ -n "${workdir}" ] && workdir="--workdir ${workdir}"   [ -n "${workdir}" ] && workdir="--workdir ${workdir}"
195   [ -n "${icon}" ] && icon="<${icon}>"   [ -n "${icon}" ] && icon="<${icon}>"
196    
# Line 266  generate_icon() Line 242  generate_icon()
242   [ -z "${command}" ] && return 1   [ -z "${command}" ] && return 1
243    
244   # use some defaults for icon, dest, {x,y}res   # use some defaults for icon, dest, {x,y}res
245   [ -z "${xres}" ] && xres=20   [ -z "${xres}" ] && xres=30
246   [ -z "${yres}" ] && xres=20   [ -z "${yres}" ] && xres=30
247   [ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"   [ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"
248   if [ -z "${icon}" ] || [ ! -f "${icon}" ]   if [ -z "${icon}" ] || [ ! -f "${icon}" ]
249   then   then
# Line 307  generate_all_desktop_icons() Line 283  generate_all_desktop_icons()
283   local progsh_path   local progsh_path
284    
285   # get the resolution   # get the resolution
286   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}'")  
287    
288   # split res to x & y   # split res to x & y
289   xres="$(echo ${res} | cut -dx -f1)"   xres="$(echo ${res} | cut -dx -f1)"
# Line 328  generate_all_desktop_icons() Line 303  generate_all_desktop_icons()
303    
304    
305   # default settings   # default settings
306   declare -i x=20   declare -i x=30
307   declare -i y=20   declare -i y=30
308    
309   # first all ica sessions   # first all ica sessions
310   local count=${#ALX_SESSIONS[*]}   local count=${#ALX_SESSIONS[*]}
# Line 346  generate_all_desktop_icons() Line 321  generate_all_desktop_icons()
321    
322   # new line if x > xres   # new line if x > xres
323   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ];then
324   x=20   x=30
325   y=$((${y} + 80))   y=$((${y} + 80))
326   fi   fi
327    
328   # new row if y > yres   # new row if y > yres
329   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ];then
330   x=$((${x} + 120))   x=$((${x} + 120))
331   y=20   y=30
332    
333   # re-check x   # re-check x
334   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=30
335   fi   fi
336    
337   # ica icons   # ica icons
# Line 364  generate_all_desktop_icons() Line 339  generate_all_desktop_icons()
339   basename_item="$(basename ${item} .ica)"   basename_item="$(basename ${item} .ica)"
340   generate_icon \   generate_icon \
341   --name "${basename_item}" \   --name "${basename_item}" \
342   --command "wfica ${ALX_ICA_SESSIONS}/${item}" \   --command "numlockx on && nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \
343   --icon "${ALX_SESSIONS_ICONS}/${basename_item}.png" \   --icon "${ALX_SESSIONS_ICONS}/${basename_item}.png" \
344   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${basename_item}.lnk" \   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${basename_item}.lnk" \
345   --xres "${x}" \   --xres "${x}" \
# Line 386  generate_all_desktop_icons() Line 361  generate_all_desktop_icons()
361    
362   # new line if x > xres   # new line if x > xres
363   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ];then
364   x=20   x=30
365   y=$((${y} + 80))   y=$((${y} + 80))
366   fi   fi
367    
368   # new row if y > yres   # new row if y > yres
369   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ];then
370   x=$((${x} + 120))   x=$((${x} + 120))
371   y=20   y=30
372    
373   # re-check x   # re-check x
374   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=30
375   fi   fi
376    
377   generate_icon \   generate_icon \
# Line 419  generate_all_desktop_icons() Line 394  generate_all_desktop_icons()
394   local osversion   local osversion
395    
396   osversion="$(< /etc/mageversion)"   osversion="$(< /etc/mageversion)"
397   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}'")  
398   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
399    
400   # now get the right position:   # now get the right position:
# Line 457  config_sessions() Line 431  config_sessions()
431   local icon   local icon
432   local i   local i
433    
  # DEBUG  
 # declare -i i=0  
 # echo count=${count}  
 # echo "Number of new sessions: ${count}"  
 # for ((i=0; i < count; i++))  
 # do  
 # echo "${i} - ${ALX_SESSIONS[${i}]}"  
 # done  
   
434   # now setup fluxbox for user station   # now setup fluxbox for user station
435    
436   # create a fresh fluxbox directory   # create a fresh fluxbox directory
# Line 501  config_sessions() Line 466  config_sessions()
466   # add autostart session   # add autostart session
467   if [[ ${ALX_AUTOSTART} != "" ]]   if [[ ${ALX_AUTOSTART} != "" ]]
468   then   then
469   echo "[startup] {wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \   echo "[startup] {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \
470   >> ${ALX_UNPRIV_HOME}/.fluxbox/apps   >> ${ALX_UNPRIV_HOME}/.fluxbox/apps
471   fi   fi
472    
# Line 525  config_sessions() Line 490  config_sessions()
490   for (( i=0; i < count; i++ ))   for (( i=0; i < count; i++ ))
491   do   do
492   [ -n "${ALX_SESSIONS[${i}]}" ] && \   [ -n "${ALX_SESSIONS[${i}]}" ] && \
493   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {numlockx on && nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \
494   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
495   done   done
496    

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