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 510 by niro, Tue Jun 17 19:05:51 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.21 2008-06-17 19:05:51 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 21  Line 21 
21  # if no changes are at server side they will be kept, if yes the get updated.  # if no changes are at server side they will be kept, if yes the get updated.
22  # the server settings has higher priority.  # the server settings has higher priority.
23    
24  source /etc/sysconfig/rc  source /etc/conf.d/rc
25  source $rc_functions  source ${rc_functions}
26    
27  # mysql settings  # mysql settings
28  source /etc/alxconfig-ng/config.rc  source /etc/alxconfig-ng/config.rc
# 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     # theme
378     echo "      Theme settings ..."
379     mysqldo "insert into cfg_theme(serial,theme) values('${ALX_SERIAL}','${ALX_DEFAULT_THEME}')"
380    
381   evaluate_retval   evaluate_retval
382  }  }
383    
# Line 392  update_settings_in_db() Line 389  update_settings_in_db()
389   # note: we updating only hardware settings here !   # note: we updating only hardware settings here !
390    
391   # to be safe, we do some sanity checks   # to be safe, we do some sanity checks
392   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain
393   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx
394    
395   # vars used by hwdetect   # vars used by hwdetect
396   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 405  update_settings_in_db()
405   echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT}   echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT}
406    
407   # network   # network
408   echo -e "      Network settings ..."   echo "      Network settings ..."
409   mysqldo "update cfg_network set   mysqldo "update cfg_network set
410   hostname='${ALX_DEFAULT_HOSTNAME}',   hostname='${ALX_DEFAULT_HOSTNAME}',
411   domain='${ALX_DEFAULT_DOMAIN}';   domain='${ALX_DEFAULT_DOMAIN}';
# Line 434  update_settings_in_db() Line 431  update_settings_in_db()
431   evaluate_retval   evaluate_retval
432    
433   # xserver   # xserver
434   echo -e "      Graphic settings ..."   echo "      Graphic settings ..."
435   # xserver general   # xserver general
436   mysqldo "update cfg_graphic set   mysqldo "update cfg_graphic set
437   module='${XMODULE}',   module='${XMODULE}',
# Line 445  update_settings_in_db() Line 442  update_settings_in_db()
442   evaluate_retval   evaluate_retval
443    
444   # input   # input
445   echo -e "      Input settings ..."   echo "      Input settings ..."
446   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};"
447   evaluate_retval   evaluate_retval
448  }  }
# Line 458  import_settings_local() Line 455  import_settings_local()
455   # note: default_domain/hostname is set in config.rc   # note: default_domain/hostname is set in config.rc
456    
457   # to be safe, we do some sanity checks   # to be safe, we do some sanity checks
458   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [[ -z ${ALX_DEFAULT_DOMAIN} ]] && ALX_DEFAULT_DOMAIN=localdomain
459   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [[ -z ${ALX_DEFAULT_HOSTNAME} ]] && ALX_DEFAULT_HOSTNAME=magellan-alx
460    
461   # vars used by hwdetect   # vars used by hwdetect
462   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
# Line 484  import_settings_local() Line 481  import_settings_local()
481    
482   # now generate fluxbox config files   # now generate fluxbox config files
483    
484     # fluxbox theme
485     [[ ! -d /usr/share/fluxbox/styles ]] && install -d /usr/share/fluxbox/styles
486     cat ${ALX_SKELETONS}/fluxbox/themes/${ALX_DEFAULT_THEME} > /usr/share/fluxbox/styles/default
487    
488   # fluxbox main config   # fluxbox main config
489   cat ${ALX_SKELETONS}/fluxbox/init \   cat ${ALX_SKELETONS}/fluxbox/init > ${ALX_UNPRIV_HOME}/.fluxbox/init
  > ${ALX_UNPRIV_HOME}/.fluxbox/init  
490    
491   # fluxbox autostart   # fluxbox autostart
492   cat ${ALX_SKELETONS}/fluxbox/apps \   cat ${ALX_SKELETONS}/fluxbox/apps > ${ALX_UNPRIV_HOME}/.fluxbox/apps
  > ${ALX_UNPRIV_HOME}/.fluxbox/apps  
493    
494   # fluxbox menu header   # fluxbox menu header
495   cat ${ALX_SKELETONS}/fluxbox/menu.header \   cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu
  > ${ALX_UNPRIV_HOME}/.fluxbox/menu  
496    
497   # now fix it with proper messages :P   # now fix it with proper messages :P
498   local ver="$(< /etc/mageversion)"   local ver="$(< /etc/mageversion)"
499   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  
500    
501   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
502   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
503    
504   # fluxbox menu footer   # fluxbox menu footer
505   cat ${ALX_SKELETONS}/fluxbox/menu.footer \   cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
  >> ${ALX_UNPRIV_HOME}/.fluxbox/menu  
506    
507   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
508   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
509    
510   # setup some standart icons (sysinfo.lnk)   # setup some standart icons (sysinfo.lnk)
511   # basic config   # basic config
512   cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc   cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc-${ALX_DEFAULT_THEME} > ${ALX_UNPRIV_HOME}/.xtdeskrc
513    
514   # clean desktop icon location   # clean desktop icon location
515   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop   [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop
# Line 545  import_settings_local() Line 541  import_settings_local()
541   --icon-width "1" \   --icon-width "1" \
542   --icon-height "1"   --icon-height "1"
543    
  # create a xinitrc  
  echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc  
   
544   # set correct permissions   # set correct permissions
545   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
546   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
# Line 609  reset_system_settings() Line 602  reset_system_settings()
602   rm -f /etc/alxconfig-ng/serial   rm -f /etc/alxconfig-ng/serial
603   rm -rf /etc/alxconfig-ng/state   rm -rf /etc/alxconfig-ng/state
604    
605   # clear all printers & net-shares   # clear all printers
606   :> /etc/cups/printers.conf   :> /etc/printcap
607   :> /etc/samba/smb.conf   find /var/spool/lpd/* -type d | xargs rm -rf &> /dev/null
   
  # remove inetd, cups & smb from init  
  rc-config del inetd &> /dev/null  
  rc-config del cups &> /dev/null  
  rc-config del samba &> /dev/null  
608    
609   # remove all user settings   # remove all user settings
610   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}   [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
# Line 639  reset_system_settings() Line 627  reset_system_settings()
627   reboot   reboot
628  }  }
629    
 # 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}"  
 }  
   
630  case $1 in  case $1 in
631   start)   start)
632   # check for global overrides   # check for global overrides
  [ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true  
633   [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true   [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true
634   read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true   read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true
635   read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true   read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true
# Line 741  case $1 in Line 675  case $1 in
675   echo "Usage: $0 {start|stop} ..."   echo "Usage: $0 {start|stop} ..."
676   ;;   ;;
677  esac  esac
   

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