1 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.10 2005-08-18 02:51:16 niro Exp $ |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.11 2005-08-28 19:29:35 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() |
167 |
fi |
fi |
168 |
} |
} |
169 |
|
|
170 |
|
|
171 |
|
# helper functions for generate all desktop icons |
172 |
|
generate_icon() |
173 |
|
{ |
174 |
|
local name |
175 |
|
local icon |
176 |
|
local command |
177 |
|
local dest |
178 |
|
local yres |
179 |
|
local xres |
180 |
|
local iwidth |
181 |
|
local iheight |
182 |
|
|
183 |
|
# very basic getops |
184 |
|
for i in $* |
185 |
|
do |
186 |
|
case $1 in |
187 |
|
--name|-n) shift; name="$1" ;; |
188 |
|
--command|-c) shift; command="$1" ;; |
189 |
|
--icon|-i) shift; icon="$1" ;; |
190 |
|
--dest|-d) shift; dest="$1" ;; |
191 |
|
--xres|-x) shift; xres="$1" ;; |
192 |
|
--yres|-y) shift; yres="$1" ;; |
193 |
|
--icon-width|-w) shift; iwidth="$1" ;; |
194 |
|
--icon-height|-h) shift; iheight="$1" ;; |
195 |
|
esac |
196 |
|
shift |
197 |
|
done |
198 |
|
|
199 |
|
# some sanity checks : |
200 |
|
|
201 |
|
# abort if name or command not given |
202 |
|
[ -z "${name}" ] && return 1 |
203 |
|
[ -z "${command}" ] && return 1 |
204 |
|
|
205 |
|
# use some defaults for icon, dest, {x,y}res |
206 |
|
[ -z "${xres}" ] && xres=20 |
207 |
|
[ -z "${yres}" ] && xres=20 |
208 |
|
[ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" |
209 |
|
if [ -z "${icon}" ] || [ ! -f "${icon}" ] |
210 |
|
then |
211 |
|
icon="${ALX_SESSIONS_ICONS}/default.png" |
212 |
|
fi |
213 |
|
|
214 |
|
echo "table Icon" > ${dest} |
215 |
|
echo " Type: Program" >> ${dest} |
216 |
|
echo " Caption: ${name}" >> ${dest} |
217 |
|
echo " Command: ${command}" >> ${dest} |
218 |
|
echo " Icon: ${icon}" >> ${dest} |
219 |
|
echo " X: ${xres}" >> ${dest} |
220 |
|
echo " Y: ${yres}" >> ${dest} |
221 |
|
|
222 |
|
# add these only if not zero |
223 |
|
if [ -n "${iwidth}" ] && [ -n "${iheight}" ] |
224 |
|
then |
225 |
|
echo " IconWidth: ${iwidth}" >> ${dest} |
226 |
|
echo " IconHeight: ${iheight}" >> ${dest} |
227 |
|
fi |
228 |
|
|
229 |
|
echo "end" >> ${dest} |
230 |
|
} |
231 |
|
|
232 |
|
generate_all_desktop_icons() |
233 |
|
{ |
234 |
|
local res |
235 |
|
local xres |
236 |
|
local yres |
237 |
|
local icon_list |
238 |
|
local x |
239 |
|
local y |
240 |
|
local item |
241 |
|
|
242 |
|
# get the resolution |
243 |
|
res=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
244 |
|
"select resolution from cfg_graphic where serial='${ALX_SERIAL}'") |
245 |
|
|
246 |
|
# split res to x & y |
247 |
|
xres="$(echo ${res} | cut -dx -f1)" |
248 |
|
yres="$(echo ${res} | cut -dx -f2)" |
249 |
|
|
250 |
|
# top left edge of the icon is given in config file |
251 |
|
# remove a little bit to simulate the bottom-right edge |
252 |
|
xres="$(( ${xres} - 120 ))" |
253 |
|
yres="$(( ${yres} - 80 ))" |
254 |
|
|
255 |
|
# basic config |
256 |
|
cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc |
257 |
|
|
258 |
|
# clean desktop icon location |
259 |
|
[ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop |
260 |
|
install -d ${ALX_UNPRIV_HOME}/.xtdesktop |
261 |
|
|
262 |
|
|
263 |
|
# default settings |
264 |
|
declare -i x=20 |
265 |
|
declare -i y=20 |
266 |
|
|
267 |
|
# first all ica sessions |
268 |
|
local count=${#ALX_SESSIONS[*]} |
269 |
|
for (( i=0; i < count; i++ )) |
270 |
|
do |
271 |
|
icon_list="${icon_list} $(basename ${ALX_SESSIONS[${i}] .ica})" |
272 |
|
done |
273 |
|
|
274 |
|
for item in ${icon_list} |
275 |
|
do |
276 |
|
# abort if empty |
277 |
|
[ -z "${item}" ] && continue |
278 |
|
|
279 |
|
# new line if x > xres |
280 |
|
if [ ${x} -ge ${xres} ];then |
281 |
|
x=20 |
282 |
|
y=$((${y} + 80)) |
283 |
|
fi |
284 |
|
|
285 |
|
# new row if y > yres |
286 |
|
if [ ${y} -ge ${yres} ];then |
287 |
|
x=$((${x} + 120)) |
288 |
|
y=20 |
289 |
|
|
290 |
|
# re-check x |
291 |
|
[ ${x} -ge ${xres} ] && x=20 |
292 |
|
fi |
293 |
|
|
294 |
|
generate_icon \ |
295 |
|
--name "${item}" \ |
296 |
|
--command "wfica ${ALX_ICA_SESSIONS}/${item}.ica" \ |
297 |
|
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
298 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
299 |
|
--xres "${x}" \ |
300 |
|
--yres "${y}" |
301 |
|
|
302 |
|
y=$((${y} + 80)) |
303 |
|
done |
304 |
|
|
305 |
|
|
306 |
|
# last but not least gen a icon with some sys informations |
307 |
|
local sysinfo |
308 |
|
local hostname |
309 |
|
local osversion |
310 |
|
|
311 |
|
osversion="$(< /etc/mageversion)" |
312 |
|
hostname=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
313 |
|
"select hostname from cfg_network where serial='${ALX_SERIAL}'") |
314 |
|
sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
315 |
|
|
316 |
|
# now get the right position: |
317 |
|
# restore orig values of xres |
318 |
|
xres="$(( ${xres} + 120 ))" |
319 |
|
# default y pos (full yres -22 = cur yres + 58 !) |
320 |
|
yres="$(( ${yres} + 58 ))" |
321 |
|
# middle of the screen |
322 |
|
# (no txt - length required, xtdesk manage that itself) |
323 |
|
xres="$(( ${xres} / 2))" |
324 |
|
|
325 |
|
generate_icon \ |
326 |
|
--name "${sysinfo}" \ |
327 |
|
--command "exit 0" \ |
328 |
|
--icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
329 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ |
330 |
|
--xres "${xres}" \ |
331 |
|
--yres "${yres}" \ |
332 |
|
--icon-width "1" \ |
333 |
|
--icon-height "1" |
334 |
|
} |
335 |
|
|
336 |
config_sessions() |
config_sessions() |
337 |
{ |
{ |
338 |
# generate ica session files |
# generate ica session files |
412 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
413 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
414 |
|
|
415 |
# now we generate the desktop icons |
# now it's a good time to generate *all* icons :) |
416 |
cat ${ALX_SKELETONS}/idesk/ideskrc \ |
generate_all_desktop_icons |
|
> ${ALX_UNPRIV_HOME}/.ideskrc |
|
|
|
|
|
# whipe out old stuff and install a fresh directory |
|
|
[ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop |
|
|
install -d ${ALX_UNPRIV_HOME}/.idesktop |
|
|
|
|
|
local name |
|
|
for (( i=0; i < count; i++ )) |
|
|
do |
|
|
name="$(basename ${ALX_SESSIONS[${i}]} .ica)" |
|
|
|
|
|
if [ -f ${ALX_SESSIONS_ICONS}/${name}.png ] |
|
|
then |
|
|
icon="${ALX_SESSIONS_ICONS}/${name}.png" |
|
|
else |
|
|
icon="${ALX_SESSIONS_ICONS}/default.png" |
|
|
fi |
|
|
|
|
|
echo "table Icon |
|
|
Caption: ${name} |
|
|
Command: wfica ${ALX_ICA_SESSIONS}/${name}.ica |
|
|
Icon: ${icon} |
|
|
end" > ${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk |
|
|
done |
|
417 |
|
|
418 |
# set correct permissions |
# set correct permissions |
419 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
420 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
421 |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
422 |
chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
423 |
chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
|
|
|
424 |
|
|
425 |
# unset vars |
# unset vars |
426 |
unset ALX_SESSIONS |
unset ALX_SESSIONS |