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 373 by niro, Thu Jan 26 19:55:53 2006 UTC alx-src/branches/alxconf-060/functions/config_sessions.sh revision 2411 by niro, Wed Jun 15 13:00:27 2011 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//\ /_}"
  # all arrays:  
  # ->  session1 session2 ... sessionN  
   
  # get settings from database  
  all=$(mysqldo "select filename from cfg_sessions where serial='${ALX_SERIAL}'")  
   
  # split'em up and put in an array (only if $all not zero)  
  declare -i i=0  
  if [ -n "${all}" ]  
  then  
  for x in ${all}  
  do  
  ALX_SESSIONS[${i}]=${x}  
  ((i++))  
  done  
  count=${i}  
  else  
  count=0  
  fi  
   
  # get settings from database  
  ALX_PROGRAMS=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")  
   
  export ALX_SESSIONS  
  export ALX_PROGRAMS  
 }  
   
 get_autostart_settings()  
 {  
  # get settings from database  
  ALX_AUTOSTART=$(mysqldo "select session from cfg_autostart where serial='${ALX_SERIAL}'")  
   
  export ALX_AUTOSTART  
 }  
   
 get_screensaver_settings()  
 {  
  ALX_SCRN_SAVER=$(mysqldo "select screensaver from cfg_screensaver where serial='${ALX_SERIAL}'")  
  ALX_SCRN_TIMEOUT=$(mysqldo "select timeout from cfg_screensaver where serial='${ALX_SERIAL}'")  
  ALX_SCRN_PASSWD=$(mysqldo "select password from cfg_screensaver where serial='${ALX_SERIAL}'")  
   
  export ALX_SCRN_SAVER  
  export ALX_SCRN_TIMEOUT  
  export ALX_SCRN_PASSWD  
8  }  }
9    
10  generate_ica_session_files()  # helper function to create citrix session files
11    generate_ica_session_file()
12  {  {
  local all_ids  
13   local i   local i
14   local x   local num
15   local server   local server
16   local ses_session   local ses_session
17   local ses_filename   local ses_filename
# Line 63  generate_ica_session_files() Line 19  generate_ica_session_files()
19   local ses_domain   local ses_domain
20   local ses_password   local ses_password
21   local ses_browseradrs   local ses_browseradrs
22   local ses_colors   local CONFIG
23    
24     # very basic getops
25     for i in $*
26     do
27     case $1 in
28     --session) shift; ses_session="$1" ;;
29     --filename) shift; ses_filename="$1" ;;
30     --username) shift; ses_username="$1" ;;
31     --password) shift; ses_password="$1" ;;
32     --domain) shift; ses_domain="$1" ;;
33     --server) shift; ses_browseradrs="$1" ;;
34             esac
35     shift
36     done
37    
38   # get settings from database   # abort if session, filename or server not given
39   all_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")   [[ -z ${ses_session} ]] && return 1
40     [[ -z ${ses_filename} ]] && return 1
41     [[ -z ${ses_browseradrs} ]] && return 1
42    
43     # write session files
44     CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}"
45     clearconfig
46    
47   for i in ${all_ids}   addconfig '[WFClient]'
48     addconfig 'Version=2'
49    
50     # use ';' as ifs
51     declare -i i=0
52     for server in ${ses_browseradrs//;/ }
53   do   do
54   # get settings   (( i++ ))
55   ses_session=$(mysqldo "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   num="${i}"
56   ses_filename=$(mysqldo "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   # support newer ica-clients:
57   ses_username=$(mysqldo "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !!
58   ses_domain=$(mysqldo "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   [[ ${i} -eq 1 ]] && num=""
59   ses_password=$(mysqldo "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   addconfig "TcpBrowserAddress${num}=${server}"
  ses_browseradrs=$(mysqldo "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")  
   
  # 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";;  
  esac  
   
  # 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}  
60   done   done
61    
62     addconfig 'ScreenPercent=0'
63     addconfig '[ApplicationServers]'
64     addconfig "${ses_session}="
65     addconfig "[${ses_session}]"
66     addconfig "Address=${ses_session}"
67     addconfig "InitialProgram=#${ses_session}"
68     addconfig 'TransportDriver=TCP/IP'
69     addconfig 'WinStationDriver=ICA 3.0'
70     addconfig "ClearPassword=${ses__password}"
71     addconfig "Username=${ses_username}"
72     addconfig "Domain=${ses_domain}"
73     addconfig 'UseFullScreen=Yes'
74     addconfig 'NoWindowManager=True'
75  }  }
76    
77  # generates a sh file to start programs  # generates a sh file to start programs
# Line 128  generate_program_sh() Line 80  generate_program_sh()
80   local dest   local dest
81   local name   local name
82   local exec   local exec
83     local param
84   local workdir   local workdir
85     local CONFIG
86    
87   # very basic getops   # very basic getops
88   for i in $*   for i in $*
# Line 136  generate_program_sh() Line 90  generate_program_sh()
90   case $1 in   case $1 in
91   --name|-n) shift; name="$1" ;;   --name|-n) shift; name="$1" ;;
92   --exec|-x) shift; exec="$1" ;;   --exec|-x) shift; exec="$1" ;;
93     --param|-p) shift; param="$1" ;;
94   --dest|-d) shift; dest="$1" ;;   --dest|-d) shift; dest="$1" ;;
95   --workdir|-w) shift; workdir="$1" ;;   --workdir|-w) shift; workdir="$1" ;;
96           esac           esac
# Line 143  generate_program_sh() Line 98  generate_program_sh()
98   done   done
99    
100   # abort if name, dest or exec not given   # abort if name, dest or exec not given
101   [ -z "${name}" ] && return 1   [[ -z ${name} ]] && return 1
102   [ -z "${exec}" ] && return 1   [[ -z ${exec} ]] && return 1
103   [ -z "${dest}" ] && return 1   [[ -z ${dest} ]] && return 1
104    
105   echo "#!/bin/sh" > ${dest}   CONFIG="${dest}"
106   [ -n "${workdir}" ] && echo "cd ${workdir}" >> ${dest}   addconfig "#!/bin/sh"
107   echo "exec ${exec}" >> ${dest}   [ -n "${workdir}" ] && addconfig "cd ${workdir}"
108     addconfig "exec ${exec} ${param}"
109    
110   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  
111  }  }
112    
113  # helper functions for generate all desktop icons  # helper functions for generate all desktop icons
# Line 212  generate_icon() Line 122  generate_icon()
122   local iwidth   local iwidth
123   local iheight   local iheight
124   local deficon   local deficon
125     local CONFIG
126     local utility
127    
128   # very basic getops   # very basic getops
129   for i in $*   for i in $*
# Line 230  generate_icon() Line 142  generate_icon()
142   shift   shift
143   done   done
144    
145   # some sanity checks :   # some sanity checks:
146    
147   # abort if name or command not given   # abort if name or command not given
148   [ -z "${name}" ] && return 1   [[ -z ${name} ]] && return 1
149   [ -z "${command}" ] && return 1   [[ -z ${command} ]] && return 1
150    
151     # which utility are we using idesk|xtdesk ?
152     if [ -x /usr/bin/idesk ]
153     then
154     utility="idesk"
155     [[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk"
156     else
157     utility="xtdesk"
158     [[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"
159     fi
160    
161   # use some defaults for icon, dest, {x,y}res   # use some defaults for icon, dest, {x,y}res
162   [ -z "${xres}" ] && xres=20   [[ -z ${xres} ]] && xres=30
163   [ -z "${yres}" ] && xres=20   [[ -z ${yres} ]] && xres=30
164   [ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk"   if [[ -z ${icon} ]] || [ ! -f ${icon} ]
  if [ -z "${icon}" ] || [ ! -f "${icon}" ]  
165   then   then
166   # if no default icon is given use default.png   # if no default icon is given use default.png
167   [ -z "${deficon}" ] && deficon="default.png"   [[ -z ${deficon} ]] && deficon="default.png"
168   icon="${ALX_SESSIONS_ICONS}/${deficon}"   icon="${ALX_SESSIONS_ICONS}/${deficon}"
169   fi   fi
170    
171   echo "table Icon" > ${dest}   CONFIG="${dest}"
172   echo "  Type: Program" >> ${dest}   clearconfig
173   echo "  Caption: ${name}" >> ${dest}  
174   echo "  Command: ${command}" >> ${dest}   addconfig 'table Icon'
175   echo "  Icon: ${icon}" >> ${dest}   [[ ${utility} = xtdesk ]] && addconfig '  Type: Program'
176   echo "  X: ${xres}" >> ${dest}   addconfig "  Caption: ${name}"
177   echo "  Y: ${yres}" >> ${dest}   addconfig "  Command: ${command}"
178     addconfig "  Icon: ${icon}"
179     addconfig "  X: ${xres}"
180     addconfig "  Y: ${yres}"
181    
182   # add these only if not zero   # add these only if not zero
183   if [ -n "${iwidth}" ] && [ -n "${iheight}" ]   if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]
184   then   then
185   echo "  IconWidth: ${iwidth}" >> ${dest}   if [[ ${utility} = xtdesk ]]
186   echo "  IconHeight: ${iheight}" >> ${dest}   then
187     addconfig "  IconWidth: ${iwidth}"
188     addconfig "  IconHeight: ${iheight}"
189     fi
190     if [[ ${utility} = idesk ]]
191     then
192     addconfig "  Width: ${iwidth}"
193     addconfig "  Height: ${iheight}"
194     fi
195   fi   fi
196    
197   echo "end" >> ${dest}   addconfig 'end'
198  }  }
199    
200  generate_all_desktop_icons()  generate_all_desktop_icons()
201  {  {
202     local session_list="$1"
203     local other_menuitem_list="$2"
204   local res   local res
205   local xres   local xres
206   local yres   local yres
  local icon_list  
207   local x   local x
208   local y   local y
209   local item   local i
210   local basename_item   local name
211   local progsh_path   local progsh_path
212     local utility
213     local dest
214     local rc
215    
216     # which utility are we using idesk|xtdesk ?
217     if [ -x /usr/bin/idesk ]
218     then
219     utility="idesk"
220     dest="${ALX_UNPRIV_HOME}/.idesktop"
221     rc="${ALX_UNPRIV_HOME}/.ideskrc"
222     else
223     utility="xtdesk"
224     dest="${ALX_UNPRIV_HOME}/.xtdesktop"
225     rc="${ALX_UNPRIV_HOME}/.xtdeskrc"
226     fi
227    
228    
229     # progsh path
230     progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
231    
232   # get the resolution   # get the resolution
233   res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")   res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'")
234    
235   # split res to x & y   # split res to x & y
236   xres="$(echo ${res} | cut -dx -f1)"   xres="${res%x*}"
237   yres="$(echo ${res} | cut -dx -f2)"   yres="${res#*x}"
238    
239   # top left edge of the icon is given in config file   # top left edge of the icon is given in config file
240   # remove a little bit to simulate the bottom-right edge   # remove a little bit to simulate the bottom-right edge
241   xres="$(( ${xres} - 120 ))"   xres="$(( ${xres} - 120 ))"
242   yres="$(( ${yres} - 80 ))"   yres="$(( ${yres} - 80 ))"
243    
  # basic config  
  cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc  
   
244   # clean desktop icon location   # clean desktop icon location
245   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop   [ -d ${dest} ] && rm -rf ${dest}
246   install -d ${ALX_UNPRIV_HOME}/.xtdesktop   [ -f ${rc} ] && rm -f ${rc}
247     install -d ${dest}
248    
249    if [[ ${utility} = xtdesk ]]
250    then
251     # basic config
252     cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdesktop/xtdeskrc
253    fi
254    
255   # default settings   # default settings
256   declare -i x=20   declare -i x=30
257   declare -i y=20   declare -i y=30
258    
259   # first all ica sessions   # ica icons
260   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}  
261   do   do
262   # abort if empty   # abort if empty
263   [ -z "${item}" ] && continue   [[ -z ${i} ]] && continue
264    
265     # get database information
266     evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
267    
268   # new line if x > xres   # new line if x > xres
269   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ]
270   x=20   then
271     x=30
272   y=$((${y} + 80))   y=$((${y} + 80))
273   fi   fi
274    
275   # new row if y > yres   # new row if y > yres
276   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ]
277     then
278   x=$((${x} + 120))   x=$((${x} + 120))
279   y=20   y=30
280    
281   # re-check x   # re-check x
282   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=30
283   fi   fi
284    
  # ica icons  
  # get basename (.ica must be suffix)  
  basename_item="$(basename ${item} .ica)"  
