Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *