Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 348 - (hide annotations) (download)
Sun Oct 9 21:38:14 2005 UTC (18 years, 7 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/init.d/alxsettings
File size: 21959 byte(s)
- fixed whitespaces
- using now mysqldo from mysqlfunctions
- fixed broken wireless extensions support
- added support for preliminary confd-networking
- added support mutiple ifaces support
- using better literal tests ( [[ xx ]] construct )
- fixed some bootup and performance issues

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

Properties

Name Value
svn:executable *