Annotation of /alx-src/branches/alxconf-060/functions/config_sessions.sh
Parent Directory | Revision Log
Revision 6765 -
(hide annotations)
(download)
(as text)
Tue Jul 21 12:18:38 2015 UTC (8 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 18205 byte(s)
Tue Jul 21 12:18:38 2015 UTC (8 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 18205 byte(s)
-respect storefront/pnabrowse stores and always use generate_program_sh to make the session startup handling easier
1 | niro | 2001 | # $Id$ |
2 | niro | 236 | # configures ica-sessions on the host via mysql db settings |
3 | |||
4 | niro | 2161 | fix_whitespaces() |
5 | { | ||
6 | local var="$@" | ||
7 | echo "${var//\ /_}" | ||
8 | } | ||
9 | |||
10 | niro | 2149 | # helper function to create citrix session files |
11 | generate_ica_session_file() | ||
12 | niro | 236 | { |
13 | niro | 246 | local i |
14 | niro | 2149 | local num |
15 | niro | 246 | local server |
16 | local ses_session | ||
17 | local ses_filename | ||
18 | local ses_username | ||
19 | local ses_domain | ||
20 | local ses_password | ||
21 | local ses_browseradrs | ||
22 | niro | 2435 | local ses_colors |
23 | niro | 2035 | local CONFIG |
24 | niro | 246 | |
25 | niro | 2149 | # very basic getops |
26 | for i in $* | ||
27 | niro | 246 | do |
28 | niro | 2149 | case $1 in |
29 | --session) shift; ses_session="$1" ;; | ||
30 | --filename) shift; ses_filename="$1" ;; | ||
31 | --username) shift; ses_username="$1" ;; | ||
32 | --password) shift; ses_password="$1" ;; | ||
33 | --domain) shift; ses_domain="$1" ;; | ||
34 | niro | 2161 | --server) shift; ses_browseradrs="$1" ;; |
35 | niro | 2435 | --colordepth) shift; ses_colors="$1" ;; |
36 | niro | 6763 | esac |
37 | niro | 2149 | shift |
38 | done | ||
39 | niro | 246 | |
40 | niro | 2149 | # abort if session, filename or server not given |
41 | niro | 2161 | [[ -z ${ses_session} ]] && return 1 |
42 | [[ -z ${ses_filename} ]] && return 1 | ||
43 | [[ -z ${ses_browseradrs} ]] && return 1 | ||
44 | niro | 272 | |
45 | niro | 2149 | # write session files |
46 | CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}" | ||
47 | clearconfig | ||
48 | niro | 2035 | |
49 | niro | 2149 | addconfig '[WFClient]' |
50 | addconfig 'Version=2' | ||
51 | niro | 1654 | |
52 | niro | 2149 | # use ';' as ifs |
53 | declare -i i=0 | ||
54 | for server in ${ses_browseradrs//;/ } | ||
55 | do | ||
56 | (( i++ )) | ||
57 | num="${i}" | ||
58 | # support newer ica-clients: | ||
59 | # the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !! | ||
60 | [[ ${i} -eq 1 ]] && num="" | ||
61 | addconfig "TcpBrowserAddress${num}=${server}" | ||
62 | niro | 5618 | addconfig "HttpBrowserAddress${num}=${server}" |
63 | niro | 246 | done |
64 | niro | 2149 | |
65 | addconfig 'ScreenPercent=0' | ||
66 | addconfig '[ApplicationServers]' | ||
67 | addconfig "${ses_session}=" | ||
68 | addconfig "[${ses_session}]" | ||
69 | addconfig "Address=${ses_session}" | ||
70 | addconfig "InitialProgram=#${ses_session}" | ||
71 | niro | 2435 | |
72 | # convert to ica session file values | ||
73 | case ${ses_colors} in | ||
74 | 24|32) ses_colors="8";; | ||
75 | 16) ses_colors="4";; | ||
76 | 8) ses_colors="2";; | ||
77 | *) ses_colors="4";; # default to 16bit | ||
78 | esac | ||
79 | addconfig "DesiredColor=${ses_colors}" | ||
80 | niro | 2149 | addconfig 'TransportDriver=TCP/IP' |
81 | addconfig 'WinStationDriver=ICA 3.0' | ||
82 | niro | 2611 | addconfig "ClearPassword=${ses_password}" |
83 | niro | 2149 | addconfig "Username=${ses_username}" |
84 | addconfig "Domain=${ses_domain}" | ||
85 | addconfig 'UseFullScreen=Yes' | ||
86 | addconfig 'NoWindowManager=True' | ||
87 | niro | 246 | } |
88 | |||
89 | niro | 6765 | generate_storefront_sh() |
90 | { | ||
91 | local server | ||
92 | local ses_session | ||
93 | local ses_filename | ||
94 | local ses_username | ||
95 | local ses_domain | ||
96 | local ses_password | ||
97 | local ses_browseradrs | ||
98 | |||
99 | # very basic getops | ||
100 | for i in $* | ||
101 | do | ||
102 | case $1 in | ||
103 | --session) shift; ses_session="$1" ;; | ||
104 | --filename) shift; ses_filename="$1" ;; | ||
105 | --username) shift; ses_username="$1" ;; | ||
106 | --password) shift; ses_password="$1" ;; | ||
107 | --domain) shift; ses_domain="$1" ;; | ||
108 | --server) shift; ses_browseradrs="$1" ;; | ||
109 | esac | ||
110 | shift | ||
111 | done | ||
112 | |||
113 | generate_program_sh \ | ||
114 | --name "${ses_session}" \ | ||
115 | --exec "storefront-resolver" \ | ||
116 | --param "launch '${ses_username}' '${ses_password}' '${ses_domain}' '${ses_session}'" \ | ||
117 | --dest "${ALX_UNPRIV_HOME}/.alxprogs/$(fix_whitespaces ${ses_filename})" \ | ||
118 | --environment "STORE=${ses_browseradrs}" | ||
119 | } | ||
120 | |||
121 | niro | 317 | # generates a sh file to start programs |
122 | generate_program_sh() | ||
123 | { | ||
124 | local dest | ||
125 | local name | ||
126 | local exec | ||
127 | niro | 2161 | local param |
128 | niro | 317 | local workdir |
129 | niro | 2035 | local CONFIG |
130 | niro | 317 | |
131 | # very basic getops | ||
132 | for i in $* | ||
133 | do | ||
134 | case $1 in | ||
135 | --name|-n) shift; name="$1" ;; | ||
136 | --exec|-x) shift; exec="$1" ;; | ||
137 | niro | 2161 | --param|-p) shift; param="$1" ;; |
138 | niro | 317 | --dest|-d) shift; dest="$1" ;; |
139 | --workdir|-w) shift; workdir="$1" ;; | ||
140 | niro | 6765 | --environment|-e) shift; environment="$1" ;; |
141 | niro | 6763 | esac |
142 | niro | 317 | shift |
143 | done | ||
144 | |||
145 | # abort if name, dest or exec not given | ||
146 | niro | 2149 | [[ -z ${name} ]] && return 1 |
147 | [[ -z ${exec} ]] && return 1 | ||
148 | [[ -z ${dest} ]] && return 1 | ||
149 | niro | 317 | |
150 | niro | 2149 | CONFIG="${dest}" |
151 | niro | 2035 | addconfig "#!/bin/sh" |
152 | niro | 6765 | [[ -n ${environment} ]] && addconfig "export ${environment}" |
153 | [[ -n ${workdir} ]] && addconfig "cd ${workdir}" | ||
154 | niro | 2161 | addconfig "exec ${exec} ${param}" |
155 | niro | 317 | |
156 | niro | 2149 | chmod 0755 "${dest}" |
157 | niro | 317 | } |
158 | |||
159 | niro | 304 | # helper functions for generate all desktop icons |
160 | generate_icon() | ||
161 | { | ||
162 | local name | ||
163 | local icon | ||
164 | local command | ||
165 | local dest | ||
166 | local yres | ||
167 | local xres | ||
168 | local iwidth | ||
169 | local iheight | ||
170 | niro | 317 | local deficon |
171 | niro | 2035 | local CONFIG |
172 | niro | 2401 | local utility |
173 | niro | 304 | |
174 | # very basic getops | ||
175 | for i in $* | ||
176 | do | ||
177 | case $1 in | ||
178 | --name|-n) shift; name="$1" ;; | ||
179 | --command|-c) shift; command="$1" ;; | ||
180 | --icon|-i) shift; icon="$1" ;; | ||
181 | --dest|-d) shift; dest="$1" ;; | ||
182 | --xres|-x) shift; xres="$1" ;; | ||
183 | --yres|-y) shift; yres="$1" ;; | ||
184 | --icon-width|-w) shift; iwidth="$1" ;; | ||
185 | --icon-height|-h) shift; iheight="$1" ;; | ||
186 | niro | 317 | --default-icon) shift; deficon="$1" ;; |
187 | niro | 6763 | esac |
188 | niro | 304 | shift |
189 | done | ||
190 | |||
191 | niro | 2149 | # some sanity checks: |
192 | niro | 2401 | |
193 | niro | 304 | # abort if name or command not given |
194 | niro | 2035 | [[ -z ${name} ]] && return 1 |
195 | [[ -z ${command} ]] && return 1 | ||
196 | niro | 304 | |
197 | niro | 2454 | [[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk" |
198 | niro | 2401 | |
199 | niro | 304 | # use some defaults for icon, dest, {x,y}res |
200 | niro | 2495 | [[ -z ${xres} ]] && xres=50 |
201 | [[ -z ${yres} ]] && xres=50 | ||
202 | niro | 2035 | if [[ -z ${icon} ]] || [ ! -f ${icon} ] |
203 | niro | 304 | then |
204 | niro | 317 | # if no default icon is given use default.png |
205 | niro | 2035 | [[ -z ${deficon} ]] && deficon="default.png" |
206 | niro | 317 | icon="${ALX_SESSIONS_ICONS}/${deficon}" |
207 | niro | 304 | fi |
208 | |||
209 | niro | 2161 | CONFIG="${dest}" |
210 | niro | 2035 | clearconfig |
211 | niro | 304 | |
212 | niro | 2035 | addconfig 'table Icon' |
213 | addconfig " Caption: ${name}" | ||
214 | addconfig " Command: ${command}" | ||
215 | addconfig " Icon: ${icon}" | ||
216 | addconfig " X: ${xres}" | ||
217 | addconfig " Y: ${yres}" | ||
218 | |||
219 | niro | 304 | # add these only if not zero |
220 | niro | 2035 | if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]] |
221 | niro | 304 | then |
222 | niro | 2454 | addconfig " Width: ${iwidth}" |
223 | addconfig " Height: ${iheight}" | ||
224 | niro | 304 | fi |
225 | |||
226 | niro | 2035 | addconfig 'end' |
227 | niro | 304 | } |
228 | |||
229 | generate_all_desktop_icons() | ||
230 | { | ||
231 | niro | 2149 | local session_list="$1" |
232 | local other_menuitem_list="$2" | ||
233 | niro | 2747 | local plugin_list="$3" |
234 | niro | 304 | local res |
235 | local xres | ||
236 | local yres | ||
237 | local x | ||
238 | local y | ||
239 | niro | 2161 | local i |
240 | niro | 2149 | local name |
241 | niro | 317 | local progsh_path |
242 | niro | 2401 | local utility |
243 | local dest | ||
244 | local rc | ||
245 | niro | 304 | |
246 | niro | 2454 | dest="${ALX_UNPRIV_HOME}/.idesktop" |
247 | rc="${ALX_UNPRIV_HOME}/.ideskrc" | ||
248 | niro | 2401 | |
249 | niro | 2149 | # progsh path |
250 | niro | 2161 | progsh_path="${ALX_UNPRIV_HOME}/.alxprogs" |
251 | niro | 2149 | |
252 | niro | 304 | # get the resolution |
253 | niro | 342 | res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'") |
254 | niro | 304 | |
255 | # split res to x & y | ||
256 | niro | 2149 | xres="${res%x*}" |
257 | niro | 2166 | yres="${res#*x}" |
258 | niro | 304 | |
259 | # top left edge of the icon is given in config file | ||
260 | # remove a little bit to simulate the bottom-right edge | ||
261 | xres="$(( ${xres} - 120 ))" | ||
262 | yres="$(( ${yres} - 80 ))" | ||
263 | |||
264 | # clean desktop icon location | ||
265 | niro | 2401 | [ -d ${dest} ] && rm -rf ${dest} |
266 | [ -f ${rc} ] && rm -f ${rc} | ||
267 | install -d ${dest} | ||
268 | niro | 304 | |
269 | # default settings | ||
270 | niro | 2495 | declare -i x=50 |
271 | declare -i y=50 | ||
272 | niro | 304 | |
273 | niro | 2149 | # ica icons |
274 | niro | 2161 | for i in ${session_list} |
275 | niro | 304 | do |
276 | # abort if empty | ||
277 | niro | 2161 | [[ -z ${i} ]] && continue |
278 | niro | 304 | |
279 | niro | 2161 | # get database information |
280 | evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" | ||
281 | |||
282 | niro | 304 | # new line if x > xres |
283 | niro | 2035 | if [ ${x} -ge ${xres} ] |
284 | then | ||
285 | niro | 2495 | x=50 |
286 | niro | 304 | y=$((${y} + 80)) |
287 | fi | ||
288 | |||
289 | # new row if y > yres | ||
290 | niro | 2035 | if [ ${y} -ge ${yres} ] |
291 | then | ||
292 | niro | 304 | x=$((${x} + 120)) |
293 | niro | 2495 | y=50 |
294 | niro | 304 | |
295 | # re-check x | ||
296 | niro | 2495 | [ ${x} -ge ${xres} ] && x=50 |
297 | niro | 304 | fi |
298 | |||
299 | generate_icon \ | ||
300 | niro | 2166 | --name "${cfg_sessions_session}" \ |
301 | niro | 6765 | --command "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \ |
302 | niro | 2166 | --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \ |
303 | niro | 2401 | --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \ |
304 | niro | 304 | --xres "${x}" \ |
305 | --yres "${y}" | ||
306 | |||
307 | y=$((${y} + 80)) | ||
308 | done | ||
309 | |||
310 | niro | 2161 | for i in ${other_menuitem_list} |
311 | niro | 317 | do |
312 | # abort if empty | ||
313 | niro | 2161 | [[ -z ${i} ]] && continue |
314 | niro | 317 | |
315 | niro | 2161 | # get database information |
316 | evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" | ||
317 | |||
318 | niro | 317 | # new line if x > xres |
319 | niro | 2035 | if [ ${x} -ge ${xres} ] |
320 | then | ||
321 | niro | 2495 | x=50 |
322 | niro | 317 | y=$((${y} + 80)) |
323 | fi | ||
324 | |||
325 | # new row if y > yres | ||
326 | niro | 2035 | if [ ${y} -ge ${yres} ] |
327 | then | ||
328 | niro | 317 | x=$((${x} + 120)) |
329 | niro | 2495 | y=50 |
330 | niro | 317 | |
331 | # re-check x | ||
332 | niro | 2495 | [ ${x} -ge ${xres} ] && x=50 |
333 | niro | 317 | fi |
334 | |||
335 | generate_icon \ | ||
336 | niro | 2161 | --name "${cfg_other_menuitems_name}" \ |
337 | niro | 2381 | --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \ |
338 | niro | 6759 | --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_icon}).png" \ |
339 | niro | 2401 | --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \ |
340 | niro | 317 | --xres "${x}" \ |
341 | --yres "${y}" \ | ||
342 | --default-icon "default_item.png" | ||
343 | |||
344 | y=$((${y} + 80)) | ||
345 | done | ||
346 | niro | 2747 | |
347 | for i in ${plugin_list} | ||
348 | do | ||
349 | # abort if empty | ||
350 | [[ -z ${i} ]] && continue | ||
351 | niro | 3490 | |
352 | niro | 2747 | evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" |
353 | if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] | ||
354 | then | ||
355 | eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem) | ||
356 | niro | 317 | |
357 | niro | 2747 | # abort if name or exec is empty |
358 | [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue | ||
359 | [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue | ||
360 | |||
361 | # new line if x > xres | ||
362 | if [ ${x} -ge ${xres} ] | ||
363 | then | ||
364 | x=50 | ||
365 | y=$((${y} + 80)) | ||
366 | fi | ||
367 | |||
368 | # new row if y > yres | ||
369 | if [ ${y} -ge ${yres} ] | ||
370 | then | ||
371 | x=$((${x} + 120)) | ||
372 | y=50 | ||
373 | |||
374 | # re-check x | ||
375 | [ ${x} -ge ${xres} ] && x=50 | ||
376 | fi | ||
377 | |||
378 | generate_icon \ | ||
379 | --name "${PLUGIN_MENUITEM_NAME}" \ | ||
380 | --command "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \ | ||
381 | --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).png" \ | ||
382 | --dest "${dest}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).lnk" \ | ||
383 | --xres "${x}" \ | ||
384 | --yres "${y}" \ | ||
385 | --default-icon "default_item.png" | ||
386 | |||
387 | y=$((${y} + 80)) | ||
388 | fi | ||
389 | |||
390 | # unset all variables | ||
391 | unset PLUGIN_MENUITEM_NAME | ||
392 | unset PLUGIN_MENUITEM_EXEC | ||
393 | unset PLUGIN_MENUITEM_PARAM | ||
394 | unset PLUGIN_MENUITEM_WORKDIR | ||
395 | unset PLUGIN_MENUITEM_ICON | ||
396 | done | ||
397 | |||
398 | niro | 2469 | # add shutdown, reboot icons |
399 | for i in shutdown reboot | ||
400 | do | ||
401 | # new line if x > xres | ||
402 | if [ ${x} -ge ${xres} ] | ||
403 | then | ||
404 | niro | 2495 | x=50 |
405 | niro | 2469 | y=$((${y} + 80)) |
406 | fi | ||
407 | |||
408 | # new row if y > yres | ||
409 | if [ ${y} -ge ${yres} ] | ||
410 | then | ||
411 | x=$((${x} + 120)) | ||
412 | niro | 2495 | y=50 |
413 | niro | 2469 | |
414 | # re-check x | ||
415 | niro | 2495 | [ ${x} -ge ${xres} ] && x=50 |
416 | niro | 2469 | fi |
417 | |||
418 | case ${i} in | ||
419 | niro | 2479 | shutdown) name="Herunterfahren" ;; |
420 | reboot) name="Neustarten" ;; | ||
421 | niro | 2469 | esac |
422 | |||
423 | generate_icon \ | ||
424 | --name "${name}" \ | ||
425 | --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \ | ||
426 | --icon "${ALX_SESSIONS_ICONS}/${i}.png" \ | ||
427 | --dest "${dest}/${i}.lnk" \ | ||
428 | --xres "${x}" \ | ||
429 | niro | 2565 | --yres "${y}" \ |
430 | --icon-width "40" \ | ||
431 | --icon-height "40" | ||
432 | niro | 2469 | |
433 | y=$((${y} + 80)) | ||
434 | done | ||
435 | |||
436 | niro | 304 | # last but not least gen a icon with some sys informations |
437 | local sysinfo | ||
438 | local hostname | ||
439 | local osversion | ||
440 | |||
441 | osversion="$(< /etc/mageversion)" | ||
442 | niro | 342 | hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'") |
443 | niro | 304 | sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
444 | |||
445 | # now get the right position: | ||
446 | # restore orig values of xres | ||
447 | xres="$(( ${xres} + 120 ))" | ||
448 | # default y pos (full yres -22 = cur yres + 58 !) | ||
449 | yres="$(( ${yres} + 58 ))" | ||
450 | # middle of the screen | ||
451 | # (no txt - length required, xtdesk manage that itself) | ||
452 | xres="$(( ${xres} / 2))" | ||
453 | |||
454 | generate_icon \ | ||
455 | --name "${sysinfo}" \ | ||
456 | --command "exit 0" \ | ||
457 | --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ | ||
458 | niro | 2401 | --dest "${dest}/sysinfo.lnk" \ |
459 | niro | 304 | --xres "${xres}" \ |
460 | --yres "${yres}" \ | ||
461 | --icon-width "1" \ | ||
462 | --icon-height "1" | ||
463 | } | ||
464 | |||
465 | niro | 236 | config_sessions() |
466 | { | ||
467 | niro | 272 | local i |
468 | niro | 2149 | local all_ses_ids |
469 | local all_other_ids | ||
470 | niro | 2035 | local CONFIG |
471 | niro | 2149 | local screensaver_passwd_cmd |
472 | niro | 2469 | local fbinit |
473 | local fbkeys | ||
474 | niro | 3503 | local progsh_path |
475 | niro | 236 | |
476 | niro | 3503 | progsh_path="${ALX_UNPRIV_HOME}/.alxprogs" |
477 | |||
478 | niro | 2149 | # get all session ids from database |
479 | all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'") | ||
480 | niro | 2747 | # get all other_menuitem ids from database |
481 | niro | 2149 | all_other_ids=$(mysqldo "select id from cfg_other_menuitems where serial='${ALX_SERIAL}'") |
482 | niro | 2747 | # get all plugin ids from database |
483 | all_plugin_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'") | ||
484 | niro | 2149 | |
485 | # get screensaver settings | ||
486 | evaluate_table cfg_screensaver | ||
487 | # get autostart settings | ||
488 | evaluate_table cfg_autostart | ||
489 | niro | 2435 | # get current color depth |
490 | evaluate_table cfg_graphic | ||
491 | niro | 2149 | |
492 | niro | 236 | # now setup fluxbox for user station |
493 | |||
494 | # create a fresh fluxbox directory | ||
495 | [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox | ||
496 | install -d ${ALX_UNPRIV_HOME}/.fluxbox | ||
497 | |||
498 | # now generate fluxbox config files | ||
499 | |||
500 | # fluxbox main config | ||
501 | niro | 2469 | if [ -f ${ALX_SKELETONS}/fluxbox/init ] |
502 | then | ||
503 | fbinit="${ALX_SKELETONS}/fluxbox/init" | ||
504 | else | ||
505 | fbinit="/usr/share/fluxbox/init" | ||
506 | fi | ||
507 | cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init | ||
508 | niro | 236 | |
509 | # fluxbox autostart | ||
510 | niro | 2411 | CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps" |
511 | niro | 2454 | # do not show decorations on messages generated with xmessage |
512 | if [ -x /usr/bin/xmessage ] | ||
513 | then | ||
514 | addconfig '[app] (xmessage)' | ||
515 | addconfig ' [Deco] {NONE}' | ||
516 | addconfig '[end]' | ||
517 | fi | ||
518 | niro | 2411 | # add icon utility |
519 | niro | 2454 | [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}' |
520 | niro | 2411 | # add numlock utility |
521 | niro | 2454 | [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}' |
522 | niro | 236 | |
523 | niro | 338 | # add screensaver |
524 | niro | 2149 | if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]] |
525 | niro | 338 | then |
526 | niro | 2149 | if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]] |
527 | niro | 338 | then |
528 | niro | 2149 | screensaver_passwd_cmd="-nolock" |
529 | niro | 338 | else |
530 | niro | 2149 | screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})" |
531 | niro | 338 | fi |
532 | |||
533 | niro | 2149 | addconfig "[startup] {nohup xautolock -time ${cfg_screensaver_timeout} -locker 'xlock -mode ${cfg_screensaver_screensaver} ${screensaver_passwd_cmd}' > /dev/null &}" |
534 | niro | 338 | fi |
535 | |||
536 | niro | 3503 | # add plugins autostart |
537 | for i in ${all_plugin_ids} | ||
538 | do | ||
539 | evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" | ||
540 | if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] | ||
541 | then | ||
542 | eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh autostart) | ||
543 | |||
544 | if [[ ${PLUGIN_AUTOSTART} = 1 ]] | ||
545 | then | ||
546 | addconfig "[startup] {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}) &}" | ||
547 | fi | ||
548 | niro | 3504 | # unset all variables |
549 | unset PLUGIN_AUTOSTART | ||
550 | unset PLUGIN_MENUITEM_NAME | ||
551 | niro | 3503 | fi |
552 | done | ||
553 | |||
554 | niro | 246 | # add autostart session |
555 | niro | 2149 | if [[ ! -z ${cfg_autostart_session} ]] |
556 | niro | 246 | then |
557 | niro | 2371 | # sleep one second to wait until busybox is fully initialized and the screen is really centered |
558 | niro | 6765 | addconfig "[startup] {sleep 1 && ${progsh_path}/$(fix_whitespaces ${cfg_autostart_session}) &}" |
559 | niro | 246 | fi |
560 | |||
561 | niro | 236 | # fluxbox hotkeys |
562 | niro | 2469 | if [ -f ${ALX_SKELETONS}/fluxbox/keys ] |
563 | then | ||
564 | fbkeys="${ALX_SKELETONS}/fluxbox/keys" | ||
565 | else | ||
566 | fbkeys="/usr/share/fluxbox/keys" | ||
567 | fi | ||
568 | cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys | ||
569 | niro | 236 | |
570 | niro | 2035 | # generate a fluxbox menu |
571 | niro | 2161 | CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu" |
572 | niro | 2035 | clearconfig |
573 | |||
574 | niro | 236 | # fluxbox menu header |
575 | niro | 2035 | cat ${ALX_SKELETONS}/fluxbox/menu.header >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
576 | niro | 291 | # now fix it with proper messages :P |
577 | local ver="$(< /etc/mageversion)" | ||
578 | niro | 2035 | sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu |
579 | niro | 239 | # add a newline (maybe there is no crlf in the header) |
580 | niro | 2035 | addconfig |
581 | niro | 239 | |
582 | niro | 6765 | # delete all progs |
583 | [ -d ${progsh_path} ] && rm -rf ${progsh_path} | ||
584 | install -d ${progsh_path} | ||
585 | |||
586 | niro | 2149 | # first generate session files |
587 | for i in ${all_ses_ids} | ||
588 | niro | 236 | do |
589 | niro | 2149 | evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" |
590 | |||
591 | niro | 6765 | # generate STOREFRONT/PNABROWSE compatible session |
592 | case "${cfg_sessions_browseradrs}" in | ||
593 | "http://"*|"https://"* ) | ||
594 | # generate STOREFRONT/PNABROWSE compatible session | ||
595 | generate_storefront_sh \ | ||
596 | --session "${cfg_sessions_session}" \ | ||
597 | --filename "$(fix_whitespaces ${cfg_sessions_filename})" \ | ||
598 | --username "${cfg_sessions_username}" \ | ||
599 | --password "${cfg_sessions_password}" \ | ||
600 | --domain "${cfg_sessions_domain}" \ | ||
601 | --server "${cfg_sessions_browseradrs}" | ||
602 | ;; | ||
603 | *) | ||
604 | # generate ICA compatible session | ||
605 | generate_ica_session_file \ | ||
606 | --session "${cfg_sessions_session}" \ | ||
607 | --filename "$(fix_whitespaces ${cfg_sessions_filename})" \ | ||
608 | --username "${cfg_sessions_username}" \ | ||
609 | --password "${cfg_sessions_password}" \ | ||
610 | --domain "${cfg_sessions_domain}" \ | ||
611 | --server "${cfg_sessions_browseradrs}" \ | ||
612 | --colordepth "${cfg_graphic_depth}" | ||
613 | # gen prog startup wrapper | ||
614 | generate_program_sh \ | ||
615 | --name "$(fix_whitespaces ${cfg_sessions_filename})" \ | ||
616 | --exec "wfica-launcher" \ | ||
617 | --param "${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \ | ||
618 | --dest "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \ | ||
619 | "${workdir}" | ||
620 | ;; | ||
621 | esac | ||
622 | |||
623 | niro | 2149 | # fluxbox menusession |
624 | niro | 6765 | addconfig "[exec] (${cfg_sessions_session}) {${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})}" |
625 | niro | 2149 | done |
626 | |||
627 | # add other menuitems | ||
628 | for i in ${all_other_ids} | ||
629 | do | ||
630 | evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" | ||
631 | |||
632 | # now echo config line for fluxbox-menu | ||
633 | # make it "configureable" :p | ||
634 | if [[ -n ${cfg_other_menuitems_workdir} ]] | ||
635 | niro | 2035 | then |
636 | niro | 2149 | workdir="--workdir ${cfg_other_menuitems_workdir}" |
637 | niro | 2035 | fi |
638 | niro | 2149 | if [[ -n ${cfg_other_menuitems_icon} ]] |
639 | then | ||
640 | cfg_other_menuitems_icon="<${cfg_other_menuitems_icon}>" | ||
641 | fi | ||
642 | |||
643 | # gen prog startup wrapper | ||
644 | generate_program_sh \ | ||
645 | --name "${cfg_other_menuitems_name}" \ | ||
646 | --exec "${cfg_other_menuitems_exec}" \ | ||
647 | niro | 2161 | --param "${cfg_other_menuitems_param}" \ |
648 | --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \ | ||
649 | "${workdir}" | ||
650 | niro | 2149 | |
651 | niro | 2161 | addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}" |
652 | niro | 236 | done |
653 | |||
654 | niro | 2747 | # add plugins |
655 | for i in ${all_plugin_ids} | ||
656 | do | ||
657 | evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" | ||
658 | if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] | ||
659 | then | ||
660 | eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem) | ||
661 | |||
662 | # abort if name or exec is empty | ||
663 | [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue | ||
664 | [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue | ||
665 | |||
666 | # now echo config line for fluxbox-menu | ||
667 | # make it "configureable" :p | ||
668 | if [[ -n ${PLUGIN_MENUITEM_WORKDIR} ]] | ||
669 | then | ||
670 | workdir="--workdir ${PLUGIN_MENUITEM_WORKDIR}" | ||
671 | fi | ||
672 | if [[ -n ${PLUGIN_MENUITEM_ICON} ]] | ||
673 | then | ||
674 | PLUGIN_MENUITEM_ICON="<${PLUGIN_MENUITEM_ICON}>" | ||
675 | fi | ||
676 | |||
677 | # gen prog startup wrapper | ||
678 | generate_program_sh \ | ||
679 | --name "${PLUGIN_MENUITEM_NAME}" \ | ||
680 | --exec "${PLUGIN_MENUITEM_EXEC}" \ | ||
681 | niro | 3455 | --param "${PLUGIN_MENUITEM_PARAM}" \ |
682 | niro | 2747 | --dest "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \ |
683 | "${workdir}" | ||
684 | |||
685 | addconfig "[exec] (${PLUGIN_MENUITEM_NAME}) {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})} ${PLUGIN_MENUITEM_ICON}" | ||
686 | fi | ||
687 | |||
688 | # unset all variables | ||
689 | unset PLUGIN_MENUITEM_NAME | ||
690 | unset PLUGIN_MENUITEM_EXEC | ||
691 | unset PLUGIN_MENUITEM_PARAM | ||
692 | unset PLUGIN_MENUITEM_WORKDIR | ||
693 | unset PLUGIN_MENUITEM_ICON | ||
694 | done | ||
695 | |||
696 | niro | 236 | # fluxbox menu footer |
697 | niro | 2035 | cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
698 | niro | 239 | # add a newline (maybe there is no crlf in the footer) |
699 | niro | 2035 | addconfig |
700 | niro | 236 | |
701 | niro | 304 | # now it's a good time to generate *all* icons :) |
702 | niro | 2747 | generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}" "${all_plugin_ids}" |
703 | niro | 236 | |
704 | niro | 2149 | # fix permissions |
705 | niro | 236 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
706 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox | ||
707 | chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox | ||
708 | niro | 2454 | chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop |
709 | niro | 236 | } |