285   generate_icon \   generate_icon \
286   --name "${basename_item}" \   --name "${cfg_sessions_session}" \
287   --command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \   --command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \
288   --icon "${ALX_SESSIONS_ICONS}/${basename_item}.png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \
289   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${basename_item}.lnk" \   --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \
290   --xres "${x}" \   --xres "${x}" \
291   --yres "${y}"   --yres "${y}"
292    
293   y=$((${y} + 80))   y=$((${y} + 80))
294   done   done
295    
296     for i in ${other_menuitem_list}
  # generate program icons  
  icon_list="${ALX_PROGRAMS}"  
   
  progsh_path=${ALX_UNPRIV_HOME}/.alxprogs  
   
  for item in ${icon_list}  
297   do   do
298   # abort if empty   # abort if empty
299   [ -z "${item}" ] && continue   [[ -z ${i} ]] && continue
300    
301     # get database information
302     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
303    
304   # new line if x > xres   # new line if x > xres
305   if [ ${x} -ge ${xres} ];then   if [ ${x} -ge ${xres} ]
306   x=20   then
307     x=30
308   y=$((${y} + 80))   y=$((${y} + 80))
309   fi   fi
310    
311   # new row if y > yres   # new row if y > yres
312   if [ ${y} -ge ${yres} ];then   if [ ${y} -ge ${yres} ]
313     then
314   x=$((${x} + 120))   x=$((${x} + 120))
315   y=20   y=30
316    
317   # re-check x   # re-check x
318   [ ${x} -ge ${xres} ] && x=20   [ ${x} -ge ${xres} ] && x=30
319   fi   fi
320    
321   generate_icon \   generate_icon \
322   --name "${item}" \   --name "${cfg_other_menuitems_name}" \
323   --command "${progsh_path}/${item}" \   --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
324   --icon "${ALX_SESSIONS_ICONS}/${item}.png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_name}).png" \
325   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \   --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \
326   --xres "${x}" \   --xres "${x}" \
327   --yres "${y}" \   --yres "${y}" \
328   --default-icon "default_item.png"   --default-icon "default_item.png"
# Line 381  generate_all_desktop_icons() Line 330  generate_all_desktop_icons()
330   y=$((${y} + 80))   y=$((${y} + 80))
331   done   done
332    
   
   
333   # last but not least gen a icon with some sys informations   # last but not least gen a icon with some sys informations
334   local sysinfo   local sysinfo
335   local hostname   local hostname
# Line 405  generate_all_desktop_icons() Line 352  generate_all_desktop_icons()
352   --name "${sysinfo}" \   --name "${sysinfo}" \
353   --command "exit 0" \   --command "exit 0" \
354   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \   --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
355   --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \   --dest "${dest}/sysinfo.lnk" \
356   --xres "${xres}" \   --xres "${xres}" \
357   --yres "${yres}" \   --yres "${yres}" \
358   --icon-width "1" \   --icon-width "1" \
# Line 414  generate_all_desktop_icons() Line 361  generate_all_desktop_icons()
361    
362  config_sessions()  config_sessions()
363  {  {
  # 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  
364   local i   local i
365     local all_ses_ids
366     local all_other_ids
367     local CONFIG
368     local screensaver_passwd_cmd
369    
370     # get all session ids from database
371     all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'")
372     # get all other_menutiem ids from database
373     all_other_ids=$(mysqldo "select id from cfg_other_menuitems where serial='${ALX_SERIAL}'")
374    
375     # get screensaver settings
376     evaluate_table cfg_screensaver
377     # get autostart settings
378     evaluate_table cfg_autostart
379    
380   # now setup fluxbox for user station   # now setup fluxbox for user station
381    
# Line 435  config_sessions() Line 386  config_sessions()
386   # now generate fluxbox config files   # now generate fluxbox config files
387    
388   # fluxbox main config   # fluxbox main config
389   cat ${ALX_SKELETONS}/fluxbox/init \   cat ${ALX_SKELETONS}/fluxbox/init > ${ALX_UNPRIV_HOME}/.fluxbox/init
  > ${ALX_UNPRIV_HOME}/.fluxbox/init  
390    
391   # fluxbox autostart   # fluxbox autostart
392   cat ${ALX_SKELETONS}/fluxbox/apps \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
393   > ${ALX_UNPRIV_HOME}/.fluxbox/apps   # add icon utility
394     [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
395     [ -x /usr/bin/xtdesk ] && addconfig '[startup] {nohup xtdesk > /dev/null &}'
396     # add numlock utility
397     [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
398    
399   # add screensaver   # add screensaver
400   if [[ -n ${ALX_SCRN_SAVER} ]] && [[ -n ${ALX_SCRN_TIMEOUT} ]]   if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]]
401   then   then
402   local ALX_PASSWD_CMD   if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]]
   
  if [[ -z ${ALX_SCRN_PASSWD} ]] || [[ ${ALX_SCRN_PASSWD} = NULL ]]  
