Magellan Linux

Diff of /alx-src/trunk/tinyalxconfig-ng/init.d/alxsettings

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

revision 448 by niro, Thu Jun 5 17:23:07 2008 UTC revision 491 by niro, Sun Jun 8 11:07:16 2008 UTC
# Line 11  Line 11 
11  #%before:  #%before:
12  #%after:  #%after:
13    
14  # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/init.d/alxsettings,v 1.10 2008-06-05 17:23:07 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/init.d/alxsettings,v 1.16 2008-06-08 11:07:16 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 30  source /etc/alxconfig-ng/config.rc Line 30  source /etc/alxconfig-ng/config.rc
30  # helper functions  # helper functions
31  source /usr/lib/alxconfig-ng/functions/mysqlfunctions  source /usr/lib/alxconfig-ng/functions/mysqlfunctions
32  source /usr/lib/alxconfig-ng/functions/serial_functions  source /usr/lib/alxconfig-ng/functions/serial_functions
33    source /usr/lib/alxconfig-ng/functions/config_driverkits
34  source /usr/lib/alxconfig-ng/functions/config_modules  source /usr/lib/alxconfig-ng/functions/config_modules
35  source /usr/lib/alxconfig-ng/functions/config_network  source /usr/lib/alxconfig-ng/functions/config_network
36  source /usr/lib/alxconfig-ng/functions/config_printers  source /usr/lib/alxconfig-ng/functions/config_printers
# Line 38  source /usr/lib/alxconfig-ng/functions/c Line 39  source /usr/lib/alxconfig-ng/functions/c
39  source /usr/lib/alxconfig-ng/functions/config_auth  source /usr/lib/alxconfig-ng/functions/config_auth
40  source /usr/lib/alxconfig-ng/functions/config_ssh_auth  source /usr/lib/alxconfig-ng/functions/config_ssh_auth
41    
 # check if mysql is available  
 [ -x /usr/bin/mysql ] && MYSQL_ALX=true  
   
42  # other needed vars  # other needed vars
43  ALX_HW_DETECT=false  ALX_HW_DETECT=false
44  ALX_FORCED_RECHECK=false  ALX_FORCED_RECHECK=false
45  ALX_RESET_SETTINGS=false  ALX_RESET_SETTINGS=false
 ALX_CONFD_NETWORKING=false  
46    
47  # unset vars which may kill us  # unset vars which may kill us
48  unset ALX_SERIAL ALX_STATE  unset ALX_SERIAL ALX_STATE
# Line 72  update_system_settings() Line 69  update_system_settings()
69  {  {
70   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}
71    
72     # install neccessary driverkits
73     config_driverkits
74    
75   # get the modules settings   # get the modules settings
76   # ! is the first thing that must be configured !   # ! is the first thing that must be configured !
77   config_modules   config_modules
# Line 99  get_system_serial() Line 99  get_system_serial()
99  {  {
100   local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE   local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE
101    
  if [[ -f ${SETTINGSPATH}/confd-networking ]]  
  then  
  ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)"  
  else  
  ALX_IFACE="eth0"  
  fi  
   
102   # check if serial file exists   # check if serial file exists
103   if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]   if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]
104   then   then
# Line 279  import_settings_to_db() Line 272  import_settings_to_db()
272   # note: default_domain/hostname is set in config.rc   # note: default_domain/hostname is set in config.rc
273    
274   # to be safe, we do some sanity checks   # to be safe, we do some sanity checks
275   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain
276   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx
277    
278   # vars used by hwdetect   # vars used by hwdetect
279   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
# Line 295  import_settings_to_db() Line 288  import_settings_to_db()
288   echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT}   echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT}
289    
290   # network   # network
291   echo -e "      Network settings ..."   echo "      Network settings ..."
292   # global settings   # global settings
293   mysqldo "insert into cfg_network(serial, hostname, domain )   mysqldo "insert into cfg_network(serial, hostname, domain )
294   values('${ALX_SERIAL}', '${ALX_DEFAULT_HOSTNAME}','${ALX_DEFAULT_DOMAIN}');"   values('${ALX_SERIAL}', '${ALX_DEFAULT_HOSTNAME}','${ALX_DEFAULT_DOMAIN}');"
# Line 324  import_settings_to_db() Line 317  import_settings_to_db()
317   evaluate_retval   evaluate_retval
318    
319   # xserver   # xserver
320   echo -e "      Graphic settings ..."   echo "      Graphic settings ..."
321   # xserver general   # xserver general
322   ( mysqldo "insert into cfg_graphic(   ( mysqldo "insert into cfg_graphic(
323   serial,   serial,
# Line 343  import_settings_to_db() Line 336  import_settings_to_db()
336   evaluate_retval   evaluate_retval
337    
338   # input   # input
339   echo -e "      Input settings ..."   echo "      Input settings ..."
340   mysqldo "insert into cfg_input(serial,mouse,keyboard) values('${ALX_SERIAL}','${XMOUSETYPE}','kbd');"   mysqldo "insert into cfg_input(serial,mouse,keyboard) values('${ALX_SERIAL}','${XMOUSETYPE}','kbd');"
341   evaluate_retval   evaluate_retval
342    
343   # auth   # auth
344   echo -e "      Authentification settings ..."   echo "      Authentification settings ..."
345   mysqldo "insert into client_auth(   mysqldo "insert into client_auth(
346   serial,   serial,
347   username,   username,
# Line 369  import_settings_to_db() Line 362  import_settings_to_db()
362    
363   # exchange ssh rsa keys - the first boot needs this !   # exchange ssh rsa keys - the first boot needs this !
364   # or no reboot will work via the webadmin   # or no reboot will work via the webadmin
365   echo -e "      SSH authentification settings ..."   echo "      SSH authentification settings ..."
366   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
367   evaluate_retval   evaluate_retval
368    
369   # autostart   # autostart
370   echo -e "      Autostart settings ..."   echo "      Autostart settings ..."
371   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
372    
373   # screensaver   # screensaver
374   echo -e "      Screensaver settings ..."   echo "      Screensaver settings ..."
375   mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"   mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"
376    
377   evaluate_retval   evaluate_retval
# Line 392  update_settings_in_db() Line 385  update_settings_in_db()
385   # note: we updating only hardware settings here !   # note: we updating only hardware settings here !
386    
387   # to be safe, we do some sanity checks   # to be safe, we do some sanity checks
388   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain
389   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx
390    
391   # vars used by hwdetect   # vars used by hwdetect
392   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
# Line 408  update_settings_in_db() Line 401  update_settings_in_db()
401   echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT}   echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT}
402    
403   # network   # network
404   echo -e "      Network settings ..."   echo "      Network settings ..."
405   mysqldo "update cfg_network set   mysqldo "update cfg_network set
406   hostname='${ALX_DEFAULT_HOSTNAME}',   hostname='${ALX_DEFAULT_HOSTNAME}',
407   domain='${ALX_DEFAULT_DOMAIN}';   domain='${ALX_DEFAULT_DOMAIN}';
# Line 434  update_settings_in_db() Line 427  update_settings_in_db()
427   evaluate_retval   evaluate_retval
428    
429   # xserver   # xserver
430   echo -e "      Graphic settings ..."   echo "      Graphic settings ..."
431   # xserver general   # xserver general
432   mysqldo "update cfg_graphic set   mysqldo "update cfg_graphic set
433   module='${XMODULE}',   module='${XMODULE}',
# Line 445  update_settings_in_db() Line 438  update_settings_in_db()
438   evaluate_retval   evaluate_retval
439    
440   # input   # input
441   echo -e "      Input settings ..."   echo "      Input settings ..."
442   mysqldo "update cfg_input set mouse='${XMOUSETYPE}', keyboard='kbd' where serial=${ALX_SERIAL};"   mysqldo "update cfg_input set mouse='${XMOUSETYPE}', keyboard='kbd' where serial=${ALX_SERIAL};"
443   evaluate_retval   evaluate_retval
444  }  }
# Line 458  import_settings_local() Line 451  import_settings_local()
451   # note: default_domain/hostname is set in config.rc   # note: default_domain/hostname is set in config.rc
452    
453   # to be safe, we do some sanity checks   # to be safe, we do some sanity checks
454   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain
455   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx
456    
457   # vars used by hwdetect   # vars used by hwdetect
458   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
# Line 485  import_settings_local() Line 478  import_settings_local()
478   # now generate fluxbox config files   # now generate fluxbox config files
479    
480   # fluxbox main config   # fluxbox main config
481   cat ${ALX_SKELETONS}/fluxbox/init \   cat ${ALX_SKELETONS}/fluxbox/init > ${ALX_UNPRIV_HOME}/.fluxbox/init
  > ${ALX_UNPRIV_HOME}/.fluxbox/init  
482    
483   # fluxbox autostart   # fluxbox autostart
484   cat ${ALX_SKELETONS}/fluxbox/apps \   cat ${ALX_SKELETONS}/fluxbox/apps > ${ALX_UNPRIV_HOME}/.fluxbox/apps
  > ${ALX_UNPRIV_HOME}/.fluxbox/apps  
485    
486   # fluxbox menu header   # fluxbox menu header
487   cat ${ALX_SKELETONS}/fluxbox/menu.header \   cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu
  > ${ALX_UNPRIV_HOME}/.fluxbox/menu  
488    
489   # now fix it with proper messages :P   # now fix it with proper messages :P
490   local ver="$(< /etc/mageversion)"   local ver="$(< /etc/mageversion)"
491   sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" \   sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu
  ${ALX_UNPRIV_HOME}/.fluxbox/menu  
492    
493   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
494   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
495    
496   # fluxbox menu footer   # fluxbox menu footer
497   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
  >> ${ALX_UNPRIV_HOME}/.fluxbox/menu  
498    
499   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
500   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
# Line 609  reset_system_settings() Line 597  reset_system_settings()
597   rm -f /etc/alxconfig-ng/serial   rm -f /etc/alxconfig-ng/serial
598   rm -rf /etc/alxconfig-ng/state   rm -rf /etc/alxconfig-ng/state
599    
600   # clear all printers & net-shares   # clear all printers
601   :> /etc/cups/printers.conf   :> /etc/printcap
  :> /etc/samba/smb.conf  
   
  # remove inetd, cups & smb from init  
  rc-config del inetd &> /dev/null  
  rc-config del cups &> /dev/null  
  rc-config del samba &> /dev/null  
602    
603   # remove all user settings   # remove all user settings
604   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
# Line 639  reset_system_settings() Line 621  reset_system_settings()
621   reboot   reboot
622  }  }
623    
 # read values from net.* files  
 read_value()  
 {  
  local var="$1"  
  local file="$2"  
  local value  
   
  # local all possible vars  
  # global  
  local ONBOOT  
  local NETWORKING  
   
  # static  
  local IP  
  local NETMASK  
  local BROADCAST  
  local NETWORKING  
  local FORCE_MAC_TO  
   
  # dhcp  
  local DHCP_PROG  
  local DHCP_START  
  local DHCP_STOP  
   
  # default gw  
  local GATEWAY  
  local GATEWAY_IF  
   
  # wireless extensions  
  local WIRELESS_AP  
  local WIRELESS_AUTH_MODE  
  local WIRELESS_BITRATE  
  local WIRELESS_CHANNEL  
  local WIRELESS_DEFAULT_KEY  
  local WIRELESS_ESSID  
  local WIRELESS_FREQUENCY  
  local WIRELESS_KEY  
  local WIRELESS_KEY_ASCII  
  local WIRELESS_KEY_0  
  local WIRELESS_KEY_1  
  local WIRELESS_KEY_2  
  local WIRELESS_KEY_3  
  local WIRELESS_KEY_LENGTH  
  local WIRELESS_MODE  
  local WIRELESS_NICK  
  local WIRELESS_NWID  
  local WIRELESS_POWER  
   
  source ${file}  
  eval value=\$$(echo ${var})  
  echo "${value}"  
 }  
   
624  case $1 in  case $1 in
625   start)   start)
626   # check for global overrides   # check for global overrides
  [ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true  
627   [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true   [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true
628   read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true   read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true
629   read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true   read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true
# Line 741  case $1 in Line 669  case $1 in
669   echo "Usage: $0 {start|stop} ..."   echo "Usage: $0 {start|stop} ..."
670   ;;   ;;
671  esac  esac
   

Legend:
Removed from v.448  
changed lines
  Added in v.491