Magellan Linux

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

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

revision 246 by niro, Wed Apr 13 16:09:53 2005 UTC revision 277 by niro, Wed Aug 3 17:56:57 2005 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.5 2005-04-13 16:09:53 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.9 2005-08-03 17:56:57 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 11  get_sessions_settings() Line 11  get_sessions_settings()
11   #get settings from database   #get settings from database
12   all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
13   "select filename from cfg_sessions where serial='${ALX_SERIAL}'")   "select filename from cfg_sessions where serial='${ALX_SERIAL}'")
  #"select session from cfg_sessions where serial='${ALX_SERIAL}'")  
14    
15   #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)
16   declare -i i=0   declare -i i=0
# Line 36  get_autostart_settings() Line 35  get_autostart_settings()
35   ALX_AUTOSTART=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_AUTOSTART=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
36   "select session from cfg_autostart where serial='${ALX_SERIAL}'")   "select session from cfg_autostart where serial='${ALX_SERIAL}'")
37    
38   export ALX_SESSIONS   export ALX_AUTOSTART
39  }  }
40    
41  generate_ica_session_files()  generate_ica_session_files()
# Line 44  generate_ica_session_files() Line 43  generate_ica_session_files()
43   local all_ids   local all_ids
44   local i   local i
45   local x   local x
  local k  
46   local server   local server
47   local ses_session   local ses_session
48   local ses_filename   local ses_filename
# Line 52  generate_ica_session_files() Line 50  generate_ica_session_files()
50   local ses_domain   local ses_domain
51   local ses_password   local ses_password
52   local ses_browseradrs   local ses_browseradrs
53     local ses_colors
54    
55   #get settings from database   #get settings from database
56   all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
57   "select id from cfg_sessions where serial='${ALX_SERIAL}'")   "select id from cfg_sessions where serial='${ALX_SERIAL}'")
58    
  declare -i x=0  
59   for i in ${all_ids}   for i in ${all_ids}
60   do   do
61   # get settings   # get settings
62   ses_session[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_session=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
63   "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   "select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
64    
65   ses_filename[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_filename=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
66   "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   "select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
67    
68   ses_username[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_username=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
69   "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
70    
71   ses_domain[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_domain=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
72   "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   "select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
73    
74   ses_password[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_password=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
75   "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   "select password from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
76    
77   ses_browseradrs[${x}]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ses_browseradrs=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
78   "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")   "select browseradrs from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'")
79    
80     # get the right colors
81     ses_colors=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
82     "select depth from cfg_graphic where serial='${ALX_SERIAL}'")
83     case ${ses_colors} in
84     24) ses_colors="8";;
85     16) ses_colors="4";;
86     8) ses_colors="2";;
87     *) ses_colors="2";;
88     esac
89    
90   # write session files   # write session files
91   echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename}   echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename}
92   echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename}
93   OLD_IFS="$IFS"   OLD_IFS="$IFS"
94   IFS=";"   IFS=";"
95   declare -i k=0   declare -i x=0
96   for server in ${ses_browseradrs[${x}]}   for server in ${ses_browseradrs}
97   do   do
98   (( k++ ))   (( x++ ))
99   echo "TcpBrowserAddress${k}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
100   done   done
101   IFS="${OLD_IFS}"   IFS="${OLD_IFS}"
102   unset k   unset x
103   unset OLD_IFS   unset OLD_IFS
104    
105   echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}
106    
107   echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}
108   echo "${ses_session[${x}]}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}
109    
110   echo "[${ses_session[${x}]}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}
111   echo "Address=${ses_session[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
112   echo "InitialProgram=#${ses_session[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
113   echo 'DesiredColor=3' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "DesiredColor=${ses_colors}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
114   echo 'TransportDriver=TCP/IP' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo 'TransportDriver=TCP/IP' >> ${ALX_ICA_SESSIONS}/${ses_filename}
115   echo 'WinStationDriver=ICA 3.0' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo 'WinStationDriver=ICA 3.0' >> ${ALX_ICA_SESSIONS}/${ses_filename}
116   echo "ClearPassword=${ses_password[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "ClearPassword=${ses_password}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
117   echo "Username=${ses_username[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "Username=${ses_username}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
118   echo "Domain=${ses_domain[${x}]}" >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo "Domain=${ses_domain}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
119   echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename}
120   echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename}   echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename}
121   done   done
122    }
123    
124    get_other_menuitems()
125    {
126     local x i count name exec icon workdir
127    
128     #all arrays:
129     # ->  session1 session2 ... sessionN
130    
131   (( x++ ))   #get settings from database
132     count=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
133     "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'")
134    
135     # get all instances and put them into an array
136     if [ -n "${count}" ]
137     then
138     for x in ${count}
139     do
140     # to be sure
141     unset name
142     unset exec
143     unset workdir
144     unset icon
145    
146     name=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
147     "select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
148    
149     exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
150     "select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
151    
152     workdir=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
153     "select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
154    
155     icon=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
156     "select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'")
157    
158     # debug only
159     #echo "DEBUG: ${x}: name:'${name}' exec:'${exec}' workdir:'${workdir}' ic$
160    
161     # now echo config line for fluxbox-menu
162     # make it "configureable" :P
163     [ -n "${workdir}" ] && workdir="cd ${workdir};"
164     [ -n "${icon}" ] && icon="[${icon}]"
165     echo "[exec] (${name}) {${workdir}${exec}} ${icon}"
166     done
167     fi
168  }  }
169    
170  config_sessions()  config_sessions()
# Line 126  config_sessions() Line 178  config_sessions()
178    
179   local count=${#ALX_SESSIONS[*]}   local count=${#ALX_SESSIONS[*]}
180   local icon   local icon
181     local i
182    
183   # DEBUG   # DEBUG
184  # declare -i i=0  # declare -i i=0
# Line 173  config_sessions() Line 226  config_sessions()
226   # fluxbox menu sessions   # fluxbox menu sessions
227   for (( i=0; i < count; i++ ))   for (( i=0; i < count; i++ ))
228   do   do
229   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \   [ -n "${ALX_SESSIONS[${i}]}" ] && \
230   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \
231     >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
232   done   done
233    
234     # add other menuitems
235     get_other_menuitems >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
236    
237   # fluxbox menu footer   # fluxbox menu footer
238   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   cat ${ALX_SKELETONS}/fluxbox/menu.footer \
239   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   >> ${ALX_UNPRIV_HOME}/.fluxbox/menu

Legend:
Removed from v.246  
changed lines
  Added in v.277