403   then   then
404   ALX_PASSWD_CMD="-nolock"   screensaver_passwd_cmd="-nolock"
405   else   else
406   ALX_PASSWD_CMD="-cpasswd $(openssl passwd ${ALX_SCRN_PASSWD})"   screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})"
407   fi   fi
408    
409   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  
410   fi   fi
411    
412   # add autostart session   # add autostart session
413   if [[ ${ALX_AUTOSTART} != "" ]]   if [[ ! -z ${cfg_autostart_session} ]]
414   then   then
415   echo "[startup] {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \   # sleep one second to wait until busybox is fully initialized and the screen is really centered
416   >> ${ALX_UNPRIV_HOME}/.fluxbox/apps   addconfig "[startup] {sleep 1 && nohup nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_autostart_session}) &}"
417   fi   fi
418    
419   # fluxbox hotkeys   # fluxbox hotkeys
420   cat ${ALX_SKELETONS}/fluxbox/keys \   cat ${ALX_SKELETONS}/fluxbox/keys > ${ALX_UNPRIV_HOME}/.fluxbox/keys
  > ${ALX_UNPRIV_HOME}/.fluxbox/keys  
421    
422   # fluxbox menu header   # generate a fluxbox menu
423   cat ${ALX_SKELETONS}/fluxbox/menu.header \   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
424   > ${ALX_UNPRIV_HOME}/.fluxbox/menu   clearconfig
425    
426     # fluxbox menu header
427     cat ${ALX_SKELETONS}/fluxbox/menu.header >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
428   # now fix it with proper messages :P   # now fix it with proper messages :P
429   local ver="$(< /etc/mageversion)"   local ver="$(< /etc/mageversion)"
430   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  
   
431   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
432   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   addconfig
433    
434   # fluxbox menu sessions   # first generate session files
435   for (( i=0; i < count; i++ ))   for i in ${all_ses_ids}
436   do   do
437   [ -n "${ALX_SESSIONS[${i}]}" ] && \   evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
438   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \   generate_ica_session_file \
439   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   --session "${cfg_sessions_session}" \
440     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
441     --username "${cfg_sessions_username}" \
442     --password "${cfg_sessions_password}" \
443     --domain "${cfg_sessions_domain}" \
444     --server "${cfg_sessions_browseradrs}"
445    
446     # fluxbox menusession
447     addconfig "[exec] (${cfg_sessions_session}) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})}"
448   done   done
449    
450     # delete all progs
451     progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
452     [ -d ${progsh_path} ] && rm -rf ${progsh_path}
453     install -d ${progsh_path}
454    
455   # add other menuitems   # add other menuitems
456   get_other_menuitems >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   for i in ${all_other_ids}
457     do
458     evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'"
459    
460   # fluxbox menu footer   # now echo config line for fluxbox-menu
461   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   # make it "configureable" :p
462   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   if [[ -n ${cfg_other_menuitems_workdir} ]]
463     then
464     workdir="--workdir ${cfg_other_menuitems_workdir}"
465     fi
466     if [[ -n ${cfg_other_menuitems_icon} ]]
467     then
468     cfg_other_menuitems_icon="<${cfg_other_menuitems_icon}>"
469     fi
470    
471     # gen prog startup wrapper
472     generate_program_sh \
473     --name "${cfg_other_menuitems_name}" \
474     --exec "${cfg_other_menuitems_exec}" \
475     --param "${cfg_other_menuitems_param}" \
476     --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
477     "${workdir}"
478    
479     addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}"
480     done
481    
482     # fluxbox menu footer
483     cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
484   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
485   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   addconfig
486    
487   # now it's a good time to generate *all* icons :)   # now it's a good time to generate *all* icons :)
488   generate_all_desktop_icons   generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}"
489    
490   # set correct permissions   # fix permissions
491   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
492   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
493   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
494   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop
495   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc   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  
496  }  }
   

Legend:
Removed from v.373  
changed lines
  Added in v.2411