Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

alx-src/trunk/alxconfig-ng/init.d/alxsettings revision 313 by niro, Wed Aug 31 21:31:09 2005 UTC alx-src/branches/alxconf-060/init.d/alxsettings revision 1800 by niro, Thu Apr 14 19:29:35 2011 UTC
# Line 11  Line 11 
11  #%before:  #%before:
12  #%after:  #%after:
13    
14  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.19 2005-08-31 21:31:09 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.27 2005-10-11 12:10:15 niro Exp $
15    
16  # checks first if the client was already configured and if it has an valid serial  # checks first if the client was already configured and if it has an valid serial
17  # if not it runs the autoconfiguration script  # if not it runs the autoconfiguration script
# Line 37  source /usr/lib/alxconfig-ng/functions/c Line 37  source /usr/lib/alxconfig-ng/functions/c
37  source /usr/lib/alxconfig-ng/functions/config_x11  source /usr/lib/alxconfig-ng/functions/config_x11
38  source /usr/lib/alxconfig-ng/functions/config_auth  source /usr/lib/alxconfig-ng/functions/config_auth
39  source /usr/lib/alxconfig-ng/functions/config_ssh_auth  source /usr/lib/alxconfig-ng/functions/config_ssh_auth
40    source /usr/lib/alxconfig-ng/functions/config_versions
41    
42  # check if mysql is available  # check if mysql is available
43  [ -x /usr/bin/mysql ] && MYSQL_ALX=true  [ -x /usr/bin/mysql ] && MYSQL_ALX=true
# Line 44  source /usr/lib/alxconfig-ng/functions/c Line 45  source /usr/lib/alxconfig-ng/functions/c
45  # other needed vars  # other needed vars
46  ALX_HW_DETECT=false  ALX_HW_DETECT=false
47  ALX_FORCED_RECHECK=false  ALX_FORCED_RECHECK=false
48    ALX_RESET_SETTINGS=false
49    ALX_CONFD_NETWORKING=false
50    
51  # unset vars which may kill us  # unset vars which may kill us
52  unset ALX_SERIAL ALX_STATE  unset ALX_SERIAL ALX_STATE
# Line 53  unset ALX_SERIAL ALX_STATE Line 56  unset ALX_SERIAL ALX_STATE
56  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state
57    
58    
59  update_system_settings(){  # read_cmdline ${item}
60    read_cmdline()
61    {
62     local i
63    
64     for i in $(< /proc/cmdline)
65     do
66     [[ ${i} = $1 ]] && return 0
67     done
68    
69     return 1
70    }
71    
72    update_system_settings()
73    {
74   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}
75    
76   # get the modules settings   # get the modules settings
# Line 77  update_system_settings(){ Line 94  update_system_settings(){
94    
95   # exchange ssh rsa keys   # exchange ssh rsa keys
96   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
97    
98     # import version info
99     config_version
100  }  }
101    
102  get_system_serial(){  get_system_serial()
103    {
104     local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE
105    
106   local CUR_IP CUR_MAC CUR_MTIME   if [[ ${ALX_CONFD_NETWORKING} = true ]]
107     then
108     ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)"
109     else
110     ALX_IFACE="eth0"
111     fi
112    
113   # check if serial file exists   # check if serial file exists
114   if [ -f /etc/alxconfig-ng/serial ] && [ ! -f /hardware-auto-detection ]   if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]
115   then   then
116   source /etc/alxconfig-ng/serial   source /etc/alxconfig-ng/serial
117    
# Line 99  get_system_serial(){ Line 126  get_system_serial(){
126   exit 1   exit 1
127   fi   fi
128    
129   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
130   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
131   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
132    
133   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."
# Line 116  get_system_serial(){ Line 143  get_system_serial(){
143   else   else
144   # abort on non valid serial   # abort on non valid serial
145   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
146   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
147   show_invalid_serial_msg   show_invalid_serial_msg
148   exit 1   exit 1
149   fi   fi
# Line 124  get_system_serial(){ Line 151  get_system_serial(){
151   else   else
152   # run hardware detection   # run hardware detection
153   echo   echo
154   if [ -f /hardware-auto-detection ]   if [[ ${ALX_FORCED_RECHECK} = true ]]
155   then   then
156   echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT}   echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT}
157     # always disable CONFD_NETWORKING here
158     export ALX_CONFD_NETWORKING="false"
159   else   else
160   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}
161   fi   fi
# Line 135  get_system_serial(){ Line 164  get_system_serial(){
164    
165   # set hostname to alx_default_hostname   # set hostname to alx_default_hostname
166   # use old hostname if this is a forced re-check   # use old hostname if this is a forced re-check
167   [ -f /hardware-auto-detection ] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)"   [[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)"
168   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
169   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"
170    
# Line 158  get_system_serial(){ Line 187  get_system_serial(){
187   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
188    
189   # abort now if this is a forced re-check   # abort now if this is a forced re-check
190   if [ -f /hardware-auto-detection ]   if [[ ${ALX_FORCED_RECHECK} = true ]]
191   then   then
192   # but first check the serial   # but first check the serial
193   source /etc/alxconfig-ng/serial   source /etc/alxconfig-ng/serial
# Line 182  get_system_serial(){ Line 211  get_system_serial(){
211   fi   fi
212    
213   # write current state to temp file   # write current state to temp file
214   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
215   rm /hardware-auto-detection   [ -f /hardware-auto-detection ] && rm /hardware-auto-detection
216    
217   # now export ALX_FORCED_RECHECK=true   # now export ALX_FORCED_RECHECK=true
218   # that the setting will be updated not inserted !   # that the setting will be updated not inserted !
# Line 193  get_system_serial(){ Line 222  get_system_serial(){
222    
223   echo -e ${COLOREDSTAR} "Trying to get new serial ..."   echo -e ${COLOREDSTAR} "Trying to get new serial ..."
224    
  # request new serial  
  # ALX_REG_DATE="$(date +%F)"  
   
  # we're using the mtime now (better for validating the serial)  
 # mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "insert into client_serials(  
 # mtime,  
 # mac  
 # )  
 # values(  
 # '${CUR_MTIME}',  
 # '${CUR_MAC}'  
 # );"  
 #  
 # # then validate and retrieve serial  
 #  
 # ### warning must be changed that only the LAST ID will be fetched,  ###  
 # ### or you get error if the computer name and date are the same     ###  
 # ### you have more than one serial number then                       ###  
 #  
 # # select highest id only (added max)  
 # ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'")  
   
