Magellan Linux

Diff of /alx-src/trunk/alxconfig-ng/functions/config_sessions.sh

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

revision 237 by niro, Thu Mar 10 01:13:05 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.2 2005-03-10 01:13:05 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 10  get_sessions_settings() Line 10  get_sessions_settings()
10    
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 session from cfg_sessions where serial='${ALX_SERIAL}'")   "select filename 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 29  get_sessions_settings() Line 29  get_sessions_settings()
29   export ALX_SESSIONS   export ALX_SESSIONS
30  }  }
31    
32    get_autostart_settings()
33    {
34     #get settings from database
35     ALX_AUTOSTART=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
36     "select session from cfg_autostart where serial='${ALX_SERIAL}'")
37    
38     export ALX_AUTOSTART
39    }
40    
41    generate_ica_session_files()
42    {
43     local all_ids
44     local i
45     local x
46     local server
47     local ses_session
48     local ses_filename
49     local ses_username
50     local ses_domain
51     local ses_password
52     local ses_browseradrs
53     local ses_colors
54    
55     #get settings from database
56     all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
57     "select id from cfg_sessions where serial='${ALX_SERIAL}'")
58    
59     for i in ${all_ids}
60     do
61     # get settings
62     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}'")
64    
65     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}'")
67    
68     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}'")
70    
71     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}'")
73    
74     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}'")
76    
77     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}'")
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
91     echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename}
92     echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename}
93     OLD_IFS="$IFS"
94     IFS=";"
95     declare -i x=0
96     for server in ${ses_browseradrs}
97     do
98     (( x++ ))
99     echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
100     done
101     IFS="${OLD_IFS}"
102     unset x
103     unset OLD_IFS
104    
105     echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename}
106    
107     echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename}
108     echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename}
109    
110     echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename}
111     echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
112     echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
113     echo "DesiredColor=${ses_colors}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
114     echo 'TransportDriver=TCP/IP' >> ${ALX_ICA_SESSIONS}/${ses_filename}
115     echo 'WinStationDriver=ICA 3.0' >> ${ALX_ICA_SESSIONS}/${ses_filename}
116     echo "ClearPassword=${ses_password}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
117     echo "Username=${ses_username}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
118     echo "Domain=${ses_domain}" >> ${ALX_ICA_SESSIONS}/${ses_filename}
119     echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename}
120     echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename}
121     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     #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()
171  {  {
172     # generate ica session files
173     generate_ica_session_files
174    
175   #first of all get the vars   #first of all get the vars
176   get_sessions_settings   get_sessions_settings
177     get_autostart_settings
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
185   echo count=${count}  # echo count=${count}
186   echo "Number of new sessions: ${count}"  # echo "Number of new sessions: ${count}"
187   for ((i=0; i < count; i++))  # for ((i=0; i < count; i++))
188   do  # do
189   echo "${i} - ${ALX_SESSIONS[${i}]}"  # echo "${i} - ${ALX_SESSIONS[${i}]}"
190   done  # done
191    
192   # now setup fluxbox for user station   # now setup fluxbox for user station
193    
# Line 62  config_sessions() Line 205  config_sessions()
205   cat ${ALX_SKELETONS}/fluxbox/apps \   cat ${ALX_SKELETONS}/fluxbox/apps \
206   > ${ALX_UNPRIV_HOME}/.fluxbox/apps   > ${ALX_UNPRIV_HOME}/.fluxbox/apps
207    
208     # add autostart session
209     if [[ ${ALX_AUTOSTART} != "" ]]
210     then
211     echo "[startup] {wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \
212     >> ${ALX_UNPRIV_HOME}/.fluxbox/apps
213     fi
214    
215   # fluxbox hotkeys   # fluxbox hotkeys
216   cat ${ALX_SKELETONS}/fluxbox/apps \   cat ${ALX_SKELETONS}/fluxbox/apps \
217   > ${ALX_UNPRIV_HOME}/.fluxbox/keys   > ${ALX_UNPRIV_HOME}/.fluxbox/keys
# Line 70  config_sessions() Line 220  config_sessions()
220   cat ${ALX_SKELETONS}/fluxbox/menu.header \   cat ${ALX_SKELETONS}/fluxbox/menu.header \
221   > ${ALX_UNPRIV_HOME}/.fluxbox/menu   > ${ALX_UNPRIV_HOME}/.fluxbox/menu
222    
223     # add a newline (maybe there is no crlf in the header)
224     echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
225    
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}/${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
240    
241     # add a newline (maybe there is no crlf in the footer)
242     echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
243    
244   # now we generate the desktop icons   # now we generate the desktop icons
245   cat ${ALX_SKELETONS}/idesk/ideskrc \   cat ${ALX_SKELETONS}/idesk/ideskrc \
# Line 104  config_sessions() Line 263  config_sessions()
263    
264   echo "table Icon   echo "table Icon
265  Caption: ${name}  Caption: ${name}
266  Command: wfica ${ALX_ICA_SESSIONS}/${i}  Command: wfica ${ALX_ICA_SESSIONS}/${name}.ica
267  Icon: ${icon}  Icon: ${icon}
268  end" > ${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk  end" > ${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk
269   done   done

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