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_20060908/functions/config_sessions.sh revision 1642 by niro, Tue Dec 28 12:46:26 2010 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 $  # $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()
44    {
45     ALX_SCRN_SAVER=$(mysqldo "select screensaver from cfg_screensaver where serial='${ALX_SERIAL}'")
46     ALX_SCRN_TIMEOUT=$(mysqldo "select timeout from cfg_screensaver where serial='${ALX_SERIAL}'")
47     ALX_SCRN_PASSWD=$(mysqldo "select password from cfg_screensaver where serial='${ALX_SERIAL}'")
48    
49     export ALX_SCRN_SAVER
50     export ALX_SCRN_TIMEOUT
51     export ALX_SCRN_PASSWD
52    }
53    
54  generate_ica_session_files()  generate_ica_session_files()
55  {  {
56   local all_ids   local all_ids
# Line 58  generate_ica_session_files() Line 66  generate_ica_session_files()
66   local ses_colors   local ses_colors
67    
68   # get settings from database   # get settings from database
69   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}'")  
70    
71   for i in ${all_ids}   for i in ${all_ids}
72   do   do
73   # get settings   # get settings
74   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}'")
75   "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}'")
76     ses_username=$(mysqldo "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
77   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}'")
78   "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}'")
79     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}'")  
80    
81   # get the right colors   # get the right colors
82   ses_colors=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_colors=$(mysqldo "select depth from cfg_graphic where serial='${ALX_SERIAL}'")
83   "select depth from cfg_graphic where serial='${ALX_SERIAL}'")   # convert to ica session file values
84   case ${ses_colors} in   case ${ses_colors} in
85   24) ses_colors="8";;   24) ses_colors="8";;
86   16) ses_colors="4";;   16) ses_colors="4";;
# Line 183  get_other_menuitems() Line 179  get_other_menuitems()
179   unset workdir   unset workdir
180   unset icon   unset icon
181    
182   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}'")
183   "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}'")
184     workdir=$(mysqldo "select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
185   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$  
186    
187   # now echo config line for fluxbox-menu   # now echo config line for fluxbox-menu
188   # make it "configureable" :P   # make it "configureable" :P
  #[ -n "${workdir}" ] && workdir="cd ${workdir};"  
189   [ -n "${workdir}" ] && workdir="--workdir ${workdir}"   [ -n "${workdir}" ] && workdir="--workdir ${workdir}"
190   [ -n "${icon}" ] && icon="<${icon}>"   [ -n "${icon}" ] && icon="<${icon}>"
191    
# Line 252  generate_icon() Line 237  generate_icon()
237   [ -z "${command}" ] && return 1   [ -z "${command}" ] && return 1
238    
239   # use some defaults for icon, dest, {x,y}res   # use some defaults for icon, dest, {x,y}res
240   [ -z "${xres}" ] && xres=20   [ -z "${xres}" ] && xres=30
241   [ -z "${yres}" ] && xres=20   [ -z "${yres}" ] && xres=30
242   [ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"   [ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"
243   if [ -z "${icon}" ] || [ ! -f "${icon}" ]   if [ -z "${icon}" ] || [ ! -f "${icon}" ]
244   then   then
# Line 289  generate_all_desktop_icons() Line 274  generate_all_desktop_icons()
274   local x   local x
275   local y   local y
276   local item   local item
277     local basename_item
278   local progsh_path   local progsh_path
279    
280   # get the resolution   # get the resolution
281   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}'")  
282    
283   # split res to x & y   # split res to x & y
284   xres="$(echo ${res} | cut -dx -f1)"   xres="$(echo ${res} | cut -dx -f1)"
# Line 313  generate_all_desktop_icons() Line 298  generate_all_desktop_icons()
298    
299    
300   # default settings   # default settings
301   declare -i x=20   declare -i x=30
302   declare -i y=20   declare -i y=30
303    
304   # first all ica sessions   # first all ica sessions
305   local count=${#ALX_SESSIONS[*]}   local count=${#ALX_SESSIONS[*]}
306   for (( i=0; i < count; i++ ))   for (( i=0; i < count; i++ ))
307   do   do
308   icon_list="${icon_list} $(basename ${ALX_SESSIONS[${i}]} .ica)"   # filenames !
309     icon_list="${icon_list} ${ALX_SESSIONS[${i}]}"
310   done   done
311    
312   for item in ${icon_list}   for item in ${icon_list}
# Line 330  generate_all_desktop_icons() Line 316  generate_all_desktop_icons()
316    
317   # new line if x > xres   # new line if x > xres
318   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ];then
319   x=20   x=30
320   y=$((${y} + 80))   y=$((${y} + 80))
321   fi   fi
322    
323   # new row if y > yres   # new row if y > yres
324   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ];then
325   x=$((${x} + 120))   x=$((${x} + 120))
326   y=20   y=30
327    
328   # re-check x   # re-check x
329   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=30
330   fi   fi
331    
332     # ica icons
333     # get basename (.ica must be suffix)
334     basename_item="$(basename ${item} .ica)"
335   generate_icon \   generate_icon \
336   --name "${item}" \   --name "${basename_item}" \
337   --command "${progsh_path}/${item}" \   --command "numlockx on && nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \
338   --icon "${ALX_SESSIONS_ICONS}/${item}.png" \   --icon "${ALX_SESSIONS_ICONS}/${basename_item}.png" \
339   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${basename_item}.lnk" \
340   --xres "${x}" \   --xres "${x}" \
341   --yres "${y}"   --yres "${y}"
342    
# Line 367  generate_all_desktop_icons() Line 356  generate_all_desktop_icons()
356    
357   # new line if x > xres   # new line if x > xres
358   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ];then
359   x=20   x=30
360   y=$((${y} + 80))   y=$((${y} + 80))
361   fi   fi
362    
363   # new row if y > yres   # new row if y > yres
364   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ];then
365   x=$((${x} + 120))   x=$((${x} + 120))
366   y=20   y=30
367    
368   # re-check x   # re-check x
369   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=30
370   fi   fi
371    
372   generate_icon \   generate_icon \
# Line 400  generate_all_desktop_icons() Line 389  generate_all_desktop_icons()
389   local osversion   local osversion
390    
391   osversion="$(< /etc/mageversion)"   osversion="$(< /etc/mageversion)"
392   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}'")  
393   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"   sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
394    
395   # now get the right position:   # now get the right position:
# Line 432  config_sessions() Line 420  config_sessions()
420   # first of all get the vars   # first of all get the vars
421   get_sessions_settings   get_sessions_settings
422   get_autostart_settings   get_autostart_settings
423     get_screensaver_settings
424    
425   local count=${#ALX_SESSIONS[*]}   local count=${#ALX_SESSIONS[*]}
426   local icon   local icon
427   local i   local i
428    
  # 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  
   
429   # now setup fluxbox for user station   # now setup fluxbox for user station
430    
431   # create a fresh fluxbox directory   # create a fresh fluxbox directory
# Line 462  config_sessions() Line 442  config_sessions()
442   cat ${ALX_SKELETONS}/fluxbox/apps \   cat ${ALX_SKELETONS}/fluxbox/apps \
443   > ${ALX_UNPRIV_HOME}/.fluxbox/apps   > ${ALX_UNPRIV_HOME}/.fluxbox/apps
444    
445     # add screensaver
446     if [[ -n ${ALX_SCRN_SAVER} ]] && [[ -n ${ALX_SCRN_TIMEOUT} ]]
447     then
448     local ALX_PASSWD_CMD
449    
450     if [[ -z ${ALX_SCRN_PASSWD} ]] || [[ ${ALX_SCRN_PASSWD} = NULL ]]
451     then
452     ALX_PASSWD_CMD="-nolock"
453     else
454     ALX_PASSWD_CMD="-cpasswd $(openssl passwd ${ALX_SCRN_PASSWD})"
455     fi
456    
457     echo "[startup] {nohup xautolock -time ${ALX_SCRN_TIMEOUT} -locker 'xlock -mode ${ALX_SCRN_SAVER} ${ALX_PASSWD_CMD}' > /dev/null &}" \
458     >> ${ALX_UNPRIV_HOME}/.fluxbox/apps
459     fi
460    
461   # add autostart session   # add autostart session
462   if [[ ${ALX_AUTOSTART} != "" ]]   if [[ ${ALX_AUTOSTART} != "" ]]
463   then   then
464   echo "[startup] {wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \   echo "[startup] {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \
465   >> ${ALX_UNPRIV_HOME}/.fluxbox/apps   >> ${ALX_UNPRIV_HOME}/.fluxbox/apps
466   fi   fi
467    
468   # fluxbox hotkeys   # fluxbox hotkeys
469   cat ${ALX_SKELETONS}/fluxbox/apps \   cat ${ALX_SKELETONS}/fluxbox/keys \
470   > ${ALX_UNPRIV_HOME}/.fluxbox/keys   > ${ALX_UNPRIV_HOME}/.fluxbox/keys
471    
472   # fluxbox menu header   # fluxbox menu header
# Line 489  config_sessions() Line 485  config_sessions()
485   for (( i=0; i < count; i++ ))   for (( i=0; i < count; i++ ))
486   do   do
487   [ -n "${ALX_SESSIONS[${i}]}" ] && \   [ -n "${ALX_SESSIONS[${i}]}" ] && \
488   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}]}}" \
489   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
490   done   done
491    
# Line 510  config_sessions() Line 506  config_sessions()
506   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
507   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
508   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
509   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop
510   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc
511    
512   # unset vars   # unset vars
513   unset ALX_SESSIONS   unset ALX_SESSIONS
514   unset ALX_PROGRAMS   unset ALX_PROGRAMS
515     unset ALX_SCRN_SAVER
516     unset ALX_SCRN_TIMEOUT
517     unset ALX_SCRN_PASSWD
518  }  }
519    

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