225   # request a new serial; one command now (cause must be done in the same session)   # request a new serial; one command now (cause must be done in the same session)
226   ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');
227   "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');   select last_insert_id();")
  select last_insert_id() + 1;")  
228    
229   if [ "${ALX_SERIAL}" != NULL ]   if [[ ${ALX_SERIAL} != NULL ]]
230   then   then
231   # nice serial output   # nice serial output
232   $CURS_UP   $CURS_UP
233   $SET_WCOL   $SET_WCOL
234   echo "[ SN: ${ALX_SERIAL} ]"   echo "[ SN: ${ALX_SERIAL} ]"
235    
236   # set ALX_STATE to ok so everybody that everything was ok   # set ALX_STATE to ok so everybody knows that everything was ok
237   ALX_STATE=ok   ALX_STATE=ok
238    
239   echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial   echo "ALX_SERIAL=\"${ALX_SERIAL}\"" > /etc/alxconfig-ng/serial
240   echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial   echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial
241    
242   evaluate_retval   evaluate_retval
243   else   else
# Line 252  get_system_serial(){ Line 256  get_system_serial(){
256   fi   fi
257    
258   # write current state to temp file   # write current state to temp file
259   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
260     echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state
261  }  }
262    
263    
264  check_is_configured() {  check_is_configured()
265    {
266   if [ -f /etc/alxconfig-ng/state/configured ]   if [ -f /etc/alxconfig-ng/state/configured ]
267   then   then
268   export ALX_CONFIGURED=true   export ALX_CONFIGURED=true
# Line 267  check_is_configured() { Line 273  check_is_configured() {
273    
274    
275  # imports current settings to the database resolved by the hardware detection  # imports current settings to the database resolved by the hardware detection
276  import_settings_to_db() {  import_settings_to_db()
277    {
278   # note: networking is always 'dhcp' if hw was autodetected   # note: networking is always 'dhcp' if hw was autodetected
279   # note: default_domain/hostname is set in config.rc   # note: default_domain/hostname is set in config.rc
280    
# Line 289  import_settings_to_db() { Line 296  import_settings_to_db() {
296    
297   # network   # network
298   echo -e "      Network settings ..."   echo -e "      Network settings ..."
299   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   if [[ ${ALX_CONFD_NETWORKING} = true ]]
300   "insert into cfg_network(   then
301   hostname,   # get settings
302   serial,   #source ${rc_base}/init.d/network &> /dev/null
303   module,   for iface in $(onboot_interface_list ${network_settings}/net.*)
304   domain,   do
305   networking   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
306   )   echo "WARNING: only importing settings for interface [ ${iface} ] !"
307   values(   source ${network_settings}/net.${iface} || exit 1
308   '${ALX_DEFAULT_HOSTNAME}',   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"
309   '${ALX_SERIAL}',  
310   '${NETCARD_DRIVER}',   mysqldo "insert into cfg_network(
311   '${ALX_DEFAULT_DOMAIN}',   hostname,
312   'dhcp'   serial,
313   );"   module,
314     domain,
315     networking,
316     netmask,
317     dns,
318     gateway,
319     broadcast,
320     ip,
321     forcemacto,
322     wireless_bitrate,
323     wireless_channel,
324     wireless_essid,
325     wireless_frequency,
326     wireless_mode,
327     wireless_nick,
328     wireless_auth_mode,
329     wireless_key_length,
330     wireless_key,
331     wireless_key_ascii
332     )
333     values(
334     '${ALX_DEFAULT_HOSTNAME}',
335     '${ALX_SERIAL}',
336     '${NETCARD_DRIVER}',
337     '${ALX_DEFAULT_DOMAIN}',
338     '${NETWORKING}',
339     '${NETMASK}',
340     '${NAMESERVER}',
341     '${GATEWAY}',
342     '${BROADCAST}',
343     '${IP}',
344     '${FORCE_MAC_TO}',
345     '${WIRELESS_BITRATE}',
346     '${WIRELESS_CHANNEL}',
347     '${WIRELESS_ESSID}',
348     '${WIRELESS_FREQUENCY}',
349     '${WIRELESS_MODE}',
350     '${WIRELESS_NICK}',
351     '${WIRELESS_AUTH_MODE}',
352     '${WIRELESS_KEY_LENGTH}',
353     '${WIRELESS_KEY}',
354     '${WIRELESS_KEY_ASCII}'
355     );"
356    
357     # only insert the *FIRST* iface
358     break
359     done
360     else
361     mysqldo "insert into cfg_network(
362     hostname,
363     serial,
364     module,
365     domain,
366     networking
367     )
368     values(
369     '${ALX_DEFAULT_HOSTNAME}',
370     '${ALX_SERIAL}',
371     '${NETCARD_DRIVER}',
372     '${ALX_DEFAULT_DOMAIN}',
373     'dhcp'
374     );"
375     fi
376   evaluate_retval   evaluate_retval
377    
378   # xserver   # xserver
379   echo -e "      Graphic settings ..."   echo -e "      Graphic settings ..."
380   # xserver general   # xserver general
381   ( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ( mysqldo "insert into cfg_graphic(
  "insert into cfg_graphic(  
382   serial,   serial,
383   module,   module,
384   resolution,   resolution,
385   depth,   depth,
386   monitorid   refresh_rate
387   )   )
388   values(   values(
389   '${ALX_SERIAL}',   '${ALX_SERIAL}',
390   '${XMODULE}',   '${XMODULE}',
391   '1024x768',   '1024x768',
392   '16',   '16',
393   '0'   '60'
394   );"; )   );"; )
395   evaluate_retval   evaluate_retval
396    
397   # input   # input
398   echo -e "      Input settings ..."   echo -e "      Input settings ..."
399   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"
  "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"  
400   evaluate_retval   evaluate_retval
401    
402   # auth   # auth
403   echo -e "      Authentifcation settings ..."   echo -e "      Authentification settings ..."
404   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into client_auth(
  "insert into client_auth(  
405   serial,   serial,
406   username,   username,
407   shell,   shell,
# Line 355  import_settings_to_db() { Line 421  import_settings_to_db() {
421    
422   # exchange ssh rsa keys - the first boot needs this !   # exchange ssh rsa keys - the first boot needs this !
423   # or no reboot will work via the webadmin   # or no reboot will work via the webadmin
424   echo -e "      SSH authentifcation settings ..."   echo -e "      SSH authentification settings ..."
425   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
426   evaluate_retval   evaluate_retval
427    
428   # input   # autostart
429   echo -e "      Autostart settings ..."   echo -e "      Autostart settings ..."
430   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
431   "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"  
432     # screensaver
433     echo -e "      Screensaver settings ..."
434     mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"
435    
436     # version info
437     local alx_os
438     local alx_utils
439     alx_os="$(< /etc/mageversion)"
440     alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')"
441     alx_utils="${alx_utils/alxconfig-ng-alx-}"
442     mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')"
443    
444   evaluate_retval   evaluate_retval
445  }  }
446    
447  # imports current settings to the database resolved by the hardware detection  # imports current settings to the database resolved by the hardware detection
448  update_settings_in_db() {  update_settings_in_db()
449    {
450   # note: networking is always 'dhcp' if hw was autodetected   # note: networking is always 'dhcp' if hw was autodetected
451   # note: default_domain/hostname is set in config.rc or exported   # note: default_domain/hostname is set in config.rc or exported
452   # note: we updating only hardware settings here !   # note: we updating only hardware settings here !
# Line 390  update_settings_in_db() { Line 469  update_settings_in_db() {
469    
470   # network   # network
471   echo -e "      Network settings ..."   echo -e "      Network settings ..."
472     if [[ ${ALX_CONFD_NETWORKING} = true ]]
473   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   then
474   "update cfg_network set   # get settings
475   hostname='${ALX_DEFAULT_HOSTNAME}',   #source ${rc_base}/init.d/network &> /dev/null
476   module='${NETCARD_DRIVER}',   for iface in $(onboot_interface_list ${network_settings}/net.*)
477   domain='${ALX_DEFAULT_DOMAIN}',   do
478   networking='dhcp'   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
479   where serial=${ALX_SERIAL};"   echo "WARNING: only importing settings for interface [ ${iface} ] !"
480     source ${network_settings}/net.${iface} || exit 1
481     NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"
482    
483     mysqldo "update cfg_network set
484     hostname='${ALX_DEFAULT_HOSTNAME}',
485     module='${NETCARD_DRIVER}',
486     domain='${ALX_DEFAULT_DOMAIN}',
487     networking='${NETWORKING}',
488     netmask='${NETMASK}',
489     dns='${NAMESERVER}',
490     gateway='${GATEWAY}',
491     broadcast='${BROADCAST}',
492     ip='${IP}',
493     forcemacto='${FORCE_MAC_TO}',
494     wireless_bitrate='${WIRELESS_BITRATE}',
495     wireless_channel='${WIRELESS_CHANNEL}',
496     wireless_essid='${WIRELESS_ESSID}',
497     wireless_frequency='${WIRELESS_FREQUENCY}',
498     wireless_mode='${WIRELESS_MODE}',
499     wireless_nick='${WIRELESS_NICK}',
500     wireless_auth_mode='${WIRELESS_AUTH_MODE}',
501     wireless_key_length='${WIRELESS_KEY_LENGTH}',
502     wireless_key='${WIRELESS_KEY}',
503     wireless_key_ascii='${WIRELESS_KEY_ASCII}'
504     where serial=${ALX_SERIAL};"
505    
506     # only insert the *FIRST* iface
507     break
508     done
509     else
510     mysqldo "update cfg_network set
511     hostname='${ALX_DEFAULT_HOSTNAME}',
512     module='${NETCARD_DRIVER}',
513     domain='${ALX_DEFAULT_DOMAIN}',
514     networking='dhcp'
515     where serial=${ALX_SERIAL};"
516     fi
517   evaluate_retval   evaluate_retval
518    
519   # xserver   # xserver
520   echo -e "      Graphic settings ..."   echo -e "      Graphic settings ..."
521   # xserver general   # xserver general
522   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_graphic set
  "update cfg_graphic set  
523   module='${XMODULE}',   module='${XMODULE}',
524   resolution='1024x768',   resolution='1024x768',
525   depth='16',   depth='16',
526   monitorid='0'   refresh_rate='60'
527   where serial=${ALX_SERIAL};"   where serial=${ALX_SERIAL};"
528   evaluate_retval   evaluate_retval
529    
530   # input   # input
531   echo -e "      Input settings ..."   echo -e "      Input settings ..."
532   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"
  "update cfg_input set  
  mouse='${XMOUSETYPE}'  
  where serial=${ALX_SERIAL};"  
533   evaluate_retval   evaluate_retval
534    
535     # version info
536     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  }  }
543    
544  # imports current settings to the local system resolved by the hardware detection  # imports current settings to the local system resolved by the hardware detection
545  # we only need the network settings  # we only need the network settings
546  import_settings_local(){  import_settings_local()
547    {
548   # note: networking is always 'dhcp' if hw was autodetected   # note: networking is always 'dhcp' if hw was autodetected
549   # note: default_domain/hostname is set in config.rc   # note: default_domain/hostname is set in config.rc
550    
# Line 442  import_settings_local(){ Line 563  import_settings_local(){
563   echo   echo
564   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}
565    
566   [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}   if [[ ${ALX_CONFD_NETWORKING} = false ]]
567   echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules   then
568   evaluate_retval   #[ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}
569     #echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules
570    
571     # set an device alias for modprobe.conf and modules.conf
572     [ ! -d /etc/modules.d ] && install -d /etc/modules.d
573     [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d
574     echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modules.d/net.eth0
575     echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0
576    
577     # regenerate modprobe.conf
578     [ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf"
579     evaluate_retval
580     fi
581    
582   # set system state to 'already configured'   # set system state to 'already configured'
583   touch /etc/alxconfig-ng/state/configured   touch /etc/alxconfig-ng/state/configured
584    
585     # install slim desktopmanager configuration
586     config_display_manager
587    
588   # if only an recheck was forced than abort now   # if only an recheck was forced than abort now
589   [[ ${ALX_FORCED_RECHECK} = true ]] && return 0   [[ ${ALX_FORCED_RECHECK} = true ]] && return 0
590    
# Line 462  import_settings_local(){ Line 598  import_settings_local(){
598   cat ${ALX_SKELETONS}/fluxbox/init \   cat ${ALX_SKELETONS}/fluxbox/init \
599   > ${ALX_UNPRIV_HOME}/.fluxbox/init   > ${ALX_UNPRIV_HOME}/.fluxbox/init
600    
601     # fluxbox autostart
602     cat ${ALX_SKELETONS}/fluxbox/apps \
603     > ${ALX_UNPRIV_HOME}/.fluxbox/apps
604    
605   # fluxbox menu header   # fluxbox menu header
606   cat ${ALX_SKELETONS}/fluxbox/menu.header \   cat ${ALX_SKELETONS}/fluxbox/menu.header \
607   > ${ALX_UNPRIV_HOME}/.fluxbox/menu   > ${ALX_UNPRIV_HOME}/.fluxbox/menu
# Line 516  import_settings_local(){ Line 656  import_settings_local(){
656   --icon-width "1" \   --icon-width "1" \
657   --icon-height "1"   --icon-height "1"
658    
659     # create a xinitrc
660     echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc
661    
662   # set correct permissions   # set correct permissions
663   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
664   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
665   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
666   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop
667   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc
668     chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc
  # default passwords are bad  
  #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root  
  #usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER}  
  #smbpasswd -a root foobar  
669  }  }
670    
671  # start|stop  # start|stop
672  preliminary_network(){  preliminary_network()
673    {
674   local module   local module
675     local modulesconf
676    
677   if [ -f /etc/alxconfig-ng/state/configured ]   if [ -f /etc/alxconfig-ng/state/configured ]
678   then   then
679   # get module name   # compat for old clients
680   module=$(cat ${SETTINGSPATH}/modules)   if [ -f ${SETTINGSPATH}/modules ]
681   modprobe ${module}   then
682     # get module name
683     module=$(cat ${SETTINGSPATH}/modules)
684     modprobe ${module}
685     fi
686    
687     # check modprobe.conf
688     if [[ $(kernel_major_version) = 2.4 ]]
689     then
690     modulesconf="/etc/modules.conf"
691     else
692     modulesconf="/etc/modprobe.conf"
693     fi
694     if [[ -z $(grep eth0 ${modulesconf}) ]]
695     then
696     /sbin/modules-update force
697     fi
698   else   else
699   # vars used by hwdetect   # vars used by hwdetect
700   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
# Line 561  preliminary_network(){ Line 718  preliminary_network(){
718   else   else
719   rm -f /var/run/dhcpcd-eth?.pid   rm -f /var/run/dhcpcd-eth?.pid
720   fi   fi
721     [[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \
722     ${rc_base}/init.d/network stop
723    
724   echo -e ${COLMAGENTA}"Starting preliminary network ... "${COLDEFAULT}   echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT}
  # -t 10 timeout of 10 secs  
  dhcpcd -t 10 &> /dev/null  
   
  # aka_fix ########################################  
  #ifconfig eth0 128.20.222.222 netmask 255.255.0.0 up  
  #route del default gw 128.20.50.13 &> /dev/null  
  #route add default gw 128.20.50.21 &> /dev/null  
  #echo "nameserver 128.20.50.21" > /etc/resolv.conf  
  ##################################################  
725    
726   evaluate_retval   # start network configured from /etc/conf.d
727     if [[ ${ALX_CONFD_NETWORKING} = true ]]
728     then
729     ${rc_base}/init.d/network start
730     else
731     echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT}
732     # -t 10 timeout of 10 secs
733     dhcpcd -t 10 &> /dev/null
734     evaluate_retval
735     fi
736   ;;   ;;
737    
738   stop)   stop)
739   echo -e ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT}   echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT}
740   ifconfig eth0 down   if [[ ${ALX_CONFD_NETWORKING} = true ]]
741     then
742     ${rc_base}/init.d/network stop
743     else
744     echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT}
745     ifconfig eth0 down
746     fi
747   if ps -A|grep dhcpcd > /dev/null   if ps -A|grep dhcpcd > /dev/null
748   then   then
749   dhcpcd -z  &> /dev/null   dhcpcd -z  &> /dev/null
750     sleep 1
751   fi   fi
752   evaluate_retval   evaluate_retval
753   ;;   ;;
# Line 592  preliminary_network(){ Line 758  preliminary_network(){
758   esac   esac
759  }  }
760    
761    reset_system_settings()
762    {
763     # force load of de kbdkeys
764     loadkeys -q de
765     echo
766     echo -en ${COLRED}
767     echo -n "*** Warning: you are about to reset *all* local settings on this system!"
768     echo -e ${COLDEFAULT}
769     echo "*** Do you really want to continue ?"
770     echo -n "*** Enter 'yes' to continue, anything else to abort: "
771     read kbinsert
772     if [[ ${kbinsert} = yes ]]
773     then
774     echo -en ${COLRED}
775     echo -n "*** OK, you really want it ... killing all settings: "
776     for i in 3 2 1 now
777     do
778     echo -n " ${i}"
779     sleep 1
780     done
781     echo -e ${COLDEFAULT}
782    
783     ## reset all settings:
784     rm -rf ${SETTINGSPATH}/*
785     rm -f /etc/alxconfig-ng/serial
786     rm -rf /etc/alxconfig-ng/state
787    
788     # clear all printers & net-shares
789     :> /etc/cups/printers.conf
790     :> /etc/samba/smb.conf
791    
792     # remove inetd, cups & smb from init
793     rc-config del inetd &> /dev/null
794     rc-config del cups &> /dev/null
795     rc-config del samba &> /dev/null
796    
797     # remove all user settings
798     [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
799    
800     # remove all ica-sessions
801     find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm
802    
803     # remove all old nics and modules configs
804     find /etc/conf.d -type f -name 'net.*' | xargs rm
805     find /etc/modules.d -type f -name 'net.*' | xargs rm
806    
807     # restore default networking
808     cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0
809    
810     echo "I am done now, press [Enter] to reboot system ..."
811     else
812     echo "Aborted, press [Enter] to reboot system ..."
813     fi
814     read
815     reboot
816    }
817    
818    onboot_interface_list()
819    {
820     local file
821     local devices
822     local iface
823    
824     # get list of all devices
825     for file in $@
826     do
827     if [[ $(read_value ONBOOT ${file}) = yes ]]
828     then
829     iface="$(basename ${file} | sed s/net.//)"
830     # exclude backup files
831     case "${iface}" in
832     *~) ;;
833     *) devices="${devices} $(basename ${file} | sed s/net.//)" ;;
834     esac
835     fi
836     done
837    
838     echo "${devices}"
839    }
840    
841    # read values from net.* files
842    read_value()
843    {
844     local var="$1"
845     local file="$2"
846     local value
847    
848     # local all possible vars
849     # global
850     local ONBOOT
851     local NETWORKING
852    
853     # static
854     local IP
855     local NETMASK
856     local BROADCAST
857     local NETWORKING
858     local FORCE_MAC_TO
859    
860     # dhcp
861     local DHCP_PROG
862     local DHCP_START
863     local DHCP_STOP
864    
865     # default gw
866     local GATEWAY
867     local GATEWAY_IF
868    
869     # wireless extensions
870     local WIRELESS_AP
871     local WIRELESS_AUTH_MODE
872     local WIRELESS_BITRATE
873     local WIRELESS_CHANNEL
874     local WIRELESS_DEFAULT_KEY
875     local WIRELESS_ESSID
876     local WIRELESS_FREQUENCY
877     local WIRELESS_KEY
878     local WIRELESS_KEY_ASCII
879     local WIRELESS_KEY_0
880     local WIRELESS_KEY_1
881     local WIRELESS_KEY_2
882     local WIRELESS_KEY_3
883     local WIRELESS_KEY_LENGTH
884     local WIRELESS_MODE
885     local WIRELESS_NICK
886     local WIRELESS_NWID
887     local WIRELESS_POWER
888    
889     source ${file}
890     eval value=\$$(echo ${var})
891     echo "${value}"
892    }
893    
894  case $1 in  case $1 in
895   start)   start)
896     # check for global overrides
897     [ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true
898     [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true
899     read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true
900     read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true
901    
902     # kill all settings if requested
903     if [[ ${ALX_RESET_SETTINGS} = true ]]
904     then
905     reset_system_settings
906     fi
907    
908   # retrieve or validate current serial   # retrieve or validate current serial
909   get_system_serial   get_system_serial
910   if [[ ${ALX_HW_DETECT} = true ]]   if [[ ${ALX_HW_DETECT} = true ]]
# Line 614  case $1 in Line 925  case $1 in
925    
926   # now setup system configuration   # now setup system configuration
927   # alx_setup_or_whatever_it_will_be_called()   # alx_setup_or_whatever_it_will_be_called()
928   [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings   [[ ${ALX_HW_DETECT} = false ]] && update_system_settings
929    
930   # stop at last the preliminary networking (dhcp)   # stop at last the preliminary networking (dhcp)
931   preliminary_network stop   preliminary_network stop

Legend:
Removed from v.313  
changed lines
  Added in v.1800