Contents of /alx-src/tags/alxconf-0_6_4_5/init.d/alxsettings
Parent Directory | Revision Log
Revision 3466 -
(show annotations)
(download)
Fri Apr 13 17:27:25 2012 UTC (12 years, 2 months ago) by niro
Original Path: alx-src/branches/alxconf-060/init.d/alxsettings
File size: 24942 byte(s)
Fri Apr 13 17:27:25 2012 UTC (12 years, 2 months ago) by niro
Original Path: alx-src/branches/alxconf-060/init.d/alxsettings
File size: 24942 byte(s)
-use addconfig everywhere
1 | #!/bin/bash |
2 | # $Id$ |
3 | # <niro@magellan-linux.de> |
4 | |
5 | #%rlevels: 7:s 0:k |
6 | #%start: 41 |
7 | #%stop: 01 |
8 | |
9 | #deps |
10 | #%needs: |
11 | #%before: |
12 | #%after: |
13 | |
14 | # checks first if the client was already configured and if it has an valid serial |
15 | # if not it runs the autoconfiguration script |
16 | # these settings will be used for client setup |
17 | # |
18 | # if client was valid it first will check if his settings against the server |
19 | # if no changes are at server side they will be kept, if yes the get updated. |
20 | # the server settings has higher priority. |
21 | |
22 | source /etc/conf.d/rc |
23 | source $rc_functions |
24 | |
25 | # mysql settings |
26 | source /etc/alxconfig-ng/config.rc |
27 | |
28 | # helper functions |
29 | source ${ALX_FUNCTIONS}/common |
30 | source ${ALX_FUNCTIONS}/mysqlfunctions |
31 | source ${ALX_FUNCTIONS}/serial_functions |
32 | source ${ALX_FUNCTIONS}/config_modules |
33 | source ${ALX_FUNCTIONS}/config_plugins |
34 | source ${ALX_FUNCTIONS}/config_network |
35 | source ${ALX_FUNCTIONS}/config_printers |
36 | source ${ALX_FUNCTIONS}/config_sessions |
37 | source ${ALX_FUNCTIONS}/config_x11 |
38 | source ${ALX_FUNCTIONS}/config_auth |
39 | source ${ALX_FUNCTIONS}/config_ssh_auth |
40 | source ${ALX_FUNCTIONS}/config_versions |
41 | |
42 | # other needed vars |
43 | ALX_HW_DETECT=false |
44 | ALX_FORCED_RECHECK=false |
45 | ALX_RESET_SETTINGS=false |
46 | ALX_CONFD_NETWORKING=false |
47 | |
48 | # unset vars which may kill us |
49 | unset ALX_SERIAL ALX_STATE |
50 | |
51 | |
52 | # setup needed directories |
53 | [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state |
54 | |
55 | update_system_settings() |
56 | { |
57 | rc_mecho Checking system setup ... |
58 | |
59 | # get the modules settings |
60 | # ! is the first thing that must be configured ! |
61 | config_modules |
62 | |
63 | # install or uninstall plugins |
64 | config_plugins |
65 | |
66 | # imports network settings from db |
67 | config_networking |
68 | |
69 | # imports x11 settings from db |
70 | config_x11 |
71 | |
72 | # imports session settings from db |
73 | config_sessions |
74 | |
75 | # imports printer settings from db |
76 | config_printing |
77 | |
78 | # imports auth settings from db |
79 | config_auth |
80 | |
81 | # exchange ssh rsa keys |
82 | HOME=/root config_ssh_auth |
83 | |
84 | # import version info |
85 | config_version |
86 | } |
87 | |
88 | get_system_serial() |
89 | { |
90 | local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE CONFIG |
91 | |
92 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
93 | then |
94 | ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)" |
95 | else |
96 | ALX_IFACE="eth0" |
97 | fi |
98 | |
99 | # check if serial file exists |
100 | if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]] |
101 | then |
102 | source /etc/alxconfig-ng/serial |
103 | |
104 | # start preliminary networking (dhcp) |
105 | preliminary_network start |
106 | |
107 | # check if mysql server is reachable |
108 | # if not abort this script |
109 | if ! reach_mysql_server |
110 | then |
111 | preliminary_network stop |
112 | exit 1 |
113 | fi |
114 | |
115 | CUR_IP=$(ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') |
116 | CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) |
117 | CUR_MTIME=$(date +%s) |
118 | |
119 | rc_print "Trying to validate my serial ..." |
120 | |
121 | # nice serial output |
122 | $CURS_UP |
123 | $SET_WCOL |
124 | echo "[ SN: ${ALX_SERIAL} ]" |
125 | |
126 | if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" |
127 | then |
128 | ALX_STATE="ok" |
129 | else |
130 | # abort on non valid serial |
131 | ALX_STATE="invalid serial" |
132 | CONFIG="/etc/alxconfig-ng/state/state" |
133 | clearconfig |
134 | addconfig "ALX_STATE=\"${ALX_STATE}\"" |
135 | show_invalid_serial_msg |
136 | exit 1 |
137 | fi |
138 | |
139 | else |
140 | # run hardware detection |
141 | echo |
142 | if [[ ${ALX_FORCED_RECHECK} = true ]] |
143 | then |
144 | rc_mecho "Hardware autodetection forced by system-administrator" |
145 | # always disable CONFD_NETWORKING here |
146 | export ALX_CONFD_NETWORKING="false" |
147 | else |
148 | rc_mecho "Preparing system for first boot" |
149 | fi |
150 | ALX_HW_DETECT=true |
151 | hwsetup |
152 | |
153 | # set hostname to alx_default_hostname |
154 | # use old hostname if this is a forced re-check |
155 | [[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)" |
156 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
157 | HOSTNAME="${ALX_DEFAULT_HOSTNAME}" |
158 | |
159 | # update the hostname on the system for sure |
160 | CONFIG="/etc/hostname" |
161 | clearconfig |
162 | addconfig "${HOSTNAME}" |
163 | |
164 | # start preliminary networking (dhcp) |
165 | preliminary_network start |
166 | |
167 | # check if mysql server is reachable |
168 | # if not abort this script |
169 | if ! reach_mysql_server |
170 | then |
171 | preliminary_network stop |
172 | exit 1 |
173 | fi |
174 | |
175 | CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') |
176 | CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) |
177 | CUR_MTIME=$(date +%s) |
178 | |
179 | # abort now if this is a forced re-check |
180 | if [[ ${ALX_FORCED_RECHECK} = true ]] |
181 | then |
182 | # but first check the serial |
183 | source /etc/alxconfig-ng/serial |
184 | |
185 | rc_print "Trying to validate my serial ..." |
186 | |
187 | # nice serial output |
188 | $CURS_UP |
189 | $SET_WCOL |
190 | echo "[ SN: ${ALX_SERIAL} ]" |
191 | |
192 | if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" |
193 | then |
194 | ALX_STATE="ok" |
195 | else |
196 | # abort on non valid serial |
197 | ALX_STATE="invalid serial" |
198 | CONFIG="/etc/alxconfig-ng/state/state" |
199 | clearconfig |
200 | addconfig "ALX_STATE=\"${ALX_STATE}\"" |
201 | show_invalid_serial_msg |
202 | exit 1 |
203 | fi |
204 | |
205 | # write current state to temp file |
206 | CONFIG="/etc/alxconfig-ng/state/state" |
207 | clearconfig |
208 | addconfig "ALX_STATE=\"${ALX_STATE}\"" |
209 | [ -f /hardware-auto-detection ] && rm /hardware-auto-detection |
210 | |
211 | # now export ALX_FORCED_RECHECK=true |
212 | # that the setting will be updated not inserted ! |
213 | export ALX_FORCED_RECHECK=true |
214 | return 0 |
215 | fi |
216 | |
217 | rc_print "Trying to get new serial ..." |
218 | |
219 | # request a new serial; one command now (cause must be done in the same session) |
220 | ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); |
221 | select last_insert_id();") |
222 | |
223 | if [[ ${ALX_SERIAL} != NULL ]] |
224 | then |
225 | # nice serial output |
226 | $CURS_UP |
227 | $SET_WCOL |
228 | echo "[ SN: ${ALX_SERIAL} ]" |
229 | |
230 | # set ALX_STATE to ok so everybody knows that everything was ok |
231 | ALX_STATE=ok |
232 | |
233 | CONFIG="/etc/alxconfig-ng/serial" |
234 | clearconfig |
235 | addconfig "ALX_SERIAL=\"${ALX_SERIAL}\"" |
236 | addconfig "ALX_REG_DATE=\"${CUR_MTIME}\"" |
237 | |
238 | evaluate_retval |
239 | else |
240 | # print false (works only if this is the first statement here) |
241 | evaluate_retval |
242 | |
243 | # set ALX_STATE to error so everybody sees there was an error |
244 | ALX_STATE=error |
245 | |
246 | # show an error that no new serial was found |
247 | # nice serial output |
248 | $CURS_UP |
249 | $SET_WCOL |
250 | echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]" |
251 | fi |
252 | fi |
253 | |
254 | # write current state to temp file |
255 | CONFIG="/etc/alxconfig-ng/state/state" |
256 | clearconfig |
257 | addconfig "ALX_STATE=\"${ALX_STATE}\"" |
258 | addconfig "ALX_IFACE=\"${ALX_IFACE}\"" |
259 | } |
260 | |
261 | |
262 | check_is_configured() |
263 | { |
264 | if [ -f /etc/alxconfig-ng/state/configured ] |
265 | then |
266 | export ALX_CONFIGURED=true |
267 | else |
268 | export ALX_CONFIGURED=false |
269 | fi |
270 | } |
271 | |
272 | |
273 | # imports current settings to the database resolved by the hardware detection |
274 | import_settings_to_db() |
275 | { |
276 | # note: networking is always 'dhcp' if hw was autodetected |
277 | # note: default_domain/hostname is set in config.rc |
278 | |
279 | # to be safe, we do some sanity checks |
280 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
281 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
282 | |
283 | # vars used by hwsetup |
284 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
285 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
286 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
287 | |
288 | # get setting from hwsetup |
289 | source /etc/conf.d/hwsetup/knoppix |
290 | source /etc/conf.d/hwsetup/mouse |
291 | |
292 | echo |
293 | rc_mecho "Importing detected settings to database" |
294 | |
295 | # network |
296 | rc_mecho " Network settings ..." |
297 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
298 | then |
299 | # get settings |
300 | for iface in $(onboot_interface_list ${network_settings}/net.*) |
301 | do |
302 | [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
303 | rc_echo "WARNING: only importing settings for interface [ ${iface} ] !" |
304 | source ${network_settings}/net.${iface} || echo "Error: could not read '${network_settings}/net.${iface}'" |
305 | NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)" |
306 | |
307 | mysqldo "insert into cfg_network( |
308 | hostname, |
309 | serial, |
310 | module, |
311 | domain, |
312 | networking, |
313 | netmask, |
314 | dns, |
315 | gateway, |
316 | broadcast, |
317 | ip, |
318 | forcemacto, |
319 | wireless_bitrate, |
320 | wireless_channel, |
321 | wireless_essid, |
322 | wireless_frequency, |
323 | wireless_mode, |
324 | wireless_nick, |
325 | wireless_auth_mode, |
326 | wireless_key_length, |
327 | wireless_key, |
328 | wireless_key_ascii |
329 | ) |
330 | values( |
331 | '${ALX_DEFAULT_HOSTNAME}', |
332 | '${ALX_SERIAL}', |
333 | '${NETCARD_DRIVER}', |
334 | '${ALX_DEFAULT_DOMAIN}', |
335 | '${NETWORKING}', |
336 | '${NETMASK}', |
337 | '${NAMESERVER}', |
338 | '${GATEWAY}', |
339 | '${BROADCAST}', |
340 | '${IP}', |
341 | '${FORCE_MAC_TO}', |
342 | '${WIRELESS_BITRATE}', |
343 | '${WIRELESS_CHANNEL}', |
344 | '${WIRELESS_ESSID}', |
345 | '${WIRELESS_FREQUENCY}', |
346 | '${WIRELESS_MODE}', |
347 | '${WIRELESS_NICK}', |
348 | '${WIRELESS_AUTH_MODE}', |
349 | '${WIRELESS_KEY_LENGTH}', |
350 | '${WIRELESS_KEY}', |
351 | '${WIRELESS_KEY_ASCII}' |
352 | );" |
353 | |
354 | # only insert the *FIRST* iface |
355 | break |
356 | done |
357 | else |
358 | mysqldo "insert into cfg_network( |
359 | hostname, |
360 | serial, |
361 | module, |
362 | domain, |
363 | networking |
364 | ) |
365 | values( |
366 | '${ALX_DEFAULT_HOSTNAME}', |
367 | '${ALX_SERIAL}', |
368 | '${NETCARD_DRIVER}', |
369 | '${ALX_DEFAULT_DOMAIN}', |
370 | 'dhcp' |
371 | );" |
372 | fi |
373 | evaluate_retval |
374 | |
375 | # xserver |
376 | rc_mecho " Graphic settings ..." |
377 | # xserver general |
378 | ( mysqldo "insert into cfg_graphic( |
379 | serial, |
380 | module, |
381 | resolution, |
382 | depth, |
383 | refresh_rate |
384 | ) |
385 | values( |
386 | '${ALX_SERIAL}', |
387 | '${XMODULE}', |
388 | '1024x768', |
389 | '16', |
390 | '60' |
391 | );"; ) |
392 | evaluate_retval |
393 | |
394 | # input |
395 | rc_mecho " Input settings ..." |
396 | mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" |
397 | evaluate_retval |
398 | |
399 | # auth |
400 | rc_mecho " Authentification settings ..." |
401 | mysqldo "insert into client_auth( |
402 | serial, |
403 | username, |
404 | shell, |
405 | vnc, |
406 | samba, |
407 | station |
408 | ) |
409 | values( |
410 | '${ALX_SERIAL}', |
411 | '${ALX_UNPRIV_USER}', |
412 | '', |
413 | '', |
414 | '', |
415 | '' |
416 | );" |
417 | evaluate_retval |
418 | |
419 | # exchange ssh rsa keys - the first boot needs this ! |
420 | # or no reboot will work via the webadmin |
421 | rc_mecho " SSH authentification settings ..." |
422 | HOME=/root config_ssh_auth |
423 | evaluate_retval |
424 | |
425 | # autostart |
426 | rc_mecho " Autostart settings ..." |
427 | mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" |
428 | |
429 | # screensaver |
430 | rc_mecho " Screensaver settings ..." |
431 | mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')" |
432 | |
433 | # version info |
434 | rc_mecho " OS version info ..." |
435 | local alx_os |
436 | local alx_utils |
437 | alx_os="$(< /etc/mageversion)" |
438 | alx_utils="$(magequery -n alxconfig-ng | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
439 | alx_utils="${alx_utils/alxconfig-ng-}" |
440 | mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')" |
441 | |
442 | evaluate_retval |
443 | } |
444 | |
445 | # imports current settings to the database resolved by the hardware detection |
446 | update_settings_in_db() |
447 | { |
448 | # note: networking is always 'dhcp' if hw was autodetected |
449 | # note: default_domain/hostname is set in config.rc or exported |
450 | # note: we updating only hardware settings here ! |
451 | |
452 | # to be safe, we do some sanity checks |
453 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
454 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
455 | |
456 | # vars used by hwsetup |
457 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
458 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
459 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
460 | |
461 | # get setting from hwsetup |
462 | source /etc/conf.d/hwsetup/knoppix |
463 | source /etc/conf.d/hwsetup/mouse |
464 | |
465 | echo |
466 | rc_mecho "Updating detected settings in database" |
467 | |
468 | # network |
469 | rc_mecho " Network settings ..." |
470 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
471 | then |
472 | # get settings |
473 | #source ${rc_base}/init.d/network &> /dev/null |
474 | for iface in $(onboot_interface_list ${network_settings}/net.*) |
475 | do |
476 | [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue |
477 | rc_echo "WARNING: only importing settings for interface [ ${iface} ] !" |
478 | source ${network_settings}/net.${iface} || exit 1 |
479 | NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)" |
480 | |
481 | mysqldo "update cfg_network set |
482 | hostname='${ALX_DEFAULT_HOSTNAME}', |
483 | module='${NETCARD_DRIVER}', |
484 | domain='${ALX_DEFAULT_DOMAIN}', |
485 | networking='${NETWORKING}', |
486 | netmask='${NETMASK}', |
487 | dns='${NAMESERVER}', |
488 | gateway='${GATEWAY}', |
489 | broadcast='${BROADCAST}', |
490 | ip='${IP}', |
491 | forcemacto='${FORCE_MAC_TO}', |
492 | wireless_bitrate='${WIRELESS_BITRATE}', |
493 | wireless_channel='${WIRELESS_CHANNEL}', |
494 | wireless_essid='${WIRELESS_ESSID}', |
495 | wireless_frequency='${WIRELESS_FREQUENCY}', |
496 | wireless_mode='${WIRELESS_MODE}', |
497 | wireless_nick='${WIRELESS_NICK}', |
498 | wireless_auth_mode='${WIRELESS_AUTH_MODE}', |
499 | wireless_key_length='${WIRELESS_KEY_LENGTH}', |
500 | wireless_key='${WIRELESS_KEY}', |
501 | wireless_key_ascii='${WIRELESS_KEY_ASCII}' |
502 | where serial=${ALX_SERIAL};" |
503 | |
504 | # only insert the *FIRST* iface |
505 | break |
506 | done |
507 | else |
508 | mysqldo "update cfg_network set |
509 | hostname='${ALX_DEFAULT_HOSTNAME}', |
510 | module='${NETCARD_DRIVER}', |
511 | domain='${ALX_DEFAULT_DOMAIN}', |
512 | networking='dhcp' |
513 | where serial=${ALX_SERIAL};" |
514 | fi |
515 | evaluate_retval |
516 | |
517 | # xserver |
518 | rc_mecho " Graphic settings ..." |
519 | # xserver general |
520 | mysqldo "update cfg_graphic set |
521 | module='${XMODULE}', |
522 | resolution='1024x768', |
523 | depth='16', |
524 | refresh_rate='60' |
525 | where serial=${ALX_SERIAL};" |
526 | evaluate_retval |
527 | |
528 | # input |
529 | rc_mecho " Input settings ..." |
530 | mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};" |
531 | evaluate_retval |
532 | |
533 | # version info |
534 | rc_mecho " OS version info ..." |
535 | local alx_os |
536 | local alx_utils |
537 | alx_os="$(< /etc/mageversion)" |
538 | alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')" |
539 | alx_utils="${alx_utils/alxconfig-ng-alx-}" |
540 | mysqldo "update client_version set os='${alx_os}', utils='${alx_utils}' where serial=${ALX_SERIAL};" |
541 | } |
542 | |
543 | # imports current settings to the local system resolved by the hardware detection |
544 | # we only need the network settings |
545 | import_settings_local() |
546 | { |
547 | # note: networking is always 'dhcp' if hw was autodetected |
548 | # note: default_domain/hostname is set in config.rc |
549 | |
550 | # to be safe, we do some sanity checks |
551 | [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain |
552 | [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx |
553 | |
554 | # vars used by hwsetup |
555 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
556 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
557 | local MOUSETYPE XMOUSETYPE FULLNAME DEVICE |
558 | |
559 | # get setting from hwsetup |
560 | source /etc/conf.d/hwsetup/knoppix |
561 | |
562 | echo |
563 | rc_mecho "Importing detected settings to local system" |
564 | |
565 | if [[ ${ALX_CONFD_NETWORKING} = false ]] |
566 | then |
567 | # set an device alias for modprobe.conf |
568 | [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d |
569 | # update only if not the same (to speed up bootprocess - no depmod) |
570 | CONFIG="/etc/modprobe.d/net.${ALX_IFACE}.conf" |
571 | clearconfig |
572 | addconfig "alias ${ALX_IFACE} ${cfg_network_module}" |
573 | |
574 | # update confd-networking default iface |
575 | [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
576 | CONFIG="${SETTINGSPATH}/confd-networking" |
577 | clearconfig |
578 | addconfig "${ALX_IFACE}" |
579 | |
580 | # regenerate modprobe.conf |
581 | [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!" |
582 | evaluate_retval |
583 | fi |
584 | |
585 | # set system state to 'already configured' |
586 | touch /etc/alxconfig-ng/state/configured |
587 | |
588 | # install slim desktopmanager configuration |
589 | config_display_manager |
590 | |
591 | # if only an recheck was forced than abort now |
592 | [[ ${ALX_FORCED_RECHECK} = true ]] && return 0 |
593 | |
594 | # create a fresh fluxbox directory |
595 | [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox |
596 | install -d ${ALX_UNPRIV_HOME}/.fluxbox |
597 | |
598 | # now generate fluxbox config files |
599 | |
600 | # fluxbox main config |
601 | local fbinit |
602 | if [ -f ${ALX_SKELETONS}/fluxbox/init ] |
603 | then |
604 | fbinit="${ALX_SKELETONS}/fluxbox/init" |
605 | else |
606 | fbinit="/usr/share/fluxbox/init" |
607 | fi |
608 | cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init |
609 | |
610 | # fluxbox autostart |
611 | CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps" |
612 | # do not show decorations on messages generated with xmessage |
613 | if [ -x /usr/bin/xmessage ] |
614 | then |
615 | addconfig '[app] (xmessage)' |
616 | addconfig ' [Deco] {NONE}' |
617 | addconfig '[end]' |
618 | fi |
619 | # add icon utility |
620 | [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}' |
621 | # add numlock utility |
622 | [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}' |
623 | |
624 | # fluxbox hotkeys |
625 | local fbkeys |
626 | if [ -f ${ALX_SKELETONS}/fluxbox/keys ] |
627 | then |
628 | fbkeys="${ALX_SKELETONS}/fluxbox/keys" |
629 | else |
630 | fbkeys="/usr/share/fluxbox/keys" |
631 | fi |
632 | cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys |
633 | |
634 | # fluxbox menu header |
635 | cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu |
636 | |
637 | # now fix it with proper messages :P |
638 | local ver="$(< /etc/mageversion)" |
639 | sed -i "s:@CHANGEME@:alx-${ver} #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu |
640 | |
641 | # add a newline (maybe there is no crlf in the header) |
642 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
643 | |
644 | # fluxbox menu footer |
645 | cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
646 | |
647 | # add a newline (maybe there is no crlf in the footer) |
648 | echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu |
649 | |
650 | # setup some standart icons (sysinfo.lnk) |
651 | # clean desktop icon location |
652 | [ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop |
653 | install -d ${ALX_UNPRIV_HOME}/.idesktop |
654 | |
655 | # add shutdown, reboot icons |
656 | local name |
657 | # default settings |
658 | declare -i x=30 |
659 | declare -i y=30 |
660 | for i in shutdown reboot |
661 | do |
662 | case ${i} in |
663 | shutdown) name="Herunterfahren" ;; |
664 | reboot) name="Neustarten" ;; |
665 | esac |
666 | |
667 | generate_icon \ |
668 | --name "${name}" \ |
669 | --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \ |
670 | --icon "${ALX_SESSIONS_ICONS}/${i}.png" \ |
671 | --dest "${dest}/${i}.lnk" \ |
672 | --xres "${x}" \ |
673 | --yres "${y}" |
674 | |
675 | y=$((${y} + 80)) |
676 | done |
677 | |
678 | # last but not least gen a icon with some sys informations |
679 | local sysinfo |
680 | local osversion |
681 | local xres |
682 | local yres |
683 | |
684 | osversion="$(< /etc/mageversion)" |
685 | sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" |
686 | |
687 | # at first boot we got always a resolution of 1024x768-16@60 |
688 | # middle of the screen |
689 | # (no txt - length required, xtdesk manage that itself) |
690 | xres="$((1024 / 2))" |
691 | # default y pos (full yres -22 !) |
692 | yres="$((768 - 22 ))" |
693 | |
694 | generate_icon \ |
695 | --name "${sysinfo}" \ |
696 | --command "exit 0" \ |
697 | --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ |
698 | --dest "${ALX_UNPRIV_HOME}/.idesktop/sysinfo.lnk" \ |
699 | --xres "${xres}" \ |
700 | --yres "${yres}" \ |
701 | --icon-width "1" \ |
702 | --icon-height "1" |
703 | |
704 | # set correct permissions |
705 | 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 | chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop |
709 | if [ -f ${ALX_UNPRIV_HOME}/.ideskrc ] |
710 | then |
711 | chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc |
712 | fi |
713 | } |
714 | |
715 | # start|stop |
716 | preliminary_network() |
717 | { |
718 | local module |
719 | |
720 | if [ -f /etc/alxconfig-ng/state/configured ] |
721 | then |
722 | # compat for old clients |
723 | if [ -f ${SETTINGSPATH}/modules ] |
724 | then |
725 | # get module name |
726 | module=$(cat ${SETTINGSPATH}/modules) |
727 | modprobe ${module} |
728 | fi |
729 | |
730 | else |
731 | # vars used by hwsetup |
732 | local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME |
733 | local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER |
734 | |
735 | # get setting from hwsetup |
736 | source /etc/conf.d/hwsetup/knoppix |
737 | modprobe ${NETCARD_DRIVER} |
738 | fi |
739 | |
740 | case $1 in |
741 | start) |
742 | # keeping like always safe: |
743 | # no network should be startet here, |
744 | # so we can delete all pid files if one exists |
745 | if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]] |
746 | then |
747 | rc_mecho "Forcing network down" |
748 | killall $(basename ${ALX_DHCP_PROG}) &> /dev/null |
749 | sleep 1 |
750 | fi |
751 | [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop |
752 | |
753 | rc_mecho "Starting preliminary networking ... " |
754 | |
755 | # start network configured from /etc/conf.d |
756 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
757 | then |
758 | ${rc_base}/init.d/network start |
759 | else |
760 | rc_print "Starting default dhcp based networking ... " |
761 | ${ALX_DHCP_PROG} ${ALX_DHCP_START} ${ALX_IFACE} &> /dev/null |
762 | evaluate_retval |
763 | fi |
764 | ;; |
765 | |
766 | stop) |
767 | rc_mecho "Stopping preliminary networking ... " |
768 | if [[ ${ALX_CONFD_NETWORKING} = true ]] |
769 | then |
770 | ${rc_base}/init.d/network stop |
771 | else |
772 | rc_print "Stopping default dhcp based networking ... " |
773 | ifconfig ${ALX_IFACE} down |
774 | fi |
775 | if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]] |
776 | then |
777 | killall $(basename ${ALX_DHCP_PROG}) &> /dev/null |
778 | sleep 1 |
779 | fi |
780 | evaluate_retval |
781 | ;; |
782 | |
783 | *) |
784 | echo "Usage: preliminary_network {start|stop}" |
785 | ;; |
786 | esac |
787 | } |
788 | |
789 | reset_system_settings() |
790 | { |
791 | # force load of de kbdkeys |
792 | [ -x /usr/bin/loadkeys ] && loadkeys -q de |
793 | [ -x /sbin/loadkmap ] && loadkmap < /usr/share/busybox/keymaps/de.kmap |
794 | rc_echo |
795 | rc_echo -en "${COLRED}" |
796 | rc_echo -n '--- Warning: you are about to reset *all* local settings on this system!' |
797 | rc_echo -e "${COLDEFAULT}" |
798 | rc_echo '--- Do you really want to continue ?' |
799 | rc_echo -n '--- Enter 'yes' to continue, anything else to abort: ' |
800 | read kbinsert |
801 | if [[ ${kbinsert} = yes ]] |
802 | then |
803 | rc_echo -en "${COLRED}" |
804 | rc_echo -n '--- OK, you really want it ... killing all settings: ' |
805 | for i in 3 2 1 now |
806 | do |
807 | rc_echo -n " ${i}" |
808 | sleep 1 |
809 | done |
810 | rc_echo -e "${COLDEFAULT}" |
811 | |
812 | ## reset all settings: |
813 | rm -rf ${SETTINGSPATH} |
814 | rm -f /etc/alxconfig-ng/serial |
815 | rm -rf /etc/alxconfig-ng/state |
816 | local i |
817 | for i in xserver netcard knoppix mouse |
818 | do |
819 | [[ -f /etc/conf.d/hwsetup/${i} ]] && rm /etc/conf.d/hwsetup/${i} |
820 | done |
821 | |
822 | # clear all printers & net-shares |
823 | :> /etc/printcap |
824 | |
825 | # remove lprng |
826 | rc-config del lprng &> /dev/null |
827 | rc-config del nmbd &> /dev/null |
828 | |
829 | # remove all user settings |
830 | [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME} |
831 | install -o ${ALX_UNPRIV_USER} -g ${ALX_UNPRIV_GROUP} -d ${ALX_UNPRIV_HOME} |
832 | |
833 | # remove all ica-sessions |
834 | find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs --no-run-if-empty rm |
835 | |
836 | # remove all old nics and modules configs |
837 | find /etc/conf.d -type f -name 'net.*' | xargs --no-run-if-empty rm |
838 | find /etc/modprobe.d -type f -name 'net.*' | xargs --no-run-if-empty rm |
839 | |
840 | # restore default networking |
841 | cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0 |
842 | local CONFIG="/etc/hostname" |
843 | clearconfig |
844 | addconfig "${ALX_DEFAULT_HOSTNAME}" |
845 | |
846 | rc_echo -n "I am done now, press [Enter] to reboot system ..." |
847 | else |
848 | rc_echo -n "Aborted, press [Enter] to reboot system ..." |
849 | fi |
850 | read |
851 | sync |
852 | mount -oremount,ro / |
853 | reboot -f |
854 | } |
855 | |
856 | onboot_interface_list() |
857 | { |
858 | local file |
859 | local devices |
860 | local iface |
861 | |
862 | # get list of all devices |
863 | for file in $@ |
864 | do |
865 | if [[ $(read_value ONBOOT ${file}) = yes ]] |
866 | then |
867 | iface="$(basename ${file} | sed s/net.//)" |
868 | # exclude backup files |
869 | case "${iface}" in |
870 | *~) ;; |
871 | *) devices="${devices} $(basename ${file} | sed s/net.//)" ;; |
872 | esac |
873 | fi |
874 | done |
875 | |
876 | echo "${devices}" |
877 | } |
878 | |
879 | # read values from net.* files |
880 | read_value() |
881 | { |
882 | local var="$1" |
883 | local file="$2" |
884 | local value |
885 | |
886 | # local all possible vars |
887 | # global |
888 | local ONBOOT |
889 | local NETWORKING |
890 | |
891 | # static |
892 | local IP |
893 | local NETMASK |
894 | local BROADCAST |
895 | local NETWORKING |
896 | local FORCE_MAC_TO |
897 | |
898 | # dhcp |
899 | local DHCP_PROG |
900 | local DHCP_START |
901 | local DHCP_STOP |
902 | |
903 | # default gw |
904 | local GATEWAY |
905 | local GATEWAY_IF |
906 | |
907 | # wireless extensions |
908 | local WIRELESS_AP |
909 | local WIRELESS_AUTH_MODE |
910 | local WIRELESS_BITRATE |
911 | local WIRELESS_CHANNEL |
912 | local WIRELESS_DEFAULT_KEY |
913 | local WIRELESS_ESSID |
914 | local WIRELESS_FREQUENCY |
915 | local WIRELESS_KEY |
916 | local WIRELESS_KEY_ASCII |
917 | local WIRELESS_KEY_0 |
918 | local WIRELESS_KEY_1 |
919 | local WIRELESS_KEY_2 |
920 | local WIRELESS_KEY_3 |
921 | local WIRELESS_KEY_LENGTH |
922 | local WIRELESS_MODE |
923 | local WIRELESS_NICK |
924 | local WIRELESS_NWID |
925 | local WIRELESS_POWER |
926 | |
927 | source ${file} |
928 | eval value=\$$(echo ${var}) |
929 | echo "${value}" |
930 | } |
931 | |
932 | case $1 in |
933 | start) |
934 | # check for global overrides |
935 | [ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true |
936 | [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true |
937 | read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true |
938 | read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true |
939 | |
940 | # kill all settings if requested |
941 | if [[ ${ALX_RESET_SETTINGS} = true ]] |
942 | then |
943 | reset_system_settings |
944 | fi |
945 | |
946 | # retrieve or validate current serial |
947 | get_system_serial |
948 | if [[ ${ALX_HW_DETECT} = true ]] |
949 | then |
950 | if [[ ${ALX_FORCED_RECHECK} = true ]] |
951 | then |
952 | update_settings_in_db |
953 | else |
954 | import_settings_to_db |
955 | fi |
956 | import_settings_local |
957 | |
958 | # here we should also exchange the ssh keys |
959 | # or the system cannot be rebooted after |
960 | # the first start via the alx-webadmin |
961 | config_ssh_auth |
962 | fi |
963 | |
964 | # now setup system configuration |
965 | # alx_setup_or_whatever_it_will_be_called() |
966 | [[ ${ALX_HW_DETECT} = false ]] && update_system_settings |
967 | |
968 | # stop at last the preliminary networking (dhcp) |
969 | preliminary_network stop |
970 | ;; |
971 | |
972 | stop) |
973 | # unset_alx_connected #--> now in alxsetstate-rc6 |
974 | # ! important !: del systemstate |
975 | [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state |
976 | sleep 0.1 |
977 | ;; |
978 | |
979 | *) |
980 | echo "Usage: $0 {start|stop} ..." |
981 | ;; |
982 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |