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