Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *