Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *