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