1 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.9 2005-08-03 17:56:57 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() |
# helper function to create citrix session files |
5 |
|
generate_ica_session_file() |
6 |
{ |
{ |
7 |
local x i all count |
local i |
8 |
|
local num |
9 |
|
local server |
10 |
|
local ses_session |
11 |
|
local ses_filename |
12 |
|
local ses_username |
13 |
|
local ses_domain |
14 |
|
local ses_password |
15 |
|
local ses_browseradrs |
16 |
|
local CONFIG |
17 |
|
|
18 |
|
# very basic getops |
19 |
|
for i in $* |
20 |
|
do |
21 |
|
case $1 in |
22 |
|
--session) shift; ses_session="$1" ;; |
23 |
|
--filename) shift; ses_filename="$1" ;; |
24 |
|
--username) shift; ses_username="$1" ;; |
25 |
|
--password) shift; ses_password="$1" ;; |
26 |
|
--domain) shift; ses_domain="$1" ;; |
27 |
|
--server) ses_browseradrs="$1" ;; |
28 |
|
esac |
29 |
|
shift |
30 |
|
done |
31 |
|
|
32 |
#all arrays: |
# abort if session, filename or server not given |
33 |
# -> session1 session2 ... sessionN |
[[ -z ${session} ]] && return 1 |
34 |
|
[[ -z ${file} ]] && return 1 |
35 |
|
[[ -z ${server} ]] && return 1 |
36 |
|
|
37 |
|
# write session files |
38 |
|
CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}" |
39 |
|
clearconfig |
40 |
|
|
41 |
#get settings from database |
addconfig '[WFClient]' |
42 |
all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
addconfig 'Version=2' |
|
"select filename from cfg_sessions where serial='${ALX_SERIAL}'") |
|
43 |
|
|
44 |
#split'em up and put in an array (only if $all not zero) |
# use ';' as ifs |
45 |
declare -i i=0 |
declare -i i=0 |
46 |
if [ -n "${all}" ] |
for server in ${ses_browseradrs//;/ } |
47 |
then |
do |
48 |
for x in ${all} |
(( i++ )) |
49 |
do |
num="${i}" |
50 |
ALX_SESSIONS[${i}]=${x} |
# support newer ica-clients: |
51 |
((i++)) |
# the first address must be named TcpBrowserAddress, but not TcpBrowserAddress1 !! |
52 |
done |
[[ ${i} -eq 1 ]] && num="" |
53 |
count=${i} |
addconfig "TcpBrowserAddress${num}=${server}" |
54 |
else |
done |
|
count=0 |
|
|
fi |
|
55 |
|
|
56 |
export ALX_SESSIONS |
addconfig 'ScreenPercent=0' |
57 |
|
addconfig '[ApplicationServers]' |
58 |
|
addconfig "${ses_session}=" |
59 |
|
addconfig "[${ses_session}]" |
60 |
|
addconfig "Address=${ses_session}" |
61 |
|
addconfig "InitialProgram=#${ses_session}" |
62 |
|
addconfig 'TransportDriver=TCP/IP' |
63 |
|
addconfig 'WinStationDriver=ICA 3.0' |
64 |
|
addconfig "ClearPassword=${ses__password}" |
65 |
|
addconfig "Username=${ses_username}" |
66 |
|
addconfig "Domain=${ses_domain}" |
67 |
|
addconfig 'UseFullScreen=Yes' |
68 |
|
addconfig 'NoWindowManager=True' |
69 |
} |
} |
70 |
|
|
71 |
get_autostart_settings() |
# generates a sh file to start programs |
72 |
|
generate_program_sh() |
73 |
{ |
{ |
74 |
#get settings from database |
local dest |
75 |
ALX_AUTOSTART=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
local name |
76 |
"select session from cfg_autostart where serial='${ALX_SERIAL}'") |
local exec |
77 |
|
local workdir |
78 |
|
local CONFIG |
79 |
|
|
80 |
export ALX_AUTOSTART |
# very basic getops |
81 |
|
for i in $* |
82 |
|
do |
83 |
|
case $1 in |
84 |
|
--name|-n) shift; name="$1" ;; |
85 |
|
--exec|-x) shift; exec="$1" ;; |
86 |
|
--dest|-d) shift; dest="$1" ;; |
87 |
|
--workdir|-w) shift; workdir="$1" ;; |
88 |
|
esac |
89 |
|
shift |
90 |
|
done |
91 |
|
|
92 |
|
# abort if name, dest or exec not given |
93 |
|
[[ -z ${name} ]] && return 1 |
94 |
|
[[ -z ${exec} ]] && return 1 |
95 |
|
[[ -z ${dest} ]] && return 1 |
96 |
|
|
97 |
|
CONFIG="${dest}" |
98 |
|
addconfig "#!/bin/sh" |
99 |
|
[ -n "${workdir}" ] && addconfig "cd ${workdir}" |
100 |
|
addconfig "exec ${exec}" |
101 |
|
|
102 |
|
chmod 0755 "${dest}" |
103 |
} |
} |
104 |
|
|
105 |
generate_ica_session_files() |
# helper functions for generate all desktop icons |
106 |
|
generate_icon() |
107 |
{ |
{ |
108 |
local all_ids |
local name |
109 |
local i |
local icon |
110 |
local x |
local command |
111 |
local server |
local dest |
112 |
local ses_session |
local yres |
113 |
local ses_filename |
local xres |
114 |
local ses_username |
local iwidth |
115 |
local ses_domain |
local iheight |
116 |
local ses_password |
local deficon |
117 |
local ses_browseradrs |
local CONFIG |
|
local ses_colors |
|
|
|
|
|
#get settings from database |
|
|
all_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select id from cfg_sessions where serial='${ALX_SERIAL}'") |
|
118 |
|
|
119 |
for i in ${all_ids} |
# very basic getops |
120 |
|
for i in $* |
121 |
do |
do |
122 |
# get settings |
case $1 in |
123 |
ses_session=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
--name|-n) shift; name="$1" ;; |
124 |
"select session from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'") |
--command|-c) shift; command="$1" ;; |
125 |
|
--icon|-i) shift; icon="$1" ;; |
126 |
ses_filename=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
--dest|-d) shift; dest="$1" ;; |
127 |
"select filename from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'") |
--xres|-x) shift; xres="$1" ;; |
128 |
|
--yres|-y) shift; yres="$1" ;; |
129 |
ses_username=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
--icon-width|-w) shift; iwidth="$1" ;; |
130 |
"select username from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'") |
--icon-height|-h) shift; iheight="$1" ;; |
131 |
|
--default-icon) shift; deficon="$1" ;; |
132 |
ses_domain=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
esac |
133 |
"select domain from cfg_sessions where serial='${ALX_SERIAL}' and id='${i}'") |
shift |
|
|
|
|
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}'") |
|
|
|
|
|
# get the right colors |
|
|
ses_colors=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select depth from cfg_graphic where serial='${ALX_SERIAL}'") |
|
|
case ${ses_colors} in |
|
|
24) ses_colors="8";; |
|
|
16) ses_colors="4";; |
|
|
8) ses_colors="2";; |
|
|
*) ses_colors="2";; |
|
|
esac |
|
|
|
|
|
# write session files |
|
|
echo '[WFClient]' > ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo 'Version=2' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
OLD_IFS="$IFS" |
|
|
IFS=";" |
|
|
declare -i x=0 |
|
|
for server in ${ses_browseradrs} |
|
|
do |
|
|
(( x++ )) |
|
|
echo "TcpBrowserAddress${x}=${server}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
done |
|
|
IFS="${OLD_IFS}" |
|
|
unset x |
|
|
unset OLD_IFS |
|
|
|
|
|
echo 'ScreenPercent=0' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
|
|
|
echo '[ApplicationServers]' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo "${ses_session}=" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
|
|
|
echo "[${ses_session}]" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo "Address=${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo "InitialProgram=#${ses_session}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo "DesiredColor=${ses_colors}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo 'TransportDriver=TCP/IP' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo 'WinStationDriver=ICA 3.0' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo "ClearPassword=${ses_password}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo "Username=${ses_username}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo "Domain=${ses_domain}" >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo 'UseFullScreen=Yes' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
|
echo 'NoWindowManager=True' >> ${ALX_ICA_SESSIONS}/${ses_filename} |
|
134 |
done |
done |
|
} |
|
135 |
|
|
136 |
get_other_menuitems() |
# some sanity checks: |
|
{ |
|
|
local x i count name exec icon workdir |
|
137 |
|
|
138 |
#all arrays: |
# abort if name or command not given |
139 |
# -> session1 session2 ... sessionN |
[[ -z ${name} ]] && return 1 |
140 |
|
[[ -z ${command} ]] && return 1 |
141 |
|
|
142 |
|
# use some defaults for icon, dest, {x,y}res |
143 |
|
[[ -z ${xres} ]] && xres=30 |
144 |
|
[[ -z ${yres} ]] && xres=30 |
145 |
|
[[ -z ${dest} ]] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" |
146 |
|
if [[ -z ${icon} ]] || [ ! -f ${icon} ] |
147 |
|
then |
148 |
|
# if no default icon is given use default.png |
149 |
|
[[ -z ${deficon} ]] && deficon="default.png" |
150 |
|
icon="${ALX_SESSIONS_ICONS}/${deficon}" |
151 |
|
fi |
152 |
|
|
153 |
|
CONFIG=${dest} |
154 |
|
clearconfig |
155 |
|
|
156 |
#get settings from database |
addconfig 'table Icon' |
157 |
count=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
addconfig ' Type: Program' |
158 |
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}'") |
addconfig " Caption: ${name}" |
159 |
|
addconfig " Command: ${command}" |
160 |
|
addconfig " Icon: ${icon}" |
161 |
|
addconfig " X: ${xres}" |
162 |
|
addconfig " Y: ${yres}" |
163 |
|
|
164 |
# get all instances and put them into an array |
# add these only if not zero |
165 |
if [ -n "${count}" ] |
if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]] |
166 |
then |
then |
167 |
for x in ${count} |
addconfig " IconWidth: ${iwidth}" |
168 |
do |
addconfig " IconHeight: ${iheight}" |
|
# to be sure |
|
|
unset name |
|
|
unset exec |
|
|
unset workdir |
|
|
unset icon |
|
|
|
|
|
name=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
workdir=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
icon=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
# debug only |
|
|
#echo "DEBUG: ${x}: name:'${name}' exec:'${exec}' workdir:'${workdir}' ic$ |
|
|
|
|
|
# now echo config line for fluxbox-menu |
|
|
# make it "configureable" :P |
|
|
[ -n "${workdir}" ] && workdir="cd ${workdir};" |
|
|
[ -n "${icon}" ] && icon="[${icon}]" |
|
|
echo "[exec] (${name}) {${workdir}${exec}} ${icon}" |
|
|
done |
|
169 |
fi |
fi |
170 |
|
|
171 |
|
addconfig 'end' |
172 |
} |
} |
173 |
|
|
174 |
config_sessions() |
generate_all_desktop_icons() |
175 |
{ |
{ |
176 |
# generate ica session files |
local session_list="$1" |
177 |
generate_ica_session_files |
local other_menuitem_list="$2" |
178 |
|
local res |
179 |
|
local xres |
180 |
|
local yres |
181 |
|
local x |
182 |
|
local y |
183 |
|
local item |
184 |
|
local name |
185 |
|
local progsh_path |
186 |
|
|
187 |
#first of all get the vars |
# progsh path |
188 |
get_sessions_settings |
progsh_path=${ALX_UNPRIV_HOME}/.alxprogs |
|
get_autostart_settings |
|
189 |
|
|
190 |
local count=${#ALX_SESSIONS[*]} |
# get the resolution |
191 |
local icon |
res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'") |
192 |
local i |
|
193 |
|
# split res to x & y |
194 |
|
xres="${res%x*}" |
195 |
|
xres="${res#*x}" |
196 |
|
|
197 |
|
# top left edge of the icon is given in config file |
198 |
|
# remove a little bit to simulate the bottom-right edge |
199 |
|
xres="$(( ${xres} - 120 ))" |
200 |
|
yres="$(( ${yres} - 80 ))" |
201 |
|
|
202 |
|
# basic config |
203 |
|
cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc |
204 |
|
|
205 |
|
# clean desktop icon location |
206 |
|
[ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop |
207 |
|
install -d ${ALX_UNPRIV_HOME}/.xtdesktop |
208 |
|
|
209 |
# DEBUG |
# default settings |
210 |
# declare -i i=0 |
declare -i x=30 |
211 |
# echo count=${count} |
declare -i y=30 |
212 |
# echo "Number of new sessions: ${count}" |
|
213 |
# for ((i=0; i < count; i++)) |
# ica icons |
214 |
# do |
for item in ${session_list} |
215 |
# echo "${i} - ${ALX_SESSIONS[${i}]}" |
do |
216 |
# done |
# abort if empty |
217 |
|
[[ -z ${item} ]] && continue |
218 |
|
|
219 |
|
# new line if x > xres |
220 |
|
if [ ${x} -ge ${xres} ] |
221 |
|
then |
222 |
|
x=30 |
223 |
|
y=$((${y} + 80)) |
224 |
|
fi |
225 |
|
|
226 |
|
# new row if y > yres |
227 |
|
if [ ${y} -ge ${yres} ] |
228 |
|
then |
229 |
|
x=$((${x} + 120)) |
230 |
|
y=30 |
231 |
|
|
232 |
|
# re-check x |
233 |
|
[ ${x} -ge ${xres} ] && x=30 |
234 |
|
fi |
235 |
|
|
236 |
|
name="$(basename ${item} .ica)" |
237 |
|
generate_icon \ |
238 |
|
--name "${name}" \ |
239 |
|
--command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \ |
240 |
|
--icon "${ALX_SESSIONS_ICONS}/${name}.png" \ |
241 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" \ |
242 |
|
--xres "${x}" \ |
243 |
|
--yres "${y}" |
244 |
|
|
245 |
|
y=$((${y} + 80)) |
246 |
|
done |
247 |
|
|
248 |
|
for item in ${other_menuitem_list} |
249 |
|
do |
250 |
|
# abort if empty |
251 |
|
[[ -z ${item} ]] && continue |
252 |
|
|
253 |
|
# new line if x > xres |
254 |
|
if [ ${x} -ge ${xres} ] |
255 |
|
then |
256 |
|
x=30 |
257 |
|
y=$((${y} + 80)) |
258 |
|
fi |
259 |
|
|
260 |
|
# new row if y > yres |
261 |
|
if [ ${y} -ge ${yres} ] |
262 |
|
then |
263 |
|
x=$((${x} + 120)) |
264 |
|
y=30 |
265 |
|
|
266 |
|
# re-check x |
267 |
|
[ ${x} -ge ${xres} ] && x=30 |
268 |
|
fi |
269 |
|
|
270 |
|
generate_icon \ |
271 |
|
--name "${item}" \ |
272 |
|
--command "${progsh_path}/${item}" \ |
273 |
|
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
274 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
275 |
|
--xres "${x}" \ |
276 |
|
--yres "${y}" \ |
277 |
|
--default-icon "default_item.png" |
278 |
|
|
279 |
|
y=$((${y} + 80)) |
280 |
|
done |
281 |
|
|
282 |
|
# last but not least gen a icon with some sys informations |
283 |
|
local sysinfo |
284 |
|
local hostname |
285 |
|
local osversion |
286 |
|
|
287 |
|
osversion="$(< /etc/mageversion)" |
288 |
|
hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'") |
289 |
|
sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
290 |
|
|
291 |
|
# now get the right position: |
292 |
|
# restore orig values of xres |
293 |
|
xres="$(( ${xres} + 120 ))" |
294 |
|
# default y pos (full yres -22 = cur yres + 58 !) |
295 |
|
yres="$(( ${yres} + 58 ))" |
296 |
|
# middle of the screen |
297 |
|
# (no txt - length required, xtdesk manage that itself) |
298 |
|
xres="$(( ${xres} / 2))" |
299 |
|
|
300 |
|
generate_icon \ |
301 |
|
--name "${sysinfo}" \ |
302 |
|
--command "exit 0" \ |
303 |
|
--icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
304 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ |
305 |
|
--xres "${xres}" \ |
306 |
|
--yres "${yres}" \ |
307 |
|
--icon-width "1" \ |
308 |
|
--icon-height "1" |
309 |
|
} |
310 |
|
|
311 |
|
config_sessions() |
312 |
|
{ |
313 |
|
local i |
314 |
|
local all_ses_ids |
315 |
|
local all_other_ids |
316 |
|
local CONFIG |
317 |
|
local screensaver_passwd_cmd |
318 |
|
local all_sessions |
319 |
|
local all_other_menuitems |
320 |
|
|
321 |
|
# get all session ids from database |
322 |
|
all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'") |
323 |
|
# get all other_menutiem ids from database |
324 |
|
all_other_ids=$(mysqldo "select id from cfg_other_menuitems where serial='${ALX_SERIAL}'") |
325 |
|
|
326 |
|
# get screensaver settings |
327 |
|
evaluate_table cfg_screensaver |
328 |
|
# get autostart settings |
329 |
|
evaluate_table cfg_autostart |
330 |
|
|
331 |
# now setup fluxbox for user station |
# now setup fluxbox for user station |
332 |
|
|
337 |
# now generate fluxbox config files |
# now generate fluxbox config files |
338 |
|
|
339 |
# fluxbox main config |
# fluxbox main config |
340 |
cat ${ALX_SKELETONS}/fluxbox/init \ |
cat ${ALX_SKELETONS}/fluxbox/init > ${ALX_UNPRIV_HOME}/.fluxbox/init |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/init |
|
341 |
|
|
342 |
# fluxbox autostart |
# fluxbox autostart |
343 |
cat ${ALX_SKELETONS}/fluxbox/apps \ |
cat ${ALX_SKELETONS}/fluxbox/apps > ${ALX_UNPRIV_HOME}/.fluxbox/apps |
344 |
> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
|
345 |
|
CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps" |
346 |
|
# add screensaver |
347 |
|
if [[ ! -z ${cfg_screensaver_screensaver} ]] && [[ ! -z ${cfg_screensaver_screensaver_timeout} ]] |
348 |
|
then |
349 |
|
if [[ -z ${cfg_screensaver_password} ]] || [[ ${cfg_screensaver_password} = NULL ]] |
350 |
|
then |
351 |
|
screensaver_passwd_cmd="-nolock" |
352 |
|
else |
353 |
|
screensaver_passwd_cmd="-cpasswd $(cryptpw -m des ${cfg_screensaver_password})" |
354 |
|
fi |
355 |
|
|
356 |
|
addconfig "[startup] {nohup xautolock -time ${cfg_screensaver_timeout} -locker 'xlock -mode ${cfg_screensaver_screensaver} ${screensaver_passwd_cmd}' > /dev/null &}" |
357 |
|
fi |
358 |
|
|
359 |
# add autostart session |
# add autostart session |
360 |
if [[ ${ALX_AUTOSTART} != "" ]] |
if [[ ! -z ${cfg_autostart_session} ]] |
361 |
then |
then |
362 |
echo "[startup] {wfica ${ALX_ICA_SESSIONS}/${ALX_AUTOSTART}}" \ |
addconfig "[startup] {nohup nice -n 19 wfica ${ALX_ICA_SESSIONS}/${cfg_autostart_session} &}" |
|
>> ${ALX_UNPRIV_HOME}/.fluxbox/apps |
|
363 |
fi |
fi |
364 |
|
|
365 |
# fluxbox hotkeys |
# fluxbox hotkeys |
366 |
cat ${ALX_SKELETONS}/fluxbox/apps \ |
cat ${ALX_SKELETONS}/fluxbox/keys > ${ALX_UNPRIV_HOME}/.fluxbox/keys |
|
> ${ALX_UNPRIV_HOME}/.fluxbox/keys |
|
367 |
|
|
368 |
# fluxbox menu header |
# generate a fluxbox menu |
369 |
cat ${ALX_SKELETONS}/fluxbox/menu.header \ |
CONFIG=${ALX_UNPRIV_HOME}/.fluxbox/menu |
370 |
> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
clearconfig |
371 |
|
|
372 |
|
# fluxbox menu header |
373 |
|
cat ${ALX_SKELETONS}/fluxbox/menu.header >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
374 |
|
# now fix it with proper messages :P |
375 |
|
local ver="$(< /etc/mageversion)" |
376 |
|
sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu |
377 |
# add a newline (maybe there is no crlf in the header) |
# add a newline (maybe there is no crlf in the header) |
378 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
addconfig |
379 |
|
|
380 |
# fluxbox menu sessions |
# first generate session files |
381 |
for (( i=0; i < count; i++ )) |
for i in ${all_ses_ids} |
382 |
do |
do |
383 |
[ -n "${ALX_SESSIONS[${i}]}" ] && \ |
evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" |
384 |
echo "[exec] ($(basename ${ALX_SESSIONS[${i}]} .ica)) {wfica ${ALX_ICA_SESSIONS}/${ALX_SESSIONS[${i}]}}" \ |
generate_ica_session_file \ |
385 |
>> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
--session "${cfg_sessions_session}" \ |
386 |
done |
--filename "${cfg_sessions_filename}" \ |
387 |
|
--username "${cfg_sessions_username}" \ |
388 |
# add other menuitems |
--password "${cfg_sessions_password}" \ |
389 |
get_other_menuitems >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
--domain "${cfg_sessions_domain}" \ |
390 |
|
--server "${cfg_sessions_browseradrs}" |
391 |
|
|
392 |
# fluxbox menu footer |
# fluxbox menusession |
393 |
cat ${ALX_SKELETONS}/fluxbox/menu.footer \ |
addconfig "[exec] (${cfg_sessions_session}) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${cfg_sessions_filename}}" |
|
>> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
|
394 |
|
|
395 |
# add a newline (maybe there is no crlf in the footer) |
# add to all_sessions variable to create icons later for these |
396 |
echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
all_sessions="${all_sessions} ${cfg_sessions_filename}" |
397 |
|
done |
398 |
|
|
399 |
# now we generate the desktop icons |
# delete all progs |
400 |
cat ${ALX_SKELETONS}/idesk/ideskrc \ |
progsh_path="${ALX_UNPRIV_HOME}/.alxprogs" |
401 |
> ${ALX_UNPRIV_HOME}/.ideskrc |
[ -d ${progsh_path} ] && rm -rf ${progsh_path} |
402 |
|
install -d ${progsh_path} |
|
# 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 |
|
403 |
|
|
404 |
local name |
# add other menuitems |
405 |
for (( i=0; i < count; i++ )) |
for i in ${all_other_ids} |
406 |
do |
do |
407 |
name="$(basename ${ALX_SESSIONS[${i}]} .ica)" |
evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" |
408 |
|
|
409 |
if [ -f ${ALX_SESSIONS_ICONS}/${name}.png ] |
# now echo config line for fluxbox-menu |
410 |
|
# make it "configureable" :p |
411 |
|
if [[ -n ${cfg_other_menuitems_workdir} ]] |
412 |
then |
then |
413 |
icon="${ALX_SESSIONS_ICONS}/${name}.png" |
workdir="--workdir ${cfg_other_menuitems_workdir}" |
|
else |
|
|
icon="${ALX_SESSIONS_ICONS}/default.png" |
|
414 |
fi |
fi |
415 |
|
if [[ -n ${cfg_other_menuitems_icon} ]] |
416 |
|
then |
417 |
|
cfg_other_menuitems_icon="<${cfg_other_menuitems_icon}>" |
418 |
|
fi |
419 |
|
|
420 |
|
# gen prog startup wrapper |
421 |
|
generate_program_sh \ |
422 |
|
--name "${cfg_other_menuitems_name}" \ |
423 |
|
--exec "${cfg_other_menuitems_exec}" \ |
424 |
|
--dest "${progsh_path}/${cfg_other_menuitems_name}" \ |
425 |
|
"${cfg_other_menuitems_workdir}" |
426 |
|
|
427 |
|
addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/${cfg_other_menuitems_name}} ${cfg_other_menuitems_icon}" |
428 |
|
|
429 |
echo "table Icon |
# add to all_other_menuitems variable to create icons later for these |
430 |
Caption: ${name} |
all_other_menuitems="${all_other_menuitems} ${cfg_other_menuitems_name}" |
|
Command: wfica ${ALX_ICA_SESSIONS}/${name}.ica |
|
|
Icon: ${icon} |
|
|
end" > ${ALX_UNPRIV_HOME}/.idesktop/${name}.lnk |
|
431 |
done |
done |
432 |
|
|
433 |
# set correct permissions |
# fluxbox menu footer |
434 |
|
cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
435 |
|
# add a newline (maybe there is no crlf in the footer) |
436 |
|
addconfig |
437 |
|
|
438 |
|
# now it's a good time to generate *all* icons :) |
439 |
|
generate_all_desktop_icons "${all_sessions}" "${all_other_menuitems}" |
440 |
|
|
441 |
|
# fix permissions |
442 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} |
443 |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox |
444 |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox |
445 |
chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop |
chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop |
446 |
chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc |
chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc |
|
|
|
|
|
|
|
# unset vars |
|
|
unset ALX_SESSIONS |
|
447 |
} |
} |