Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *