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