Annotation of /alx-src/trunk/tinyalxconfig-ng/init.d/alxsettings
Parent Directory | Revision Log
Revision 499 -
(hide annotations)
(download)
Tue Jun 10 13:15:12 2008 UTC (15 years, 11 months ago) by niro
File size: 17948 byte(s)
Tue Jun 10 13:15:12 2008 UTC (15 years, 11 months ago) by niro
File size: 17948 byte(s)
-reset_system_settings(): delete spooler dirs too
1 | niro | 386 | #!/bin/bash |
2 | |||
3 | # <niro@magellan-linux.de> | ||
4 | |||
5 | niro | 396 | #%rlevels: 7:s 0:k |
6 | niro | 386 | #%start: 41 |
7 | #%stop: 01 | ||
8 | |||
9 | #deps | ||
10 | #%needs: | ||
11 | #%before: | ||
12 | #%after: | ||
13 | |||
14 | niro | 499 | # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/init.d/alxsettings,v 1.18 2008-06-10 13:14:06 niro Exp $ |
15 | niro | 386 | |
16 | # checks first if the client was already configured and if it has an valid serial | ||
17 | # if not it runs the autoconfiguration script | ||
18 | # these settings will be used for client setup | ||
19 | # | ||
20 | # if client was valid it first will check if his settings against the server | ||
21 | # if no changes are at server side they will be kept, if yes the get updated. | ||
22 | # the server settings has higher priority. | ||
23 | |||
24 | source /etc/sysconfig/rc | ||
25 | source $rc_functions | ||
26 | |||
27 | # mysql settings | ||
28 | source /etc/alxconfig-ng/config.rc | ||
29 | |||
30 | # helper functions | ||
31 | source /usr/lib/alxconfig-ng/functions/mysqlfunctions | ||
32 | source /usr/lib/alxconfig-ng/functions/serial_functions | ||
33 | niro | 489 | source /usr/lib/alxconfig-ng/functions/config_driverkits |
34 | niro | 386 | source /usr/lib/alxconfig-ng/functions/config_modules |
35 | source /usr/lib/alxconfig-ng/functions/config_network | ||
36 | source /usr/lib/alxconfig-ng/functions/config_printers | ||
37 | source /usr/lib/alxconfig-ng/functions/config_sessions | ||
38 | source /usr/lib/alxconfig-ng/functions/config_x11 | ||
39 | source /usr/lib/alxconfig-ng/functions/config_auth | ||
40 | source /usr/lib/alxconfig-ng/functions/config_ssh_auth | ||
41 | |||
42 | # other needed vars | ||
43 | ALX_HW_DETECT=false | ||
44 | ALX_FORCED_RECHECK=false | ||
45 | ALX_RESET_SETTINGS=false | ||
46 | |||
47 | # unset vars which may kill us | ||
48 | unset ALX_SERIAL ALX_STATE | ||
49 | |||
50 | |||
51 | # setup needed directories | ||
52 | [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state | ||
53 | |||
54 | |||
55 | # read_cmdline ${item} | ||
56 | read_cmdline() | ||
57 | { | ||
58 | local i | ||
59 | |||
60 | for i in $(< /proc/cmdline) | ||
61 | do | ||
62 | [[ ${i} = $1 ]] && return 0 | ||
63 | done | ||
64 | |||
65 | return 1 | ||
66 | } | ||
67 | |||
68 | update_system_settings() | ||
69 | { | ||
70 | echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} | ||
71 | |||
72 | niro | 489 | # install neccessary driverkits |
73 | config_driverkits | ||
74 | |||
75 | niro | 386 | # get the modules settings |
76 | # ! is the first thing that must be configured ! | ||
77 | config_modules | ||
78 | |||
79 | # imports network settings from db | ||
80 | config_networking | ||
81 | |||
82 | # imports x11 settings from db | ||
83 | config_x11 | ||
84 | |||
85 | # imports session settings from db | ||
86 | config_sessions | ||
87 | |||
88 | # imports printer settings from db | ||
89 | config_printing | ||
90 | |||
91 | # imports auth settings from db | ||
92 | config_auth | ||
93 | |||
94 | # exchange ssh rsa keys | ||
95 | HOME=/root config_ssh_auth | ||
96 | } | ||
97 | |||
98 | get_system_serial() | ||
99 | { | ||
100 | local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE | ||
101 | |||
102 | # check if serial file exists | ||
103 | if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]] | ||
104 | then | ||
105 | source /etc/alxconfig-ng/serial | ||
106 | |||
107 | # start preliminary networking (dhcp) | ||
108 | preliminary_network start | ||
109 | |||
110 | # check if mysql server is reachable | ||
111 | # if not abort this script | ||
112 | if ! reach_mysql_server | ||
113 | then | ||
114 | preliminary_network stop | ||
115 | exit 1 | ||
116 | fi | ||
117 | |||
118 | CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') | ||
119 | CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) | ||
120 | CUR_MTIME=$(date +%s) | ||
121 | |||
122 | echo -e ${COLOREDSTAR} "Trying to validate my serial ..." | ||
123 | |||
124 | # nice serial output | ||
125 | $CURS_UP | ||
126 | $SET_WCOL | ||
127 | echo "[ SN: ${ALX_SERIAL} ]" | ||
128 | |||
129 | if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" | ||
130 | then | ||
131 | ALX_STATE="ok" | ||
132 | else | ||
133 | # abort on non valid serial | ||
134 | ALX_STATE="invalid serial" | ||
135 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state | ||
136 | show_invalid_serial_msg | ||
137 | exit 1 | ||
138 | fi | ||
139 | |||
140 | else | ||
141 | # run hardware detection | ||
142 | echo | ||
143 | if [[ ${ALX_FORCED_RECHECK} = true ]] | ||
144 | then | ||
145 | echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT} | ||
146 | else | ||
147 | echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT} | ||
148 | fi | ||
149 | niro | 391 | # cleaning up old data-crap |
150 | if [ -d /etc/sysconfig/hwsetup ] | ||
151 | then | ||
152 | echo -e ${COLOREDSTAR}"Cleaning up old data ..." | ||
153 | rm -f /etc/sysconfig/hwsetup/* | ||
154 | fi | ||
155 | niro | 397 | ALX_HW_DETECT=true |
156 | niro | 391 | echo -en "${COLOREDSTAR}";hwsetup -p > /dev/null |
157 | niro | 386 | |
158 | # set hostname to alx_default_hostname | ||
159 | # use old hostname if this is a forced re-check | ||
160 | [[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" | ||
161 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
162 | HOSTNAME="${ALX_DEFAULT_HOSTNAME}" | ||
163 | |||
164 | # update the hostname on the system for sure | ||
165 | echo "${HOSTNAME}" > /etc/hostname | ||
166 | |||
167 | # start preliminary networking (dhcp) | ||
168 | preliminary_network start | ||
169 | |||
170 | # check if mysql server is reachable | ||
171 | # if not abort this script | ||
172 | if ! reach_mysql_server | ||
173 | then | ||
174 | preliminary_network stop | ||
175 | exit 1 | ||
176 | fi | ||
177 | |||
178 | CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') | ||
179 | CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) | ||
180 | CUR_MTIME=$(date +%s) | ||
181 | |||
182 | # abort now if this is a forced re-check | ||
183 | if [[ ${ALX_FORCED_RECHECK} = true ]] | ||
184 | then | ||
185 | # but first check the serial | ||
186 | source /etc/alxconfig-ng/serial | ||
187 | |||
188 | echo -e ${COLOREDSTAR} "Trying to validate my serial ..." | ||
189 | |||
190 | # nice serial output | ||
191 | $CURS_UP | ||
192 | $SET_WCOL | ||
193 | echo "[ SN: ${ALX_SERIAL} ]" | ||
194 | |||
195 | if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" | ||
196 | then | ||
197 | ALX_STATE="ok" | ||
198 | else | ||
199 | # abort on non valid serial | ||
200 | ALX_STATE="invalid serial" | ||
201 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state | ||
202 | show_invalid_serial_msg | ||
203 | exit 1 | ||
204 | fi | ||
205 | |||
206 | # write current state to temp file | ||
207 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state | ||
208 | [ -f /hardware-auto-detection ] && rm /hardware-auto-detection | ||
209 | |||
210 | # now export ALX_FORCED_RECHECK=true | ||
211 | # that the setting will be updated not inserted ! | ||
212 | export ALX_FORCED_RECHECK=true | ||
213 | return 0 | ||
214 | fi | ||
215 | |||
216 | echo -e ${COLOREDSTAR} "Trying to get new serial ..." | ||
217 | |||
218 | # request a new serial; one command now (cause must be done in the same session) | ||
219 | ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); | ||
220 | select last_insert_id();") | ||
221 | |||
222 | if [[ ${ALX_SERIAL} != NULL ]] | ||
223 | then | ||
224 | # nice serial output | ||
225 | $CURS_UP | ||
226 | $SET_WCOL | ||
227 | echo "[ SN: ${ALX_SERIAL} ]" | ||
228 | |||
229 | # set ALX_STATE to ok so everybody knows that everything was ok | ||
230 | ALX_STATE=ok | ||
231 | |||
232 | echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial | ||
233 | echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial | ||
234 | |||
235 | evaluate_retval | ||
236 | else | ||
237 | # print false (works only if this is the first statement here) | ||
238 | evaluate_retval | ||
239 | |||
240 | # set ALX_STATE to error so everybody sees there was an error | ||
241 | ALX_STATE=error | ||
242 | |||
243 | # show an error that no new serial was found | ||
244 | # nice serial output | ||
245 | $CURS_UP | ||
246 | $SET_WCOL | ||
247 | echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]" | ||
248 | fi | ||
249 | fi | ||
250 | |||
251 | # write current state to temp file | ||
252 | echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state | ||
253 | echo "ALX_IFACE=${ALX_IFACE}" >> /etc/alxconfig-ng/state/state | ||
254 | } | ||
255 | |||
256 | |||
257 | check_is_configured() | ||
258 | { | ||
259 | if [ -f /etc/alxconfig-ng/state/configured ] | ||
260 | then | ||
261 | export ALX_CONFIGURED=true | ||
262 | else | ||
263 | export ALX_CONFIGURED=false | ||
264 | fi | ||
265 | } | ||
266 | |||
267 | |||
268 | # imports current settings to the database resolved by the hardware detection | ||
269 | import_settings_to_db() | ||
270 | { | ||
271 | # note: networking is always 'dhcp' if hw was autodetected | ||
272 | # note: default_domain/hostname is set in config.rc | ||
273 | |||
274 | # to be safe, we do some sanity checks | ||
275 | niro | 490 | [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain |
276 | [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
277 | niro | 386 | |
278 | # vars used by hwdetect | ||
279 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME | ||
280 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER | ||
281 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE | ||
282 | |||
283 | # get setting from hwdetect | ||
284 | source /etc/sysconfig/hwsetup/knoppix | ||
285 | source /etc/sysconfig/hwsetup/mouse | ||
286 | |||
287 | echo | ||
288 | echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} | ||
289 | |||
290 | # network | ||
291 | niro | 490 | echo " Network settings ..." |
292 | niro | 444 | # global settings |
293 | mysqldo "insert into cfg_network(serial, hostname, domain ) | ||
294 | values('${ALX_SERIAL}', '${ALX_DEFAULT_HOSTNAME}','${ALX_DEFAULT_DOMAIN}');" | ||
295 | niro | 386 | |
296 | niro | 444 | # let udev decide which module should be loaded |
297 | # get all devices from sysfs | ||
298 | local i | ||
299 | local iface | ||
300 | for i in /sys/class/net/eth? | ||
301 | do | ||
302 | iface=$(basename ${i}) | ||
303 | NETCARD_DRIVER=$(source /sys/class/net/${iface}/uevent; echo ${PHYSDEVDRIVER}) | ||
304 | mysqldo "insert into cfg_interfaces( | ||
305 | serial, | ||
306 | iface, | ||
307 | module, | ||
308 | networking | ||
309 | niro | 386 | ) |
310 | values( | ||
311 | '${ALX_SERIAL}', | ||
312 | niro | 444 | '${iface}', |
313 | niro | 386 | '${NETCARD_DRIVER}', |
314 | 'dhcp' | ||
315 | );" | ||
316 | niro | 444 | done |
317 | niro | 386 | evaluate_retval |
318 | |||
319 | # xserver | ||
320 | niro | 490 | echo " Graphic settings ..." |
321 | niro | 386 | # xserver general |
322 | ( mysqldo "insert into cfg_graphic( | ||
323 | serial, | ||
324 | module, | ||
325 | resolution, | ||
326 | depth, | ||
327 | monitorid | ||
328 | ) | ||
329 | values( | ||
330 | '${ALX_SERIAL}', | ||
331 | '${XMODULE}', | ||
332 | '1024x768', | ||
333 | '16', | ||
334 | '0' | ||
335 | );"; ) | ||
336 | evaluate_retval | ||
337 | |||
338 | # input | ||
339 | niro | 490 | echo " Input settings ..." |
340 | niro | 444 | mysqldo "insert into cfg_input(serial,mouse,keyboard) values('${ALX_SERIAL}','${XMOUSETYPE}','kbd');" |
341 | niro | 386 | evaluate_retval |
342 | |||
343 | # auth | ||
344 | niro | 490 | echo " Authentification settings ..." |
345 | niro | 386 | mysqldo "insert into client_auth( |
346 | serial, | ||
347 | username, | ||
348 | shell, | ||
349 | vnc, | ||
350 | samba, | ||
351 | station | ||
352 | ) | ||
353 | values( | ||
354 | '${ALX_SERIAL}', | ||
355 | '${ALX_UNPRIV_USER}', | ||
356 | '', | ||
357 | '', | ||
358 | '', | ||
359 | '' | ||
360 | );" | ||
361 | evaluate_retval | ||
362 | |||
363 | # exchange ssh rsa keys - the first boot needs this ! | ||
364 | # or no reboot will work via the webadmin | ||
365 | niro | 490 | echo " SSH authentification settings ..." |
366 | niro | 386 | HOME=/root config_ssh_auth |
367 | evaluate_retval | ||
368 | |||
369 | # autostart | ||
370 | niro | 490 | echo " Autostart settings ..." |
371 | niro | 386 | mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
372 | |||
373 | # screensaver | ||
374 | niro | 490 | echo " Screensaver settings ..." |
375 | niro | 386 | mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" |
376 | |||
377 | niro | 498 | # theme |
378 | echo " Theme settings ..." | ||
379 | mysqldo "insert into cfg_theme(serial,theme) values('${ALX_SERIAL}','${ALX_DEFAULT_THEME}')" | ||
380 | |||
381 | niro | 386 | evaluate_retval |
382 | } | ||
383 | |||
384 | # imports current settings to the database resolved by the hardware detection | ||
385 | update_settings_in_db() | ||
386 | { | ||
387 | # note: networking is always 'dhcp' if hw was autodetected | ||
388 | # note: default_domain/hostname is set in config.rc or exported | ||
389 | # note: we updating only hardware settings here ! | ||
390 | |||
391 | # to be safe, we do some sanity checks | ||
392 | niro | 490 | [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain |
393 | [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
394 | niro | 386 | |
395 | # vars used by hwdetect | ||
396 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME | ||
397 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER | ||
398 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE | ||
399 | |||
400 | # get setting from hwdetect | ||
401 | source /etc/sysconfig/hwsetup/knoppix | ||
402 | source /etc/sysconfig/hwsetup/mouse | ||
403 | |||
404 | echo | ||
405 | echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT} | ||
406 | |||
407 | # network | ||
408 | niro | 490 | echo " Network settings ..." |
409 | niro | 444 | mysqldo "update cfg_network set |
410 | hostname='${ALX_DEFAULT_HOSTNAME}', | ||
411 | domain='${ALX_DEFAULT_DOMAIN}'; | ||
412 | where serial=${ALX_SERIAL};" | ||
413 | niro | 386 | |
414 | niro | 444 | # let udev decide which module should be loaded |
415 | # get all devices from sysfs | ||
416 | local i | ||
417 | local iface | ||
418 | for i in /sys/class/net/eth? | ||
419 | do | ||
420 | iface=$(basename ${i}) | ||
421 | NETCARD_DRIVER=$(source /sys/class/net/${iface}/uevent; echo ${PHYSDEVDRIVER}) | ||
422 | mysqldo "update cfg_interfaces set | ||
423 | iface='${iface}', | ||
424 | module='${NETCARD_DRIVER}', | ||
425 | networking='${NETWORKING}', | ||
426 | where serial=${ALX_SERIAL};" | ||
427 | niro | 386 | |
428 | # only insert the *FIRST* iface | ||
429 | break | ||
430 | done | ||
431 | evaluate_retval | ||
432 | |||
433 | # xserver | ||
434 | niro | 490 | echo " Graphic settings ..." |
435 | niro | 386 | # xserver general |
436 | mysqldo "update cfg_graphic set | ||
437 | module='${XMODULE}', | ||
438 | resolution='1024x768', | ||
439 | depth='16', | ||
440 | monitorid='0' | ||
441 | where serial=${ALX_SERIAL};" | ||
442 | evaluate_retval | ||
443 | |||
444 | # input | ||
445 | niro | 490 | echo " Input settings ..." |
446 | niro | 444 | mysqldo "update cfg_input set mouse='${XMOUSETYPE}', keyboard='kbd' where serial=${ALX_SERIAL};" |
447 | niro | 386 | evaluate_retval |
448 | } | ||
449 | |||
450 | # imports current settings to the local system resolved by the hardware detection | ||
451 | # we only need the network settings | ||
452 | import_settings_local() | ||
453 | { | ||
454 | # note: networking is always 'dhcp' if hw was autodetected | ||
455 | # note: default_domain/hostname is set in config.rc | ||
456 | |||
457 | # to be safe, we do some sanity checks | ||
458 | niro | 490 | [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain |
459 | [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx | ||
460 | niro | 386 | |
461 | # vars used by hwdetect | ||
462 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME | ||
463 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER | ||
464 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE | ||
465 | |||
466 | # get setting from hwdetect | ||
467 | source /etc/sysconfig/hwsetup/knoppix | ||
468 | |||
469 | echo | ||
470 | echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT} | ||
471 | |||
472 | # set system state to 'already configured' | ||
473 | touch /etc/alxconfig-ng/state/configured | ||
474 | |||
475 | # if only an recheck was forced than abort now | ||
476 | [[ ${ALX_FORCED_RECHECK} = true ]] && return 0 | ||
477 | |||
478 | # create a fresh fluxbox directory | ||
479 | [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox | ||
480 | install -d ${ALX_UNPRIV_HOME}/.fluxbox | ||
481 | |||
482 | # now generate fluxbox config files | ||
483 | |||
484 | niro | 498 | # fluxbox theme |
485 | [[ ! -d /usr/share/fluxbox/styles ]] && install -d /usr/share/fluxbox/styles | ||
486 | cat ${ALX_SKELETONS}/fluxbox/themes/${ALX_DEFAULT_THEME} > /usr/share/fluxbox/styles/default | ||
487 | |||
488 | niro | 386 | # fluxbox main config |
489 | niro | 490 | cat ${ALX_SKELETONS}/fluxbox/init > ${ALX_UNPRIV_HOME}/.fluxbox/init |
490 | niro | 386 | |
491 | # fluxbox autostart | ||
492 | niro | 490 | cat ${ALX_SKELETONS}/fluxbox/apps > ${ALX_UNPRIV_HOME}/.fluxbox/apps |
493 | niro | 386 | |
494 | # fluxbox menu header | ||
495 | niro | 490 | cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu |
496 | niro | 386 | |
497 | # now fix it with proper messages :P | ||
498 | local ver="$(< /etc/mageversion)" | ||
499 | niro | 490 | sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu |
500 | niro | 386 | |
501 | # add a newline (maybe there is no crlf in the header) | ||
502 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
503 | |||
504 | # fluxbox menu footer | ||
505 | niro | 490 | cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
506 | niro | 386 | |
507 | # add a newline (maybe there is no crlf in the footer) | ||
508 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu | ||
509 | |||
510 | # setup some standart icons (sysinfo.lnk) | ||
511 | # basic config | ||
512 | cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc | ||
513 | |||
514 | # clean desktop icon location | ||
515 | [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop | ||
516 | install -d ${ALX_UNPRIV_HOME}/.xtdesktop | ||
517 | |||
518 | # last but not least gen a icon with some sys informations | ||
519 | local sysinfo | ||
520 | local osversion | ||
521 | local xres | ||
522 | local yres | ||
523 | |||
524 | osversion="$(< /etc/mageversion)" | ||
525 | sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" | ||
526 | |||
527 | # at first boot we got always a resolution of 1024x768-16@60 | ||
528 | # middle of the screen | ||
529 | # (no txt - length required, xtdesk manage that itself) | ||
530 | xres="$((1024 / 2))" | ||
531 | # default y pos (full yres -22 !) | ||
532 | yres="$((768 - 22 ))" | ||
533 | |||
534 | generate_icon \ | ||
535 | --name "${sysinfo}" \ | ||
536 | --command "exit 0" \ | ||
537 | --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ | ||
538 | --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \ | ||
539 | --xres "${xres}" \ | ||
540 | --yres "${yres}" \ | ||
541 | --icon-width "1" \ | ||
542 | --icon-height "1" | ||
543 | |||
544 | # create a xinitrc | ||
545 | echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc | ||
546 | |||
547 | # set correct permissions | ||
548 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME} | ||
549 | chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox | ||
550 | chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox | ||
551 | chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop | ||
552 | chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc | ||
553 | chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc | ||
554 | } | ||
555 | |||
556 | # start|stop | ||
557 | preliminary_network() | ||
558 | { | ||
559 | case $1 in | ||
560 | start) | ||
561 | # keeping like always safe: | ||
562 | niro | 388 | # no network should be started here |
563 | ${rc_base}/init.d/network stop | ||
564 | niro | 386 | |
565 | echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT} | ||
566 | # start network configured from /etc/conf.d | ||
567 | niro | 388 | ${rc_base}/init.d/network start |
568 | niro | 386 | ;; |
569 | |||
570 | stop) | ||
571 | echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT} | ||
572 | niro | 388 | ${rc_base}/init.d/network stop |
573 | niro | 386 | ;; |
574 | |||
575 | *) | ||
576 | echo "Usage: preliminary_network {start|stop}" | ||
577 | ;; | ||
578 | esac | ||
579 | } | ||
580 | |||
581 | reset_system_settings() | ||
582 | { | ||
583 | # force load of de kbdkeys | ||
584 | loadkeys -q de | ||
585 | echo | ||
586 | echo -en ${COLRED} | ||
587 | echo -n "*** Warning: you are about to reset *all* local settings on this system!" | ||
588 | echo -e ${COLDEFAULT} | ||
589 | echo "*** Do you really want to continue ?" | ||
590 | echo -n "*** Enter 'yes' to continue, anything else to abort: " | ||
591 | read kbinsert | ||
592 | if [[ ${kbinsert} = yes ]] | ||
593 | then | ||
594 | echo -en ${COLRED} | ||
595 | echo -n "*** OK, you really want it ... killing all settings: " | ||
596 | for i in 3 2 1 now | ||
597 | do | ||
598 | echo -n " ${i}" | ||
599 | sleep 1 | ||
600 | done | ||
601 | echo -e ${COLDEFAULT} | ||
602 | |||
603 | ## reset all settings: | ||
604 | rm -rf ${SETTINGSPATH}/* | ||
605 | rm -f /etc/alxconfig-ng/serial | ||
606 | rm -rf /etc/alxconfig-ng/state | ||
607 | |||
608 | niro | 491 | # clear all printers |
609 | :> /etc/printcap | ||
610 | niro | 499 | find /var/spool/lpd/* -type d | xargs rm -rf &> /dev/null |
611 | niro | 386 | |
612 | # remove all user settings | ||
613 | [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} | ||
614 | |||
615 | # remove all ica-sessions | ||
616 | find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm | ||
617 | |||
618 | # remove all old nics and modules configs | ||
619 | find /etc/conf.d -type f -name 'net.*' | xargs rm | ||
620 | find /etc/modules.d -type f -name 'net.*' | xargs rm | ||
621 | |||
622 | # restore default networking | ||
623 | cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 | ||
624 | |||
625 | echo "I am done now, press [Enter] to reboot system ..." | ||
626 | else | ||
627 | echo "Aborted, press [Enter] to reboot system ..." | ||
628 | fi | ||
629 | read | ||
630 | reboot | ||
631 | } | ||
632 | |||
633 | case $1 in | ||
634 | start) | ||
635 | # check for global overrides | ||
636 | [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true | ||
637 | read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true | ||
638 | read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true | ||
639 | |||
640 | # kill all settings if requested | ||
641 | if [[ ${ALX_RESET_SETTINGS} = true ]] | ||
642 | then | ||
643 | reset_system_settings | ||
644 | fi | ||
645 | |||
646 | # retrieve or validate current serial | ||
647 | get_system_serial | ||
648 | if [[ ${ALX_HW_DETECT} = true ]] | ||
649 | then | ||
650 | if [[ ${ALX_FORCED_RECHECK} = true ]] | ||
651 | then | ||
652 | update_settings_in_db | ||
653 | else | ||
654 | import_settings_to_db | ||
655 | fi | ||
656 | import_settings_local | ||
657 | |||
658 | # here we should also exchange the ssh keys | ||
659 | # or the system cannot be rebooted after | ||
660 | # the first start via the alx-webadmin | ||
661 | config_ssh_auth | ||
662 | fi | ||
663 | |||
664 | # now setup system configuration | ||
665 | # alx_setup_or_whatever_it_will_be_called() | ||
666 | [[ ${ALX_HW_DETECT} = false ]] && update_system_settings | ||
667 | |||
668 | # stop at last the preliminary networking (dhcp) | ||
669 | preliminary_network stop | ||
670 | ;; | ||
671 | |||
672 | stop) | ||
673 | # unset_alx_connected #--> now in alxsetstate-rc6 | ||
674 | # ! important !: del systemstate | ||
675 | [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state | ||
676 | ;; | ||
677 | *) | ||
678 | echo "Usage: $0 {start|stop} ..." | ||
679 | ;; | ||
680 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |