Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (hide annotations) (download)
Thu Sep 22 22:14:38 2005 UTC (18 years, 7 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/init.d/alxsettings
File size: 22458 byte(s)
- added wlan support
- added support for multiple nic-devices for the prelim network
- now supporting cmdline args for hardware detection and settings reset
-

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

Properties

Name Value
svn:executable *