1 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.11 2005-08-28 19:29:35 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() |
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 |
25 |
count=0 |
count=0 |
26 |
fi |
fi |
27 |
|
|
28 |
|
# get settings from database |
29 |
|
ALX_PROGRAMS=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}'") |
30 |
|
|
31 |
export ALX_SESSIONS |
export ALX_SESSIONS |
32 |
|
export ALX_PROGRAMS |
33 |
} |
} |
34 |
|
|
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 |
57 |
local i |
local i |
58 |
local x |
local x |
59 |
|
local browser_address_num |
60 |
local server |
local server |
61 |
local ses_session |
local ses_session |
62 |
local ses_filename |
local ses_filename |
65 |
local ses_password |
local ses_password |
66 |
local ses_browseradrs |
local ses_browseradrs |
67 |
local ses_colors |
local ses_colors |
68 |
|
local CONFIG |
69 |
|
|
70 |
# get settings from database |
# get settings from database |
71 |
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}'") |
|
72 |
|
|
73 |
for i in ${all_ids} |
for i in ${all_ids} |
74 |
do |
do |
75 |
# get settings |
# get settings |
76 |
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}'") |
77 |
"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}'") |
78 |
|
ses_username=$(mysqldo "select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'") |
79 |
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}'") |
80 |
"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}'") |
81 |
|
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}'") |
|
82 |
|
|
83 |
# get the right colors |
# get the right colors |
84 |
ses_colors=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
ses_colors=$(mysqldo "select depth from cfg_graphic where serial='${ALX_SERIAL}'") |
85 |
"select depth from cfg_graphic where serial='${ALX_SERIAL}'") |
# convert to ica session file values |
86 |
case ${ses_colors} in |
case ${ses_colors} in |
87 |
24) ses_colors="8";; |
24) ses_colors="8";; |
88 |
16) ses_colors="4";; |
16) ses_colors="4";; |
91 |
esac |
esac |
92 |
|
|
93 |
# write session files |
# write session files |
94 |
echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename} |
CONFIG=${ALX_ICA_SESSIONS}/${ses_filename} |
95 |
echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
clearconfig |
96 |
|
|
97 |
|
addconfig '[WFClient]' |
98 |
|
addconfig 'Version=2' |
99 |
OLD_IFS="$IFS" |
OLD_IFS="$IFS" |
100 |
IFS=";" |
IFS=";" |
101 |
declare -i x=0 |
declare -i x=0 |
102 |
for server in ${ses_browseradrs} |
for server in ${ses_browseradrs} |
103 |
do |
do |
104 |
(( x++ )) |
(( x++ )) |
105 |
echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
browser_address_num="${x}" |
106 |
|
# support newer ica-clients: |
107 |
|
# the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !! |
108 |
|
[[ ${x} -eq 1 ]] && browser_address_num="" |
109 |
|
addconfig "TcpBrowserAddress${browser_address_num}=${server}" |
110 |
done |
done |
111 |
IFS="${OLD_IFS}" |
IFS="${OLD_IFS}" |
112 |
unset x |
unset x |
113 |
unset OLD_IFS |
unset OLD_IFS |
|
|
|
|
echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
114 |
|
|
115 |
echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig 'ScreenPercent=0' |
116 |
echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig '[ApplicationServers]' |
117 |
|
addconfig "${ses_session}=" |
118 |
echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig "[${ses_session}]" |
119 |
echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig "Address=${ses_session}" |
120 |
echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig "InitialProgram=#${ses_session}" |
121 |
echo "DesiredColor=${ses_colors}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig "DesiredColor=${ses_colors}" |
122 |
echo 'TransportDriver=TCP/IP' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig 'TransportDriver=TCP/IP' |
123 |
echo 'WinStationDriver=ICA 3.0' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig 'WinStationDriver=ICA 3.0' |
124 |
echo "ClearPassword=${ses_password}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig "ClearPassword=${ses_password}" |
125 |
echo "Username=${ses_username}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig "Username=${ses_username}" |
126 |
echo "Domain=${ses_domain}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig "Domain=${ses_domain}" |
127 |
echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig 'UseFullScreen=Yes' |
128 |
echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
addconfig 'NoWindowManager=True' |
129 |
done |
done |
130 |
} |
} |
131 |
|
|
132 |
|
# generates a sh file to start programs |
133 |
|
generate_program_sh() |
134 |
|
{ |
135 |
|
local dest |
136 |
|
local name |
137 |
|
local exec |
138 |
|
local workdir |
139 |
|
local CONFIG |
140 |
|
|
141 |
|
# very basic getops |
142 |
|
for i in $* |
143 |
|
do |
144 |
|
case $1 in |
145 |
|
--name|-n) shift; name="$1" ;; |
146 |
|
--exec|-x) shift; exec="$1" ;; |
147 |
|
--dest|-d) shift; dest="$1" ;; |
148 |
|
--workdir|-w) shift; workdir="$1" ;; |
149 |
|
esac |
150 |
|
shift |
151 |
|
done |
152 |
|
|
153 |
|
# abort if name, dest or exec not given |
154 |
|
[ -z "${name}" ] && return 1 |
155 |
|
[ -z "${exec}" ] && return 1 |
156 |
|
[ -z "${dest}" ] && return 1 |
157 |
|
|
158 |
|
CONFIG=${dest} |
159 |
|
addconfig "#!/bin/sh" |
160 |
|
[ -n "${workdir}" ] && addconfig "cd ${workdir}" |
161 |
|
addconfig "exec ${exec}" |
162 |
|
|
163 |
|
chmod 0755 ${dest} |
164 |
|
} |
165 |
|
|
166 |
get_other_menuitems() |
get_other_menuitems() |
167 |
{ |
{ |
168 |
local x i count name exec icon workdir |
local x i progsh_path name exec icon workdir |
169 |
|
|
170 |
# all arrays: |
# all arrays: |
171 |
# -> session1 session2 ... sessionN |
# -> session1 session2 ... sessionN |
172 |
|
|
173 |
# get settings from database |
# get settings from database -> now stored in ALX_PROGRAMS |
|
count=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}'") |
|
174 |
|
|
175 |
# get all instances and put them into an array |
# abort if empty |
176 |
if [ -n "${count}" ] |
[ -z "${ALX_PROGRAMS}" ] && return 0 |
177 |
then |
|
178 |
for x in ${count} |
progsh_path=${ALX_UNPRIV_HOME}/.alxprogs |
179 |
do |
[ -d ${progsh_path} ] && rm -rf ${progsh_path} |
180 |
# to be sure |
install -d ${progsh_path} |
181 |
unset name |
|
182 |
unset exec |
# gen menu items |
183 |
unset workdir |
for x in ${ALX_PROGRAMS} |
184 |
unset icon |
do |
185 |
|
# to be sure |
186 |
name=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
unset name |
187 |
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
unset exec |
188 |
|
unset workdir |
189 |
exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
unset icon |
190 |
"select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
191 |
|
name=$(mysqldo "select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
192 |
workdir=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
exec=$(mysqldo "select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
193 |
"select workdir 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}'") |
194 |
|
icon=$(mysqldo "select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
195 |
icon=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
196 |
"select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
# now echo config line for fluxbox-menu |
197 |
|
# make it "configureable" :P |
198 |
# debug only |
[ -n "${workdir}" ] && workdir="--workdir ${workdir}" |
199 |
#echo "DEBUG: ${x}: name:'${name}' exec:'${exec}' workdir:'${workdir}' ic$ |
[ -n "${icon}" ] && icon="<${icon}>" |
200 |
|
|
201 |
# now echo config line for fluxbox-menu |
# gen prog startup wrapper |
202 |
# make it "configureable" :P |
generate_program_sh \ |
203 |
[ -n "${workdir}" ] && workdir="cd ${workdir};" |
--name "${name}" \ |
204 |
[ -n "${icon}" ] && icon="[${icon}]" |
--exec "${exec}" \ |
205 |
echo "[exec] (${name}) {${workdir}${exec}} ${icon}" |
--dest "${progsh_path}/${name}" \ |
206 |
done |
"${workdir}" |
|
fi |
|
|
} |
|
207 |
|
|
208 |
|
echo "[exec] (${name}) {${progsh_path}/${name}} ${icon}" |
209 |
|
done |
210 |
|
} |
211 |
|
|
212 |
# helper functions for generate all desktop icons |
# helper functions for generate all desktop icons |
213 |
generate_icon() |
generate_icon() |
220 |
local xres |
local xres |
221 |
local iwidth |
local iwidth |
222 |
local iheight |
local iheight |
223 |
|
local deficon |
224 |
|
local CONFIG |
225 |
|
|
226 |
# very basic getops |
# very basic getops |
227 |
for i in $* |
for i in $* |
235 |
--yres|-y) shift; yres="$1" ;; |
--yres|-y) shift; yres="$1" ;; |
236 |
--icon-width|-w) shift; iwidth="$1" ;; |
--icon-width|-w) shift; iwidth="$1" ;; |
237 |
--icon-height|-h) shift; iheight="$1" ;; |
--icon-height|-h) shift; iheight="$1" ;; |
238 |
|
--default-icon) shift; deficon="$1" ;; |
239 |
esac |
esac |
240 |
shift |
shift |
241 |
done |
done |
243 |
# some sanity checks : |
# some sanity checks : |
244 |
|
|
245 |
# abort if name or command not given |
# abort if name or command not given |
246 |
[ -z "${name}" ] && return 1 |
[[ -z ${name} ]] && return 1 |
247 |
[ -z "${command}" ] && return 1 |
[[ -z ${command} ]] && return 1 |
248 |
|
|
249 |
# use some defaults for icon, dest, {x,y}res |
# use some defaults for icon, dest, {x,y}res |
250 |
[ -z "${xres}" ] && xres=20 |
[[ -z ${xres} ]] && xres=30 |
251 |
[ -z "${yres}" ] && xres=20 |
[[ -z ${yres} ]] && xres=30 |
252 |
[ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" |
[[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" |
253 |
if [ -z "${icon}" ] || [ ! -f "${icon}" ] |
if [[ -z ${icon} ]] || [ ! -f ${icon} ] |
254 |
then |
then |
255 |
icon="${ALX_SESSIONS_ICONS}/default.png" |
# if no default icon is given use default.png |
256 |
|
[[ -z ${deficon} ]] && deficon="default.png" |
257 |
|
icon="${ALX_SESSIONS_ICONS}/${deficon}" |
258 |
fi |
fi |
259 |
|
|
260 |
echo "table Icon" > ${dest} |
CONFIG=${dest} |
261 |
echo " Type: Program" >> ${dest} |
clearconfig |
262 |
echo " Caption: ${name}" >> ${dest} |
|
263 |
echo " Command: ${command}" >> ${dest} |
addconfig 'table Icon' |
264 |
echo " Icon: ${icon}" >> ${dest} |
addconfig ' Type: Program' |
265 |
echo " X: ${xres}" >> ${dest} |
addconfig " Caption: ${name}" |
266 |
echo " Y: ${yres}" >> ${dest} |
addconfig " Command: ${command}" |
267 |
|
addconfig " Icon: ${icon}" |
268 |
|
addconfig " X: ${xres}" |
269 |
|
addconfig " Y: ${yres}" |
270 |
|
|
271 |
# add these only if not zero |
# add these only if not zero |
272 |
if [ -n "${iwidth}" ] && [ -n "${iheight}" ] |
if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]] |
273 |
then |
then |
274 |
echo " IconWidth: ${iwidth}" >> ${dest} |
addconfig " IconWidth: ${iwidth}" |
275 |
echo " IconHeight: ${iheight}" >> ${dest} |
addconfig " IconHeight: ${iheight}" |
276 |
fi |
fi |
277 |
|
|
278 |
echo "end" >> ${dest} |
addconfig 'end' |
279 |
} |
} |
280 |
|
|
281 |
generate_all_desktop_icons() |
generate_all_desktop_icons() |
287 |
local x |
local x |
288 |
local y |
local y |
289 |
local item |
local item |
290 |
|
local basename_item |
291 |
|
local progsh_path |
292 |
|
|
293 |
# get the resolution |
# get the resolution |
294 |
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}'") |
|
295 |
|
|
296 |
# split res to x & y |
# split res to x & y |
297 |
xres="$(echo ${res} | cut -dx -f1)" |
xres="$(echo ${res} | cut -dx -f1)" |
311 |
|
|
312 |
|
|
313 |
# default settings |
# default settings |
314 |
declare -i x=20 |
declare -i x=30 |
315 |
declare -i y=20 |
declare -i y=30 |
316 |
|
|
317 |
# first all ica sessions |
# first all ica sessions |
318 |
local count=${#ALX_SESSIONS[*]} |
local count=${#ALX_SESSIONS[*]} |
319 |
for (( i=0; i < count; i++ )) |
for (( i=0; i < count; i++ )) |
320 |
do |
do |
321 |
icon_list="${icon_list} $(basename ${ALX_SESSIONS[${i}] .ica})" |
# filenames ! |
322 |
|
icon_list="${icon_list} ${ALX_SESSIONS[${i}]}" |
323 |
done |
done |
324 |
|
|
325 |
for item in ${icon_list} |
for item in ${icon_list} |
326 |
do |
do |
327 |
# abort if empty |
# abort if empty |
328 |
[ -z "${item}" ] && continue |
[[ -z ${item} ]] && continue |
329 |
|
|
330 |
# new line if x > xres |
# new line if x > xres |
331 |
if [ ${x} -ge ${xres} ];then |
if [ ${x} -ge ${xres} ] |
332 |
x=20 |
then |
333 |
|
x=30 |
334 |
y=$((${y} + 80)) |
y=$((${y} + 80)) |
335 |
fi |
fi |
336 |
|
|
337 |
# new row if y > yres |
# new row if y > yres |
338 |
if [ ${y} -ge ${yres} ];then |
if [ ${y} -ge ${yres} ] |
339 |
|
then |
340 |
x=$((${x} + 120)) |
x=$((${x} + 120)) |
341 |
y=20 |
y=30 |
342 |
|
|
343 |
# re-check x |
# re-check x |
344 |
[ ${x} -ge ${xres} ] && x=20 |
[ ${x} -ge ${xres} ] && x=30 |
345 |
|
fi |
346 |
|
|
347 |
|
# ica icons |
348 |
|
# get basename (.ica must be suffix) |
349 |
|
basename_item="$(basename ${item} .ica)" |
350 |
|
generate_icon \ |
351 |
|
--name "${basename_item}" \ |
352 |
|
--command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \ |
353 |
|
--icon "${ALX_SESSIONS_ICONS}/${basename_item}.png" \ |
354 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${basename_item}.lnk" \ |
355 |
|
--xres "${x}" \ |
356 |
|
--yres "${y}" |
357 |
|
|
358 |
|
y=$((${y} + 80)) |
359 |
|
done |
360 |
|
|
361 |
|
|
362 |
|
# generate program icons |
363 |
|
icon_list="${ALX_PROGRAMS}" |
364 |
|
|
365 |
|
progsh_path=${ALX_UNPRIV_HOME}/.alxprogs |
366 |
|
|
367 |
|
for item in ${icon_list} |
368 |
|
do |
369 |
|
# abort if empty |
370 |
|
[[ -z ${item} ]] && continue |
371 |
|
|
372 |
|
# new line if x > xres |
373 |
|
if [ ${x} -ge ${xres} ] |
374 |
|
then |
375 |
|
x=30 |
376 |
|
y=$((${y} + 80)) |
377 |
|
fi |
378 |
|
|
379 |
|
# new row if y > yres |
380 |
|
if [ ${y} -ge ${yres} ] |
381 |
|
then |
382 |
|
x=$((${x} + 120)) |
383 |
|
y=30 |
384 |
|
|
385 |
|
# re-check x |
386 |
|
[ ${x} -ge ${xres} ] && x=30 |
387 |
fi |
fi |
388 |
|
|
389 |
generate_icon \ |
generate_icon \ |
390 |
--name "${item}" \ |
--name "${item}" \ |
391 |
--command "wfica ${ALX_ICA_SESSIONS}/${item}.ica" \ |
--command "${progsh_path}/${item}" \ |
392 |
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
393 |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
394 |
--xres "${x}" \ |
--xres "${x}" \ |
395 |
--yres "${y}" |
--yres "${y}" \ |
396 |
|
--default-icon "default_item.png" |
397 |
|
|
398 |
y=$((${y} + 80)) |
y=$((${y} + 80)) |
399 |
done |
done |
400 |
|
|
401 |
|
|
402 |
|
|
403 |
# last but not least gen a icon with some sys informations |
# last but not least gen a icon with some sys informations |
404 |
local sysinfo |
local sysinfo |
405 |
local hostname |
local hostname |
406 |
local osversion |
local osversion |
407 |
|
|
408 |
osversion="$(< /etc/mageversion)" |
osversion="$(< /etc/mageversion)" |
409 |
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}'") |
|
410 |
sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
411 |
|
|
412 |
# now get the right position: |
# now get the right position: |
437 |
# first of all get the vars |
# first of all get the vars |
438 |
get_sessions_settings |
get_sessions_settings |
439 |
get_autostart_settings |
get_autostart_settings |
440 |
|
get_screensaver_settings |
441 |
|
|
442 |
local count=${#ALX_SESSIONS[*]} |
local count=${#ALX_SESSIONS[*]} |
443 |
local icon |
local icon |
444 |
local i |
local i |
445 |
|
local CONFIG |
|
# 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 |
|
446 |
|
|
447 |
# now setup fluxbox for user station |
# now setup fluxbox for user station |
448 |
|
|
460 |
cat ${ALX_SKELETONS}/fluxbox/apps \ |
cat ${ALX_SKELETONS}/fluxbox/apps \ |
461 |
> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
462 |
|
|
463 |
|
CONFIG=${ALX_UNPRIV_HOME}/.fluxbox/apps |
464 |
|
# add screensaver |
465 |
|
if [[ ! -z ${ALX_SCRN_SAVER} ]] && [[ ! -z ${ALX_SCRN_TIMEOUT} ]] |
466 |
|
then |
467 |
|
local ALX_PASSWD_CMD |
468 |
|
|
469 |
|
if [[ -z ${ALX_SCRN_PASSWD} ]] || [[ ${ALX_SCRN_PASSWD} = NULL ]] |
470 |
|
then |
471 |
|
ALX_PASSWD_CMD="-nolock" |
472 |
|
else |
473 |
|
ALX_PASSWD_CMD="-cpasswd $(cryptpw -m des ${ALX_SCRN_PASSWD})" |
474 |
|
fi |
475 |
|
|
476 |
|
addconfig "[startup] {nohup xautolock -time ${ALX_SCRN_TIMEOUT} -locker 'xlock -mode ${ALX_SCRN_SAVER} ${ALX_PASSWD_CMD}' > /dev/null &}" |
477 |
|
fi |
478 |
|
|
479 |
# add autostart session |
# add autostart session |
480 |
if [[ ${ALX_AUTOSTART} != "" ]] |
if [[ ! -z ${ALX_AUTOSTART} ]] |
481 |
then |
then |
482 |
echo "[startup] {wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \ |
addconfig "[startup] {nohup nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART} &}" |
|
>> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
|
483 |
fi |
fi |
484 |
|
|
485 |
# fluxbox hotkeys |
# fluxbox hotkeys |
486 |
cat ${ALX_SKELETONS}/fluxbox/apps \ |
cat ${ALX_SKELETONS}/fluxbox/keys > ${ALX_UNPRIV_HOME}/.fluxbox/keys |
487 |
> ${ALX_UNPRIV_HOME}/.fluxbox/keys |
|
488 |
|
# generate a fluxbox menu |
489 |
|
CONFIG=${ALX_UNPRIV_HOME}/.fluxbox/menu |
490 |
|
clearconfig |
491 |
|
|
492 |
# fluxbox menu header |
# fluxbox menu header |
493 |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
cat ${ALX_SKELETONS}/fluxbox/menu.header >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
494 |
|
|
495 |
# now fix it with proper messages :P |
# now fix it with proper messages :P |
496 |
local ver="$(< /etc/mageversion)" |
local ver="$(< /etc/mageversion)" |
497 |
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 |
|
498 |
|
|
499 |
# add a newline (maybe there is no crlf in the header) |
# add a newline (maybe there is no crlf in the header) |
500 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig |
501 |
|
|
502 |
# fluxbox menu sessions |
# fluxbox menu sessions |
503 |
for (( i=0; i < count; i++ )) |
for (( i=0; i < count; i++ )) |
504 |
do |
do |
505 |
[ -n "${ALX_SESSIONS[${i}]}" ] && \ |
if [[ ! -z ${ALX_SESSIONS[${i}]} ]] |
506 |
echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \ |
then |
507 |
>> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" |
508 |
|
fi |
509 |
done |
done |
510 |
|
|
511 |
# add other menuitems |
# add other menuitems |
512 |
get_other_menuitems >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig $(get_other_menuitems) |
513 |
|
|
514 |
# fluxbox menu footer |
# fluxbox menu footer |
515 |
cat ${ALX_SKELETONS}/fluxbox/menu.footer \ |
cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
>> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
516 |
|
|
517 |
# add a newline (maybe there is no crlf in the footer) |
# add a newline (maybe there is no crlf in the footer) |
518 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig |
519 |
|
|
520 |
# now it's a good time to generate *all* icons :) |
# now it's a good time to generate *all* icons :) |
521 |
generate_all_desktop_icons |
generate_all_desktop_icons |
524 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
525 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
526 |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
527 |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
528 |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
529 |
|
|
530 |
# unset vars |
# unset vars |
531 |
unset ALX_SESSIONS |
unset ALX_SESSIONS |
532 |
|
unset ALX_PROGRAMS |
533 |
|
unset ALX_SCRN_SAVER |
534 |
|
unset ALX_SCRN_TIMEOUT |
535 |
|
unset ALX_SCRN_PASSWD |
536 |
} |
} |