Magellan Linux

Contents of /alx-src/branches/alxconf-060/init.d/alxsettings

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *