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 221 by niro, Tue Mar 8 20:49:14 2005 UTC alx-src/branches/alxconf-060/init.d/alxsettings revision 2778 by niro, Fri Aug 26 11:49:43 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3  # <niro@magellan-linux.de>  # <niro@magellan-linux.de>
4    
5  #%rlevels: 7:s 0:k 6:k  #%rlevels: 7:s 0:k
6  #%start: 41  #%start: 41
7  #%stop: 01  #%stop: 01
8    
# Line 19  Line 19 
19  # 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.
20  # the server settings has higher priority.  # the server settings has higher priority.
21    
22  #                       +-----+  source /etc/conf.d/rc
 #                       |start|  
 #                       +-----+  
 #                          |  
 #                          |  
 #              start_preliminary_network  
 #                          |  
 #                          |       n  
 #                  serial_check ------->  get_new_serial  
 #                          |                      |  
 #                         y|                      |  
 #                          |           n          |  
 #                check_is_configured ---->  run_hw_detection  
 #                          |                      |  
 #                         y|                      |  
 #            n             |                      |  
 #        +--------cfg_equal_to_db          import_settings_to_db  
 #        |                 |                      |  
 #   update_from_db        y|                      |  
 #        |                 |                      |  
 #   set_is_configured      |                  set_is_configured  
 #        +-----------------|                      |  
 #                          +----------------------+  
 #                          |  
 #                          |  
 #               stop_preliminary_network  
 #                          |  
 #                          |  
 #                       +----+  
 #                       |done|  
 #                       +----+  
 #                          |  
 #                          |  
 #                 normal_system_bootup  
 #                          |  
 #                          .  
 #                          .  
 #                          .  
 #  
 #  
 #  
   
 source /etc/sysconfig/rc  
23  source $rc_functions  source $rc_functions
24    
25  #mysql settings  # mysql settings
26  source /etc/alx-config/config.rc  source /etc/alxconfig-ng/config.rc
 source /opt/alx-config/functions/mysqlfunctions  
 source /opt/alx-config/functions/alx-mysql-functions  
27    
28  #check if mysql is available  # helper functions
29  [ -x /usr/bin/mysql ] && MYSQL_ALX=true  source ${ALX_FUNCTIONS}/common
30    source ${ALX_FUNCTIONS}/mysqlfunctions
31    source ${ALX_FUNCTIONS}/serial_functions
32    source ${ALX_FUNCTIONS}/config_modules
33    source ${ALX_FUNCTIONS}/config_plugins
34    source ${ALX_FUNCTIONS}/config_network
35    source ${ALX_FUNCTIONS}/usr/lib/alxconfig-ng/functions/config_printers
36    source ${ALX_FUNCTIONS}/usr/lib/alxconfig-ng/functions/config_sessions
37    source ${ALX_FUNCTIONS}/usr/lib/alxconfig-ng/functions/config_x11
38    source ${ALX_FUNCTIONS}/usr/lib/alxconfig-ng/functions/config_auth
39    source ${ALX_FUNCTIONS}/usr/lib/alxconfig-ng/functions/config_ssh_auth
40    source ${ALX_FUNCTIONS}/usr/lib/alxconfig-ng/functions/config_versions
41    
42  #other needed vars  # other needed vars
43  ALX_HW_DETECT=false  ALX_HW_DETECT=false
44  ALX_NETWORK_SETUP=false  ALX_FORCED_RECHECK=false
45  ALX_XSERVER_SETUP=false  ALX_RESET_SETTINGS=false
46  ALX_SESSION_SETUP=false  ALX_CONFD_NETWORKING=false
 ALX_PRINTER_SETUP=false  
47    
48  #unset vars which may kill us  # unset vars which may kill us
49  unset ALX_SERIAL ALX_STATE  unset ALX_SERIAL ALX_STATE
50    
51    
52  #setup needed directories  # setup needed directories
53  [ ! -d /etc/alx-config/state ] && install -d /etc/alx-config/state  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state
   
   
 # still a need to implement this ?  
 # #needed to detect usb/livecd boot  
 # if [ -e /.bootdev ]  
 # then  
 # source /.bootdev  
 # else  
 # echo "Couldn't find /.bootdev. Aborting."  
 # exit 1  
 # fi  
   
 # still a need to implement this ? --> media-check ?  
 settings_import() {  
  if [ "${FSTYPE}" == "vfat" ]  
  then  
  if [ -e /mnt/cdrom/settings/system ]  
  then  
  echo -e ${COLOREDSTAR}"Importing old alx-settings ..."  
  ( cp -R /mnt/cdrom/settings/system/* /etc/alx-config/settings/menu &&  
   source /etc/alx-config/config.rc &&  
   source /opt/alx-config/Configurator/config_functions.sh &&  
   setup_xfree > /dev/null 2>&1 &&  
   setup_modules > /dev/null 2>&1 &&  
   setup_network > /dev/null 2>&1 &&  
   #setup_printers > /dev/null 2>&1 &&  
   setup_sessions > /dev/null 2>&1 &&  
   touch /etc/alx-config/imported )  
  evaluate_retval  
  fi  
  fi  
 }  
   
   
 # this thingy needs an complete rewrite.  
 # first get all settings from db server,  
 # than check against local system settings,  
 # if there are any differences, update the local settings,  
 # as the server has a higher priority.  
 # Important: write local settings only if they make sense,  
 #            to have a fallback in case the server is down!  
 #get_settings_from_server(){  
 # #some needed arrays  
 # #ARRAY_NETWORK #module domain networking netmask dns gateway  
 # #SESSION #  
 # #GRAFIK  #  
 #  
 # echo "Importing now old Settings ..."  
 #  
 # local serial module domain networking netmask dns gateway i x all  
 #  
 # declare -i i=0  
 #  
 # #get hostname from database  
 # MY_HOSTNAME=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select hostname from cfg_serial where id='${ALX_SERIAL}'")  
 #  
 # #get network settings from database  
 # all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select module,  
 # domain,  
 # networking,  
 # netmask,  
 # dns,  
 # gateway,  
 # broadcast,  
 # ip  
 # from cfg_network where serial='${ALX_SERIAL}'")  
 # #split'em up and put in array  
 # for x in ${all}  
 # do  
 # ARRAY_NETWORK[${i}]=${x}  
 # ((i++))  
 # done  
 # echo " Network:"  
 # echo "   MODULE:     ${ARRAY_NETWORK[0]}"  
 # echo "   IP:         ${ARRAY_NETWORK[7]}"  
 # echo "   HOSTNAME:   ${MY_HOSTNAME}"  
 # echo "   DOMAIN:     ${ARRAY_NETWORK[1]}"  
 # echo "   NETWORKING: ${ARRAY_NETWORK[2]}"  
 # echo "   NETMASK:    ${ARRAY_NETWORK[3]}"  
 # echo "   DNS:        ${ARRAY_NETWORK[4]}"  
 # echo "   GATEWAY:    ${ARRAY_NETWORK[5]}"  
 # echo "   BROADCAST:  ${ARRAY_NETWORK[6]}"  
 # echo  
 #  
 # #get x settings from database  
 # local module resolution  
 #  
 # #reset i  
 # declare -i i=0  
 # all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select module,  
 # resolution  
 # from cfg_grafik where serial='${ALX_SERIAL}'")  
 # #split'em up and put in array  
 # for x in ${all}  
 # do  
 # ARRAY_GRAFIK[${i}]=${x}  
 # ((i++))  
 # done  
 #  
 # echo " VGA:"  
 # echo "   MODULE:     ${ARRAY_GRAFIK[0]}"  
 # echo "   RESOLUTION: ${ARRAY_GRAFIK[1]}"  
 # echo  
 #  
 # #get ica-sessions from database  
 # ARRAY_SESSIONS=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select session from cfg_session where serial='${ALX_SERIAL}'")  
 #  
 # echo " SESSIONS:"  
 # declare -i i=0  
 # for x in ${ARRAY_SESSIONS}  
 # do  
 # ((i++))  
 # echo "   SESSION${i}:   ${x}"  
 # done  
 # echo  
 #  
 # #now write these settings  
 # local SETTINGSPATH  
 #  
 # #network  
 #  
 # #settings must be also set on system, so we put this to menu  
 # SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
 #  
 # [ ! -d ${SETTINGSPATH}/modules ] && install -d ${SETTINGSPATH}/modules  
 # echo "${ARRAY_NETWORK[0]}" > ${SETTINGSPATH}/modules/modules  
 #  
 # [ ! -d ${SETTINGSPATH}/network ] && install -d ${SETTINGSPATH}/network  
 # echo "${MY_HOSTNAME}" > ${SETTINGSPATH}/network/hostname  
 # echo "${ARRAY_NETWORK[1]}" > ${SETTINGSPATH}/network/domain  
 # echo "${ARRAY_NETWORK[2]}" > ${SETTINGSPATH}/network/networking  
 # [ -n "${ARRAY_NETWORK[3]}" ] && echo "${ARRAY_NETWORK[3]}" > ${SETTINGSPATH}/network/netmask  
 # [ -n "${ARRAY_NETWORK[4]}" ] && echo "${ARRAY_NETWORK[4]}" > ${SETTINGSPATH}/network/dns  
 # [ -n "${ARRAY_NETWORK[5]}" ] && echo "${ARRAY_NETWORK[5]}" > ${SETTINGSPATH}/network/gateway  
 # [ -n "${ARRAY_NETWORK[6]}" ] && echo "${ARRAY_NETWORK[6]}" > ${SETTINGSPATH}/network/broadcast  
 # [ -n "${ARRAY_NETWORK[7]}" ] && echo "${ARRAY_NETWORK[7]}" > ${SETTINGSPATH}/network/ip  
54    
55    update_system_settings()
56    {
57     rc_mecho Checking system setup ...
58    
59  validate_networking(){   # get the modules settings
60   #source /opt/alx-config/Configurator/config_functions.sh   # ! is the first thing that must be configured !
61     config_modules
  local x i all LOCAL_NETWORK DB_NETWORK SETTINGSPATH  
   
  #all arrays:  
  # ->  hostname modules domain networking ip netmask dns gateway broadcast  
   
   #networking  
  #get settings from local system  
  SETTINGSPATH=${SETTINGS_TEMPLATE}/system  
  declare -i i=0  
  for x in network/hostname \  
  modules/modules \  
  network/domain \  
  network/networking \  
  network/ip \  
  network/netmask \  
  network/dns \  
  network/gateway \  
  network/broadcast  
  do  
  if [ -f ${SETTINGSPATH}/${x} ]  
  then  
  #file exist, then use content  
  LOCAL_NETWORK[${i}]="$(< ${SETTINGSPATH}/${x})"  
  else  
  LOCAL_NETWORK[${i}]=""  
  fi  
  ((i++))  
  done  
   
  #get settings from database  
 # DB_NETWORK[0]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select hostname from cfg_network where serial='${ALX_SERIAL}'")  
   
  all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select hostname,  
  module,  
  domain,  
  networking,  
  ip,  
  netmask,  
  dns,  
  gateway,  
  broadcast  
  from cfg_network where serial='${ALX_SERIAL}'")  
   
  #split'em up and put in an array  
  declare -i i=0  
  for x in ${all}  
  do  
  DB_NETWORK[${i}]=${x}  
  ((i++))  
  done  
   
  #needed by the small hotfix  
  local FIX_ME  
  FIX_ME="${DB_NETWORK[2]}"  
   
   
  #now compare this stuff if they are equal  
  for ((i=0; i < 9; i++))  
  do  
  if [ "${DB_NETWORK[${i}]}" = "${LOCAL_NETWORK[${i}]}" ]  
  then  
  echo "${i}: ${DB_NETWORK[${i}]} == ${LOCAL_NETWORK[${i}]}"  
   
  #delete equal stuff from DB_NETWORK  
  DB_NETWORK[${i}]="*NULL*"  
   
  else  
  echo "${i}: ${DB_NETWORK[${i}]} != ${LOCAL_NETWORK[${i}]}"  
  fi  
  done  
   
   
  #update configs  
  SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
  declare -i i=0  
  for x in network/hostname \  
  modules/modules \  
  network/domain \  
  network/networking \  
  network/ip \  
  network/netmask \  
  network/dns \  
  network/gateway \  
  network/broadcast  
  do  
  #update only staff wich wasn't overwritten  
  if [ "${DB_NETWORK[${i}]}" != "*NULL*" ]  
  then  
  #create directory if not exist  
  if [ ! -d $(dirname ${SETTINGSPATH}/${x}) ]  
  then  
  install -d $(dirname ${SETTINGSPATH}/${x})  
  fi  
  echo "${DB_NETWORK[${i}]}" > ${SETTINGSPATH}/${x}  
   
  # theses fucking config functions:  
  # network gets only updated,  
  # if ${SETTINGS_TEMPLATE}/menu/network/networking exist  
  # so we force an update here  
  if [ ! -f ${SETTINGSPATH}/network/networking ]  
  then  
  [ ! -d ${SETTINGSPATH}/network ] && install -d ${SETTINGSPATH}/network  
  echo "${FIX_ME}" > ${SETTINGSPATH}/network/networking  
  fi  
62    
63   #set update flag   # install or uninstall plugins
64   ALX_NETWORK_SETUP=true   config_plugins
  fi  
  ((i++))  
  done  
 }  
65    
66     # imports network settings from db
67     config_networking
68    
69     # imports x11 settings from db
70     config_x11
71    
72  validate_xserver(){   # imports session settings from db
73   #source /opt/alx-config/Configurator/config_functions.sh   config_sessions
   
  local x i all LOCAL_XSERVER DB_XSERVER SETTINGSPATH  
74    
75   #all arrays:   # imports printer settings from db
76   # ->  xmodule resolution depth mouse monvendor monmodel hsync vref   config_printing
77    
78    #xserver   # imports auth settings from db
79   #get settings from local system   config_auth
  #vga  
  SETTINGSPATH=${SETTINGS_TEMPLATE}/system  
  declare -i i=0  
  for x in vga/vga \  
  vga/vgares \  
  vga/vgadepth  
  do  
  if [ -f ${SETTINGSPATH}/${x} ]  
  then  
  #file exist, then use content  
  LOCAL_XSERVER[${i}]="$(< ${SETTINGSPATH}/${x})"  
  else  
  LOCAL_XSERVER[${i}]=""  
  fi  
  ((i++))  
  done  
   
  #mouse  
  if [ -f ${SETTINGSPATH}/mouse/mouse ]  
  then  
  #file exist, then use content  
  LOCAL_XSERVER[3]="$(< ${SETTINGSPATH}/mouse/mouse)"  
  else  
  LOCAL_XSERVER[3]=""  
  fi  
   
  #monitor  
  local myvendor mymodel hsync vref  
  if [ -f ${SETTINGSPATH}/monitor/monitor ]  
  then  
  source ${SETTINGSPATH}/monitor/monitor  
   
  declare -i i=4  
  for x in "${myvendor}" \  
  "${mymodel}" \  
  "${hsync}" \  
  "${vref}"  
  do  
  LOCAL_XSERVER[${i}]="${x}"  
  ((i++))  
  done  
  else  
  LOCAL_XSERVER[4]=""  
  LOCAL_XSERVER[5]=""  
  LOCAL_XSERVER[6]=""  
  LOCAL_XSERVER[7]=""  
  fi  
   
   
  #get settings from database  
  all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select module,  
  resolution,  
  depth  
  from cfg_graphic where serial='${ALX_SERIAL}'")  
   
  #split'em up and put in an array  
  declare -i i=0  
  for x in ${all}  
  do  
  DB_XSERVER[${i}]=${x}  
  ((i++))  
  done  
   
  # read mouse  
  DB_XSERVER[3]=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select mouse from cfg_input where serial='${ALX_SERIAL}'")  
   
  #monitors  
 # all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select vendor,  
 # model,  
 # hsync,  
 # vrefresh  
 # from cfg_monitor where serial='${ALX_SERIAL}'")  
   
  all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
         "select vendor,  
  model,  
  hsync,  
  vrefresh  
  from list_monitors  
  inner join cfg_graphic  
  on cfg_graphic.monitorid=list_monitors.id;")  
   
  #split'em up and put in an array  
  declare -i i=4  
  for x in ${all}  
  do  
  DB_XSERVER[${i}]=${x}  
  ((i++))  
  done  
   
 # #now compare this stuff if they are equal  
 # for ((i=0; i < 8; i++))  
 # do  
 # if [ "${DB_XSERVER[${i}]}" = "${LOCAL_XSERVER[${i}]}" ]  
 # then  
 # echo "${i}: ${DB_XSERVER[${i}]} == ${LOCAL_XSERVER[${i}]}"  
 #  
 # #delete equal stuff from DB_NETWORK  
 # DB_XSERVER[${i}]="*NULL*"  
 #  
 # else  
 # echo "${i}: ${DB_XSERVER[${i}]} != ${LOCAL_XSERVER[${i}]}"  
 # fi  
 # done  
 #  
 #  
 # #update configs  
 # SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
 # #xserver general  
 # declare -i i=0  
 # for x in vga/vga \  
 # vga/vgares \  
 # vga/vgadepth \  
 # mouse/mouse  
 # do  
 # #update only staff wich wasn't overwritten  
 # if [ "${DB_XSERVER[${i}]}" != "*NULL*" ]  
 # then  
 # #create directory if not exist  
 # if [ ! -d $(dirname ${SETTINGSPATH}/${x}) ]  
 # then  
 # install -d $(dirname ${SETTINGSPATH}/${x})  
 # fi  
 # echo "${DB_XSERVER[${i}]}" > ${SETTINGSPATH}/${x}  
 # #set update flag  
 # ALX_XSERVER_SETUP=true  
 # fi  
 # ((i++))  
 # done  
 #  
 # #xserver monitors  
 # if [ "${DB_XSERVER[4]}" != "*NULL*" \  
 # -o "${DB_XSERVER[5]}" != "*NULL*" \  
 # -o "${DB_XSERVER[6]}" != "*NULL*" \  
 # -o "${DB_XSERVER[7]}" != "*NULL*" ]  
 # then  
 # if [ ! -d ${SETTINGSPATH}/monitor ]  
 # then  
 # install -d ${SETTINGSPATH}/monitor  
 # fi  
 # echo "myvendor=\"${DB_XSERVER[4]}\"" > ${SETTINGSPATH}/monitor/monitor  
 # echo "mymodel=\"${DB_XSERVER[5]}\"" >> ${SETTINGSPATH}/monitor/monitor  
 # echo "hsync=\"${DB_XSERVER[6]}\"" >> ${SETTINGSPATH}/monitor/monitor  
 # echo "vref=\"${DB_XSERVER[7]}\"" >> ${SETTINGSPATH}/monitor/monitor  
 #  
 # #set update flag  
 # ALX_XSERVER_SETUP=true  
 # fi  
   
  # - damn fucking setup_xfree routine need to rewrite this fucking stuff -  
  # setup_xfree will only run  
  # if ${SETTINGS_TEMPLATE}/menu/vga/vga exist  
  # so we must *always* update *all* settings if something has changed  
80    
81   #now compare this stuff if they are equal   # exchange ssh rsa keys
82   for ((i=0; i < 8; i++))   HOME=/root config_ssh_auth
  do  
  if [ "${DB_XSERVER[${i}]}" = "${LOCAL_XSERVER[${i}]}" ]  
  then  
  echo "${i}: ${DB_XSERVER[${i}]} == ${LOCAL_XSERVER[${i}]}"  
   
  #delete equal stuff from DB_NETWORK  
  #DB_XSERVER[${i}]="*NULL*"  
   
  else  
  echo "${i}: ${DB_XSERVER[${i}]} != ${LOCAL_XSERVER[${i}]}"  
  fi  
  done  
83    
84   SETTINGSPATH=${SETTINGS_TEMPLATE}/menu   # import version info
85   if [ "${DB_XSERVER[0]}" != "*NULL*" \   config_version
  -o "${DB_XSERVER[1]}" != "*NULL*" \  
  -o "${DB_XSERVER[2]}" != "*NULL*" \  
  -o "${DB_XSERVER[3]}" != "*NULL*" \  
  -o "${DB_XSERVER[4]}" != "*NULL*" \  
  -o "${DB_XSERVER[5]}" != "*NULL*" \  
  -o "${DB_XSERVER[6]}" != "*NULL*" \  
  -o "${DB_XSERVER[7]}" != "*NULL*" ]  
  then  
  [ ! -d ${SETTINGSPATH}/vga ] && install -d ${SETTINGSPATH}/vga  
  [ ! -d ${SETTINGSPATH}/mouse ] && install -d ${SETTINGSPATH}/mouse  
  [ ! -d ${SETTINGSPATH}/monitor ] && install -d ${SETTINGSPATH}/monitor  
   
  echo "${DB_XSERVER[0]}" > ${SETTINGSPATH}/vga/vga  
  echo "${DB_XSERVER[1]}" > ${SETTINGSPATH}/vga/vgares  
  echo "${DB_XSERVER[2]}" > ${SETTINGSPATH}/vga/vgadepth  
  echo "${DB_XSERVER[3]}" > ${SETTINGSPATH}/mouse/mouse  
   
  echo "myvendor=\"${DB_XSERVER[4]}\"" > ${SETTINGSPATH}/monitor/monitor  
  echo "mymodel=\"${DB_XSERVER[5]}\"" >> ${SETTINGSPATH}/monitor/monitor  
  echo "hsync=\"${DB_XSERVER[6]}\"" >> ${SETTINGSPATH}/monitor/monitor  
  echo "vref=\"${DB_XSERVER[7]}\"" >> ${SETTINGSPATH}/monitor/monitor  
   
  #set update flag  
  ALX_XSERVER_SETUP=true  
  fi  
86  }  }
87    
88    get_system_serial()
89    {
90     local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE
91    
92  validate_sessions(){   if [[ ${ALX_CONFD_NETWORKING} = true ]]
  #source /opt/alx-config/Configurator/config_functions.sh  
   
  local x i all LOCAL_SESSIONS DB_SESSIONS SETTINGSPATH count  
   
  #all arrays:  
  # ->  session1 session2 ... sessionN  
   
   
  #no LOCAL_SESSIONS here, needs bubblesort  
   
  #get settings from database  
  all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select session from cfg_sessions where serial='${ALX_SERIAL}'")  
   
  #split'em up and put in an array (only if $all not zero)  
  declare -i i=0  
  if [ -n "${all}" ]  
93   then   then
94   for x in ${all}   ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)"
  do  
  DB_SESSIONS[${i}]=${x}  
  ((i++))  
  done  
  count=${i}  
95   else   else
96   count=0   ALX_IFACE="eth0"
97   fi   fi
   
  ## no compare here, can only done with bubblesort or s.th like that  
  # shows only the new sessions  
  declare -i i=0  
  #count=${#DB_SESSIONS[*]} #---> not working gets always 1, why ?  
   
  echo "Number of new sessions: ${count}"  
  for ((i=0; i < count; i++))  
  do  
  echo "${i} - ${DB_SESSIONS[${i}]}"  
  done  
   
  #update local configs  
  SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
  declare -i i=0  
   
  #count=${#DB_SESSIONS[*]}  
   
  if [ ${count} -gt 0 ]  
  then  
  #create directory if not exist  
  [ ! -d ${SETTINGSPATH}/sessions ] && install -d ${SETTINGSPATH}/sessions  
   
  #delete old sessions  
  echo -n > ${SETTINGSPATH}/sessions/sessions  
   
  for ((i=0; i < count; i++))  
  do  
  echo "${DB_SESSIONS[${i}]}" >> ${SETTINGSPATH}/sessions/sessions  
  done  
   
  #set update flag  
  ALX_SESSION_SETUP=true  
  fi  
 }  
   
   
 validate_printing(){  
  #source /opt/alx-config/Configurator/config_functions.sh  
98    
99   local x i k all LOCAL_PRINTER DB_PRINTER SETTINGSPATH count   # check if serial file exists
100     if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]
  #all arrays: [2 dimensions !]  
  # ->  name1 name2 ... nameN  
  # ->  name1 printingport ip share  
   
  #later on, for now -> name1 port1 ip1 share1 name2 ....  
  # seperator is 4  
   
  #local PRINTERNAME PRINTING IP SHARE  
   
  # update *always* printers from database;  
  # compare with local settings cannot be done yet  
   
  #get settings from database  
  all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select printer_name,  
  port,  
  ip,  
  share  
  from cfg_printers where serial='${ALX_SERIAL}'")  
   
  #split'em up and put in an array  
  declare -i i=0  
  declare -i k=0  
   
  if [ -n "${all}" ]  
101   then   then
102   for x in ${all}   source /etc/alxconfig-ng/serial
  do  
  ((k++))  
  DB_PRINTER[${i}]="${DB_PRINTER[${i}]} ${x}"  
  if [ ${k} -eq 4 ]  
  then  
  ((i++))  
  #reset $k  
  declare -i k=0  
  fi  
  done  
  count=${i}  
  else  
  count=0  
  fi  
   
  #echo settings  
  echo "Number of new printers: ${count}"  
  for ((i=0; i < count; i++))  
  do  
  echo "${i} printer:"  
  for x in ${DB_PRINTER[${i}]}  
  do  
  echo "    ${x}"  
  done  
  done  
   
  #import settings (only if counter > 0)  
  local prnset  
   
  #delete all printers (*always*)  
  if [ -d ${SETTINGS_TEMPLATE}/system/printing ]  
  then  
  SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
  [ -d ${SETTINGSPATH}/delete ] && rm -rf ${SETTINGSPATH}/delete  
  install -d ${SETTINGSPATH}/delete  
  mv -f ${SETTINGS_TEMPLATE}/system/printing/* ${SETTINGSPATH}/delete  
  rm -rf ${SETTINGS_TEMPLATE}/system/printing  
   
  #set update flag (*always*)  
  ALX_PRINTER_SETUP=true  
  fi  
   
  if [ ${count} -gt 0 ]  
  then  
  SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
   
  [ ! -d ${SETTINGSPATH}/printing ] && install -d ${SETTINGSPATH}/printing  
  for ((i=0; i < count; i++))  
  do  
  declare -i k=0  
  for x in ${DB_PRINTER[${i}]}  
  do  
  prnset[${k}]=${x}  
  ((k++))  
  done  
   
  echo "PRINTERNAME=${prnset[0]}" >  ${SETTINGSPATH}/printing/${prnset[0]}  
  echo "PRINTING=${prnset[1]}" >> ${SETTINGSPATH}/printing/${prnset[0]}  
  echo "IP=${prnset[2]}" >> ${SETTINGSPATH}/printing/${prnset[0]}  
  echo "SHARE=${prnset[3]}" >> ${SETTINGSPATH}/printing/${prnset[0]}  
  done  
   
  #set update flag (*always*)  
  ALX_PRINTER_SETUP=true  
  fi  
   
 }  
103    
104  update_system_settings(){   # start preliminary networking (dhcp)
105   source /opt/alx-config/Configurator/config_functions.sh   preliminary_network start
106    
107   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}   # check if mysql server is reachable
108     # if not abort this script
109   echo   if ! reach_mysql_server
110   echo "network"   then
111   validate_networking   preliminary_network stop
112   echo   exit 1
113   echo "xserver"   fi
  validate_xserver  
  echo  
  echo "sessions"  
  validate_sessions  
  echo  
  #echo "printers"  
  #validate_printing  
  #echo  
   
  if [ "${ALX_NETWORK_SETUP}" == "true" ]  
  then  
  echo -e ${COLMAGENTA}"Updating network settings"${COLDEFAULT}  
  setup_modules  
  setup_network  
  fi  
   
  if [ "${ALX_XSERVER_SETUP}" == "true" ]  
  then  
  echo -e ${COLMAGENTA}"Updating xserver settings"${COLDEFAULT}  
  setup_xfree  
  fi  
   
  if [ "${ALX_SESSION_SETUP}" == "true" ]  
  then  
  echo -e ${COLMAGENTA}"Updating session settings"${COLDEFAULT}  
  setup_sessions  
  fi  
   
  #if [ "${ALX_PRINTER_SETUP}" == "true" ]  
  #then  
  # echo -e ${COLMAGENTA}"Updating printer settings"${COLDEFAULT}  
  # setup_printers  
  #fi  
   
  #clean up temp files  
  local SETTINGSPATH  
  SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
  #[ -d ${SETTINGSPATH} ] && rm -rf ${SETTINGSPATH}  
 }  
114    
115  get_system_serial(){   CUR_IP=$(ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
116     CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
117     CUR_MTIME=$(date +%s)
118    
119   local CUR_IP CUR_MAC CUR_MTIME   rc_print "Trying to validate my serial ..."
120    
121   #check if serial file exists   # nice serial output
  if [ -f /etc/alx-config/serial ]  
  then  
  source /etc/alx-config/serial  
   
  # if system is already configured, it *has* a hostname.  
  # so we take the hostname of this system here  
  source /etc/hostname  
   
  #start preliminary networking (dhcp)  
  preliminary_network start  
   
  CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')  
  CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)  
  CUR_MTIME=$(date +%s)  
   
  echo -e ${COLOREDSTAR} "Trying to validate my serial ..."  
   
  #nice serial output  
122   $CURS_UP   $CURS_UP
123   $SET_WCOL   $SET_WCOL
124   echo "[ SN: ${ALX_SERIAL} ]"   echo "[ SN: ${ALX_SERIAL} ]"
   
 # #is this system outdated ?  
 # #MY_HOSTNAME=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # # "select hostname from cfg_serial where id='${ALX_SERIAL}'")  
 #  
 # #we do this now with the date instead of the hostname  
 # local MY_ALX_REG_DATE  
 # MY_ALX_REG_DATE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
 # "select mtime from client_serial where serial='${ALX_SERIAL}'")  
 #  
 # #if [ "${MY_HOSTNAME}" == "${HOSTNAME}" ]  
 # if [ "${MY_ALX_REG_DATE}" == "${ALX_REG_DATE}" ]  
 # then  
 # #set ALX_STATE to ok so everybody that everything was ok  
 # ALX_STATE=ok  
 #  
 # evaluate_retval  
 # else  
 # #print false (works only if this is the first statement here)  
 # evaluate_retval  
 #  
 # #set ALX_STATE to error so everybody sees there was an error  
 # ALX_STATE=error  
 # fi  
125    
126   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"
127   then   then
128   ALX_STATE="ok"   ALX_STATE="ok"
129   else   else
130     # abort on non valid serial
131   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
132     echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
133     show_invalid_serial_msg
134     exit 1
135   fi   fi
136    
137   else   else
138   #run hardware detection   # run hardware detection
139   echo   echo
140   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}   if [[ ${ALX_FORCED_RECHECK} = true ]]
141     then
142     rc_mecho "Hardware autodetection forced by system-administrator"
143     # always disable CONFD_NETWORKING here
144     export ALX_CONFD_NETWORKING="false"
145     else
146     rc_mecho "Preparing system for first boot"
147     fi
148   ALX_HW_DETECT=true   ALX_HW_DETECT=true
149   /etc/init.d/hwdetect start   hwsetup
150    
151   #set hostname to alx_default_hostname   # set hostname to alx_default_hostname
152     # use old hostname if this is a forced re-check
153     [[ ${ALX_FORCED_RECHECK} = true ]] && ALX_DEFAULT_HOSTNAME="$(< /etc/hostname)"
154   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
155   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"
156    
157   #update the hostname on the system for sure   # update the hostname on the system for sure
158   echo "HOSTNAME=${HOSTNAME}" > /etc/hostname   echo "${HOSTNAME}" > /etc/hostname
159    
160   #start preliminary networking (dhcp)   # start preliminary networking (dhcp)
161   preliminary_network start   preliminary_network start
162    
163   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   # check if mysql server is reachable
164   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   # if not abort this script
165     if ! reach_mysql_server
166     then
167     preliminary_network stop
168     exit 1
169     fi
170    
171    
172     CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
173     CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
174   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
   
  echo -e ${COLOREDSTAR} "Trying to get new serial ..."  
   
  #request new serial  
  #ALX_REG_DATE="$(date +%F)"  
   
  #we're using the mtime now (better for vaildating 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 then one serial number than                       ###  
   
  #not 100% working may get more than *one* id  
  #ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  # "select id from cfg_serial where datum='${ALX_REG_DATE}' and hostname='${HOSTNAME}'")  
   
  #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}'")  
175    
176   if [ "${ALX_SERIAL}" != NULL ]   # abort now if this is a forced re-check
177     if [[ ${ALX_FORCED_RECHECK} = true ]]
178   then   then
179   #nice serial output   # but first check the serial
180     source /etc/alxconfig-ng/serial
181    
182     rc_print "Trying to validate my serial ..."
183    
184     # nice serial output
185   $CURS_UP   $CURS_UP
186   $SET_WCOL   $SET_WCOL
187   echo "[ SN: ${ALX_SERIAL} ]"   echo "[ SN: ${ALX_SERIAL} ]"
188    
189   #set ALX_STATE to ok so everybody that everything was ok   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"
190     then
191     ALX_STATE="ok"
192     else
193     # abort on non valid serial
194     ALX_STATE="invalid serial"
195     echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state
196     show_invalid_serial_msg
197     exit 1
198     fi
199    
200     # write current state to temp file
201     echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
202     [ -f /hardware-auto-detection ] && rm /hardware-auto-detection
203    
204     # now export ALX_FORCED_RECHECK=true
205     # that the setting will be updated not inserted !
206     export ALX_FORCED_RECHECK=true
207     return 0
208     fi
209    
210     rc_print "Trying to get new serial ..."
211    
212     # request a new serial; one command now (cause must be done in the same session)
213     ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');
214     select last_insert_id();")
215    
216     if [[ ${ALX_SERIAL} != NULL ]]
217     then
218     # nice serial output
219     $CURS_UP
220     $SET_WCOL
221     echo "[ SN: ${ALX_SERIAL} ]"
222    
223     # set ALX_STATE to ok so everybody knows that everything was ok
224   ALX_STATE=ok   ALX_STATE=ok
225    
226   echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alx-config/serial   echo "ALX_SERIAL=\"${ALX_SERIAL}\"" > /etc/alxconfig-ng/serial
227   echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alx-config/serial   echo "ALX_REG_DATE=\"${CUR_MTIME}\"" >> /etc/alxconfig-ng/serial
228    
229   evaluate_retval   evaluate_retval
230   else   else
231   #print false (works only if this is the first statement here)   # print false (works only if this is the first statement here)
232   evaluate_retval   evaluate_retval
233    
234   #set ALX_STATE to error so everybody sees there was an error   # set ALX_STATE to error so everybody sees there was an error
235   ALX_STATE=error   ALX_STATE=error
236    
237   #show an error that no new serial was found   # show an error that no new serial was found
238   #nice serial output   # nice serial output
239   $CURS_UP   $CURS_UP
240   $SET_WCOL   $SET_WCOL
241   echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]"   echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]"
242   fi   fi
243   fi   fi
244    
245   #write current state to temp file   # write current state to temp file
246   echo "ALX_STATE=${ALX_STATE}" > /etc/alx-config/state/state   echo "ALX_STATE=\"${ALX_STATE}\"" > /etc/alxconfig-ng/state/state
247     echo "ALX_IFACE=\"${ALX_IFACE}\"" >> /etc/alxconfig-ng/state/state
248  }  }
249    
250    
251  check_is_configured() {  check_is_configured()
252   if [ -f /etc/alx-config/state/configured ]  {
253     if [ -f /etc/alxconfig-ng/state/configured ]
254   then   then
255   export ALX_CONFIGURED=true   export ALX_CONFIGURED=true
256   else   else
# Line 927  check_is_configured() { Line 260  check_is_configured() {
260    
261    
262  # imports current settings to the database resolved by the hardware detection  # imports current settings to the database resolved by the hardware detection
263  import_settings_to_db() {  import_settings_to_db()
264   #note: networking is always 'dhcp' if hw was autodetected  {
265   #note: default_domain/hostname is set in config.rc   # note: networking is always 'dhcp' if hw was autodetected
266     # note: default_domain/hostname is set in config.rc
267   #to be safe, we do some sanity checks  
268     # to be safe, we do some sanity checks
269   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
270   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
271    
272   #vars used by hwdetect   # vars used by hwsetup
273   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
274   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
275   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
276    
277   #get setting from hwdetect   # get setting from hwsetup
278   source /etc/sysconfig/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
279   source /etc/sysconfig/hwsetup/mouse   source /etc/conf.d/hwsetup/mouse
280    
281   echo   echo
282   echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT}   rc_mecho "Importing detected settings to database"
283    
284   #network   # network
285   echo -e "      Network settings ..."   rc_mecho "      Network settings ..."
286   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   if [[ ${ALX_CONFD_NETWORKING} = true ]]
287   "insert into cfg_network(   then
288   hostname,   # get settings
289   serial,   for iface in $(onboot_interface_list ${network_settings}/net.*)
290   module,   do
291   domain,   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
292   networking   rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
293   )   source ${network_settings}/net.${iface} || echo "Error: could not read '${network_settings}/net.${iface}'"
294   values(   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
295   '${ALX_DEFAULT_HOSTNAME}',  
296   '${ALX_SERIAL}',   mysqldo "insert into cfg_network(
297   '${NETCARD_DRIVER}',   hostname,
298   '${ALX_DEFAULT_DOMAIN}',   serial,
299   'dhcp'   module,
300   );"   domain,
301     networking,
302     netmask,
303     dns,
304     gateway,
305     broadcast,
306     ip,
307     forcemacto,
308     wireless_bitrate,
309     wireless_channel,
310     wireless_essid,
311     wireless_frequency,
312     wireless_mode,
313     wireless_nick,
314     wireless_auth_mode,
315     wireless_key_length,
316     wireless_key,
317     wireless_key_ascii
318     )
319     values(
320     '${ALX_DEFAULT_HOSTNAME}',
321     '${ALX_SERIAL}',
322     '${NETCARD_DRIVER}',
323     '${ALX_DEFAULT_DOMAIN}',
324     '${NETWORKING}',
325     '${NETMASK}',
326     '${NAMESERVER}',
327     '${GATEWAY}',
328     '${BROADCAST}',
329     '${IP}',
330     '${FORCE_MAC_TO}',
331     '${WIRELESS_BITRATE}',
332     '${WIRELESS_CHANNEL}',
333     '${WIRELESS_ESSID}',
334     '${WIRELESS_FREQUENCY}',
335     '${WIRELESS_MODE}',
336     '${WIRELESS_NICK}',
337     '${WIRELESS_AUTH_MODE}',
338     '${WIRELESS_KEY_LENGTH}',
339     '${WIRELESS_KEY}',
340     '${WIRELESS_KEY_ASCII}'
341     );"
342    
343     # only insert the *FIRST* iface
344     break
345     done
346     else
347     mysqldo "insert into cfg_network(
348     hostname,
349     serial,
350     module,
351     domain,
352     networking
353     )
354     values(
355     '${ALX_DEFAULT_HOSTNAME}',
356     '${ALX_SERIAL}',
357     '${NETCARD_DRIVER}',
358     '${ALX_DEFAULT_DOMAIN}',
359     'dhcp'
360     );"
361     fi
362   evaluate_retval   evaluate_retval
363    
364   #xserver   # xserver
365   echo -e "      Graphic settings ..."   rc_mecho "      Graphic settings ..."
366   #xserver general   # xserver general
367   ( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ( mysqldo "insert into cfg_graphic(
  "insert into cfg_graphic(  
368   serial,   serial,
369   module,   module,
370   resolution,   resolution,
371   depth   depth,
372     refresh_rate
373   )   )
374   values(   values(
375   '${ALX_SERIAL}',   '${ALX_SERIAL}',
376   '${XMODULE}',   '${XMODULE}',
377   '1024x768',   '1024x768',
378   '16'   '16',
379   );";   '60'
380   #xserver monitor   );"; )
381    mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   evaluate_retval
382   "insert into cfg_monitor(  
383     # input
384     rc_mecho "      Input settings ..."
385     mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"
386     evaluate_retval
387    
388     # auth
389     rc_mecho "      Authentification settings ..."
390     mysqldo "insert into client_auth(
391   serial,   serial,
392   vendor,   username,
393   model,   shell,
394   hsync,   vnc,
395   vrefresh   samba,
396     station
397   )   )
398   values(   values(
399   '${ALX_SERIAL}',   '${ALX_SERIAL}',
400   'Aamazing',   '${ALX_UNPRIV_USER}',
401   'CM-1528-FS',   '',
402   '28-64',   '',
403   '47-104'   '',
404   );";   ''
405     );"
406   # input   evaluate_retval
407    mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
408   "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";)   # exchange ssh rsa keys - the first boot needs this !
409     # or no reboot will work via the webadmin
410     rc_mecho "      SSH authentification settings ..."
411     HOME=/root config_ssh_auth
412     evaluate_retval
413    
414     # autostart
415     rc_mecho "      Autostart settings ..."
416     mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
417    
418     # screensaver
419     rc_mecho "      Screensaver settings ..."
420     mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"
421    
422     # version info
423     rc_mecho "      OS version info ..."
424     local alx_os
425     local alx_utils
426     alx_os="$(< /etc/mageversion)"
427     alx_utils="$(magequery -n alxconfig-ng | sed 's:.*\[\ \(.*\)\ \].*:\1:')"
428     alx_utils="${alx_utils/alxconfig-ng-}"
429     mysqldo "insert into client_version(serial,os,utils) values('${ALX_SERIAL}','${alx_os}','${alx_utils}')"
430    
431   evaluate_retval   evaluate_retval
432  }  }
433    
434  # imports current settings to the local system resolved by the hardware detection  # imports current settings to the database resolved by the hardware detection
435  import_settings_local(){  update_settings_in_db()
436   #note: networking is always 'dhcp' if hw was autodetected  {
437   #note: default_domain/hostname is set in config.rc   # note: networking is always 'dhcp' if hw was autodetected
438     # note: default_domain/hostname is set in config.rc or exported
439   #to be safe, we do some sanity checks   # note: we updating only hardware settings here !
440    
441     # to be safe, we do some sanity checks
442   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
443   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
444    
445   #vars used by hwdetect   # vars used by hwsetup
446   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
447   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
448   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
449    
450     # get setting from hwsetup
451   #get setting from hwdetect   source /etc/conf.d/hwsetup/knoppix
452   source /etc/sysconfig/hwsetup/knoppix   source /etc/conf.d/hwsetup/mouse
453   source /etc/sysconfig/hwsetup/mouse  
   
454   echo   echo
455   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}   rc_mecho "Updating detected settings in database"
456    
457     # network
458   #allready configured, no update needed so we put it to system   rc_mecho "      Network settings ..."
459   SETTINGSPATH=${SETTINGS_TEMPLATE}/system   if [[ ${ALX_CONFD_NETWORKING} = true ]]
460     then
461     # get settings
462   #network   #source ${rc_base}/init.d/network &> /dev/null
463   echo -e "      Network settings ..."   for iface in $(onboot_interface_list ${network_settings}/net.*)
464     do
465     [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
466     rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
467     source ${network_settings}/net.${iface} || exit 1
468     NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
469    
470     mysqldo "update cfg_network set
471     hostname='${ALX_DEFAULT_HOSTNAME}',
472     module='${NETCARD_DRIVER}',
473     domain='${ALX_DEFAULT_DOMAIN}',
474     networking='${NETWORKING}',
475     netmask='${NETMASK}',
476     dns='${NAMESERVER}',
477     gateway='${GATEWAY}',
478     broadcast='${BROADCAST}',
479     ip='${IP}',
480     forcemacto='${FORCE_MAC_TO}',
481     wireless_bitrate='${WIRELESS_BITRATE}',
482     wireless_channel='${WIRELESS_CHANNEL}',
483     wireless_essid='${WIRELESS_ESSID}',
484     wireless_frequency='${WIRELESS_FREQUENCY}',
485     wireless_mode='${WIRELESS_MODE}',
486     wireless_nick='${WIRELESS_NICK}',
487     wireless_auth_mode='${WIRELESS_AUTH_MODE}',
488     wireless_key_length='${WIRELESS_KEY_LENGTH}',
489     wireless_key='${WIRELESS_KEY}',
490     wireless_key_ascii='${WIRELESS_KEY_ASCII}'
491     where serial=${ALX_SERIAL};"
492    
493   [ ! -d ${SETTINGSPATH}/modules ] && install -d ${SETTINGSPATH}/modules   # only insert the *FIRST* iface
494   echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules/modules   break
495     done
496   [ ! -d ${SETTINGSPATH}/network ] && install -d ${SETTINGSPATH}/network   else
497   ( echo "${ALX_DEFAULT_HOSTNAME}" > ${SETTINGSPATH}/network/hostname;   mysqldo "update cfg_network set
498    echo "${ALX_DEFAULT_DOMAIN}" > ${SETTINGSPATH}/network/domain;   hostname='${ALX_DEFAULT_HOSTNAME}',
499    echo "dhcp" > ${SETTINGSPATH}/network/networking )   module='${NETCARD_DRIVER}',
500     domain='${ALX_DEFAULT_DOMAIN}',
501     networking='dhcp'
502     where serial=${ALX_SERIAL};"
503     fi
504   evaluate_retval   evaluate_retval
505    
506     # xserver
507   #xserver   rc_mecho "      Graphic settings ..."
508   echo -e "      Graphic settings ..."   # xserver general
509     mysqldo "update cfg_graphic set
510   [ ! -d ${SETTINGSPATH}/vga ] && install -d ${SETTINGSPATH}/vga   module='${XMODULE}',
511   [ ! -d ${SETTINGSPATH}/mouse ] && install -d ${SETTINGSPATH}/mouse   resolution='1024x768',
512   [ ! -d ${SETTINGSPATH}/monitor ] && install -d ${SETTINGSPATH}/monitor   depth='16',
513   ( echo "${XMODULE}" > ${SETTINGSPATH}/vga/vga;   refresh_rate='60'
514    echo "16" > ${SETTINGSPATH}/vga/vgadepth;   where serial=${ALX_SERIAL};"
   echo "1024x768" > ${SETTINGSPATH}/vga/vgares;  
   echo "${XMOUSETYPE}" > ${SETTINGSPATH}/mouse/mouse;  
   echo "myvendor=\"Aamazing\"" > ${SETTINGSPATH}/monitor/monitor;  
   echo "mymodel=\"CM-1528-FS\"" >> ${SETTINGSPATH}/monitor/monitor;  
   echo "hsync=\"28-64\"" >> ${SETTINGSPATH}/monitor/monitor;  
   echo "vref=\"47-104\"" >> ${SETTINGSPATH}/monitor/monitor;)  
515   evaluate_retval   evaluate_retval
516    
517   #set system state to 'already configured'   # input
518   touch /etc/alx-config/state/configured   rc_mecho "      Input settings ..."
519     mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"
520     evaluate_retval
521    
522     # version info
523     rc_mecho "      OS version info ..."
524     local alx_os
525     local alx_utils
526     alx_os="$(< /etc/mageversion)"
527     alx_utils="$(magequery -n alxconfig-ng-alx | sed 's:.*\[\ \(.*\)\ \].*:\1:')"
528     alx_utils="${alx_utils/alxconfig-ng-alx-}"
529     mysqldo "update client_version set os='${alx_os}', utils='${alx_utils}' where serial=${ALX_SERIAL};"
530    }
531    
532    # imports current settings to the local system resolved by the hardware detection
533    # we only need the network settings
534    import_settings_local()
535    {
536     # note: networking is always 'dhcp' if hw was autodetected
537     # note: default_domain/hostname is set in config.rc
538    
539     # to be safe, we do some sanity checks
540     [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
541     [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
542    
543     # vars used by hwsetup
544     local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
545     local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
546     local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
547    
548     # get setting from hwsetup
549     source /etc/conf.d/hwsetup/knoppix
550    
551     echo
552     rc_mecho "Importing detected settings to local system"
553    
554     if [[ ${ALX_CONFD_NETWORKING} = false ]]
555     then
556     # set an device alias for modprobe.conf
557     [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d
558     # update only if not the same (to speed up bootprocess - no depmod)
559     CONFIG="/etc/modprobe.d/net.${ALX_IFACE}.conf"
560     clearconfig
561     addconfig "alias ${ALX_IFACE} ${cfg_network_module}"
562    
563     # update confd-networking default iface
564     [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}
565     CONFIG="${SETTINGSPATH}/confd-networking"
566     clearconfig
567     addconfig "${ALX_IFACE}"
568    
569     # regenerate modprobe.conf
570     [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!"
571     evaluate_retval
572     fi
573    
574     # set system state to 'already configured'
575     touch /etc/alxconfig-ng/state/configured
576    
577     # install slim desktopmanager configuration
578     config_display_manager
579    
580     # if only an recheck was forced than abort now
581     [[ ${ALX_FORCED_RECHECK} = true ]] && return 0
582    
583     # create a fresh fluxbox directory
584     [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox
585     install -d ${ALX_UNPRIV_HOME}/.fluxbox
586    
587     # now generate fluxbox config files
588    
589     # fluxbox main config
590     local fbinit
591     if [ -f ${ALX_SKELETONS}/fluxbox/init ]
592     then
593     fbinit="${ALX_SKELETONS}/fluxbox/init"
594     else
595     fbinit="/usr/share/fluxbox/init"
596     fi
597     cat ${fbinit} > ${ALX_UNPRIV_HOME}/.fluxbox/init
598    
599     # fluxbox autostart
600     CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
601     # do not show decorations on messages generated with xmessage
602     if [ -x /usr/bin/xmessage ]
603     then
604     addconfig '[app] (xmessage)'
605     addconfig ' [Deco] {NONE}'
606     addconfig '[end]'
607     fi
608     # add icon utility
609     [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
610     # add numlock utility
611     [ -x /usr/bin/numlockx ] && addconfig '[startup] {nohup numlockx on &}'
612    
613     # fluxbox hotkeys
614     local fbkeys
615     if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
616     then
617     fbkeys="${ALX_SKELETONS}/fluxbox/keys"
618     else
619     fbkeys="/usr/share/fluxbox/keys"
620     fi
621     cat ${fbkeys} > ${ALX_UNPRIV_HOME}/.fluxbox/keys
622    
623     # fluxbox menu header
624     cat ${ALX_SKELETONS}/fluxbox/menu.header > ${ALX_UNPRIV_HOME}/.fluxbox/menu
625    
626     # now fix it with proper messages :P
627     local ver="$(< /etc/mageversion)"
628     sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" ${ALX_UNPRIV_HOME}/.fluxbox/menu
629    
630     # add a newline (maybe there is no crlf in the header)
631     echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
632    
633     # fluxbox menu footer
634     cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
635    
636     # add a newline (maybe there is no crlf in the footer)
637     echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
638    
639     # setup some standart icons (sysinfo.lnk)
640     # clean desktop icon location
641     [ -d ${ALX_UNPRIV_HOME}/.idesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.idesktop
642     install -d ${ALX_UNPRIV_HOME}/.idesktop
643    
644     # add shutdown, reboot icons
645     local name
646     # default settings
647     declare -i x=30
648     declare -i y=30
649     for i in shutdown reboot
650     do
651     case ${i} in
652     shutdown) name="Herunterfahren" ;;
653     reboot) name="Neustarten" ;;
654     esac
655    
656     generate_icon \
657     --name "${name}" \
658     --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \
659     --icon "${ALX_SESSIONS_ICONS}/${i}.png" \
660     --dest "${dest}/${i}.lnk" \
661     --xres "${x}" \
662     --yres "${y}"
663    
664     y=$((${y} + 80))
665     done
666    
667     # last but not least gen a icon with some sys informations
668     local sysinfo
669     local osversion
670     local xres
671     local yres
672    
673     osversion="$(< /etc/mageversion)"
674     sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
675    
676     # at first boot we got always a resolution of 1024x768-16@60
677     # middle of the screen
678     # (no txt - length required, xtdesk manage that itself)
679     xres="$((1024 / 2))"
680     # default y pos (full yres -22 !)
681     yres="$((768 - 22 ))"
682    
683     generate_icon \
684     --name "${sysinfo}" \
685     --command "exit 0" \
686     --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
687     --dest "${ALX_UNPRIV_HOME}/.idesktop/sysinfo.lnk" \
688     --xres "${xres}" \
689     --yres "${yres}" \
690     --icon-width "1" \
691     --icon-height "1"
692    
693     # set correct permissions
694     chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
695     chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
696     chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
697     chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop
698     if [ -f ${ALX_UNPRIV_HOME}/.ideskrc ]
699     then
700     chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc
701     fi
702  }  }
703    
704  #start|stop  # start|stop
705  preliminary_network(){  preliminary_network()
706    {
707   local module   local module
708    
709   if [ -f /etc/alx-config/state/configured ]   if [ -f /etc/alxconfig-ng/state/configured ]
710   then   then
711   #get module name   # compat for old clients
712   module=$(cat ${SETTINGS_TEMPLATE}/system/modules/modules)   if [ -f ${SETTINGSPATH}/modules ]
713   modprobe ${module}   then
714     # get module name
715     module=$(cat ${SETTINGSPATH}/modules)
716     modprobe ${module}
717     fi
718    
719   else   else
720   #vars used by hwdetect   # vars used by hwsetup
721   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
722   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
723    
724   #get setting from hwdetect   # get setting from hwsetup
725   source /etc/sysconfig/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
726   modprobe ${NETCARD_DRIVER}   modprobe ${NETCARD_DRIVER}
727   fi   fi
728    
729   case $1 in   case $1 in
730   start)   start)
731   # keeping like always safe:   # keeping like always safe:
732   # no network should be startet here,   # no network should be startet here,
733   # so we can delete all pid files if one exists   # so we can delete all pid files if one exists
734   if ps -A|grep dhcpcd > /dev/null   if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]]
735   then   then
736   echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT}   rc_mecho "Forcing network down"
737   dhcpcd -k   killall $(basename ${ALX_DHCP_PROG}) &> /dev/null
738   sleep 1   sleep 1
739     fi
740     [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop
741    
742     rc_mecho "Starting preliminary networking ... "
743    
744     # start network configured from /etc/conf.d
745     if [[ ${ALX_CONFD_NETWORKING} = true ]]
746     then
747     ${rc_base}/init.d/network start
748   else   else
749   rm -f /var/run/dhcpcd-eth?.pid   rc_print "Starting default dhcp based networking ... "
750     ${ALX_DHCP_PROG} ${ALX_DHCP_START} ${ALX_IFACE} &> /dev/null
751     evaluate_retval
752   fi   fi
   
  echo -e ${COLMAGENTA}"Starting preliminary network ... "${COLDEFAULT}  
  #dhcpcd &> /dev/null #&& echo "ok" || echo "false"  
   
  # 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  
  ##################################################  
  evaluate_retval  
753   ;;   ;;
754    
755   stop)   stop)
756   echo -e ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT}   rc_mecho "Stopping preliminary networking ... "
757   ifconfig eth0 down   if [[ ${ALX_CONFD_NETWORKING} = true ]]
758   if ps -A|grep dhcpcd > /dev/null   then
759     ${rc_base}/init.d/network stop
760     else
761     rc_print "Stopping default dhcp based networking ... "
762     ifconfig ${ALX_IFACE} down
763     fi
764     if [[ ! -z $(pidof $(basename ${ALX_DHCP_PROG})) ]]
765   then   then
766   #echo -en ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT}   killall $(basename ${ALX_DHCP_PROG}) &> /dev/null
767   dhcpcd -z  &> /dev/null   sleep 1
768   fi   fi
769   evaluate_retval   evaluate_retval
770   ;;   ;;
771    
772   *)   *)
773   echo "Usage: preliminary_network {start|stop}"   echo "Usage: preliminary_network {start|stop}"
774   ;;   ;;
775   esac   esac
776  }  }
777    
778    reset_system_settings()
779    {
780     # force load of de kbdkeys
781     loadkeys -q de
782     rc_echo
783     rc_echo -en ${COLRED}
784     rc_echo -n "*** Warning: you are about to reset *all* local settings on this system!"
785     rc_echo -e ${COLDEFAULT}
786     rc_echo "*** Do you really want to continue ?"
787     rc_echo -n "*** Enter 'yes' to continue, anything else to abort: "
788     read kbinsert
789     if [[ ${kbinsert} = yes ]]
790     then
791     rc_echo -en ${COLRED}
792     rc_echo -n "*** OK, you really want it ... killing all settings: "
793     for i in 3 2 1 now
794     do
795     rc_echo -n " ${i}"
796     sleep 1
797     done
798     rc_echo -e ${COLDEFAULT}
799    
800     ## reset all settings:
801     rm -rf ${SETTINGSPATH}/*
802     rm -f /etc/alxconfig-ng/serial
803     rm -rf /etc/alxconfig-ng/state
804    
805     # clear all printers & net-shares
806     :> /etc/printcap
807    
808     # remove lprng
809     rc-config del lprng &> /dev/null
810    
811     # remove all user settings
812     [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
813    
814     # remove all ica-sessions
815     find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm
816    
817     # remove all old nics and modules configs
818     find /etc/conf.d -type f -name 'net.*' | xargs rm
819     find /etc/modprobe.d -type f -name 'net.*' | xargs rm
820    
821     # restore default networking
822     cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0
823    
824     rc_echo "I am done now, press [Enter] to reboot system ..."
825     else
826     rc_echo "Aborted, press [Enter] to reboot system ..."
827     fi
828     read
829     reboot
830    }
831    
832    onboot_interface_list()
833    {
834     local file
835     local devices
836     local iface
837    
838     # get list of all devices
839     for file in $@
840     do
841     if [[ $(read_value ONBOOT ${file}) = yes ]]
842     then
843     iface="$(basename ${file} | sed s/net.//)"
844     # exclude backup files
845     case "${iface}" in
846     *~) ;;
847     *) devices="${devices} $(basename ${file} | sed s/net.//)" ;;
848     esac
849     fi
850     done
851    
852     echo "${devices}"
853    }
854    
855    # read values from net.* files
856    read_value()
857    {
858     local var="$1"
859     local file="$2"
860     local value
861    
862     # local all possible vars
863     # global
864     local ONBOOT
865     local NETWORKING
866    
867     # static
868     local IP
869     local NETMASK
870     local BROADCAST
871     local NETWORKING
872     local FORCE_MAC_TO
873    
874     # dhcp
875     local DHCP_PROG
876     local DHCP_START
877     local DHCP_STOP
878    
879     # default gw
880     local GATEWAY
881     local GATEWAY_IF
882    
883     # wireless extensions
884     local WIRELESS_AP
885     local WIRELESS_AUTH_MODE
886     local WIRELESS_BITRATE
887     local WIRELESS_CHANNEL
888     local WIRELESS_DEFAULT_KEY
889     local WIRELESS_ESSID
890     local WIRELESS_FREQUENCY
891     local WIRELESS_KEY
892     local WIRELESS_KEY_ASCII
893     local WIRELESS_KEY_0
894     local WIRELESS_KEY_1
895     local WIRELESS_KEY_2
896     local WIRELESS_KEY_3
897     local WIRELESS_KEY_LENGTH
898     local WIRELESS_MODE
899     local WIRELESS_NICK
900     local WIRELESS_NWID
901     local WIRELESS_POWER
902    
903     source ${file}
904     eval value=\$$(echo ${var})
905     echo "${value}"
906    }
907    
908  case $1 in  case $1 in
909   start)   start)
910   #retrieve or validate current serial   # check for global overrides
911     [ -f ${SETTINGSPATH}/confd-networking ] && ALX_CONFD_NETWORKING=true
912     [ -f /hardware-auto-detection ] && ALX_FORCED_RECHECK=true
913     read_cmdline hardware-auto-detection && ALX_FORCED_RECHECK=true
914     read_cmdline alx-reset-settings && ALX_RESET_SETTINGS=true
915    
916     # kill all settings if requested
917     if [[ ${ALX_RESET_SETTINGS} = true ]]
918     then
919     reset_system_settings
920     fi
921    
922     # retrieve or validate current serial
923   get_system_serial   get_system_serial
924   if [ "${ALX_HW_DETECT}" == "true" ]   if [[ ${ALX_HW_DETECT} = true ]]
925   then   then
926   import_settings_to_db   if [[ ${ALX_FORCED_RECHECK} = true ]]
927     then
928     update_settings_in_db
929     else
930     import_settings_to_db
931     fi
932   import_settings_local   import_settings_local
933    
934     # here we should also exchange the ssh keys
935     # or the system cannot be rebooted after
936     # the first start via the alx-webadmin
937     config_ssh_auth
938   fi   fi
   
  #now setup system configuration  
  #alx_setup_or_whatever_it_will_be_called()  
  [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings  
939    
940   #stop at last the preliminary networking (dhcp)   # now setup system configuration
941     # alx_setup_or_whatever_it_will_be_called()
942     [[ ${ALX_HW_DETECT} = false ]] && update_system_settings
943    
944     # stop at last the preliminary networking (dhcp)
945   preliminary_network stop   preliminary_network stop
946   ;;   ;;
947    
948   stop)   stop)
949   #unset_alx_connected #--> now in alxsetstate-rc6   # unset_alx_connected #--> now in alxsetstate-rc6
950   # ! important !: del systemstate   # ! important !: del systemstate
951   [ -f /etc/alx-config/state/state ] && rm /etc/alx-config/state/state   [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state
952   sleep 0.1   sleep 0.1
953   ;;   ;;
954    
955   *)   *)
956   echo "Usage: $0 {start|stop} ..."   echo "Usage: $0 {start|stop} ..."
957   ;;   ;;

Legend:
Removed from v.221  
changed lines
  Added in v.2778