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