Magellan Linux

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

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

revision 225 by niro, Tue Mar 8 20:49:14 2005 UTC revision 226 by niro, Wed Mar 9 00:04:18 2005 UTC
# 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    
 #                       +-----+  
 #                       |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  
 #                          |  
 #                          .  
 #                          .  
 #                          .  
 #  
 #  
 #  
   
22  source /etc/sysconfig/rc  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
27  source /opt/alx-config/functions/mysqlfunctions  source /usr/lib/alxconfig-ng/functions/mysqlfunctions
28  source /opt/alx-config/functions/alx-mysql-functions  source /usr/lib/alxconfig-ng/functions/mysqlfunctions
29    source /usr/lib/alxconfig-ng/functions/config_network
30    source /usr/lib/alxconfig-ng/functions/config_printers
31    source /usr/lib/alxconfig-ng/functions/config_x11
32    
33  #check if mysql is available  #check if mysql is available
34  [ -x /usr/bin/mysql ] && MYSQL_ALX=true  [ -x /usr/bin/mysql ] && MYSQL_ALX=true
35    
36  #other needed vars  #other needed vars
37  ALX_HW_DETECT=false  ALX_HW_DETECT=false
 ALX_NETWORK_SETUP=false  
 ALX_XSERVER_SETUP=false  
 ALX_SESSION_SETUP=false  
 ALX_PRINTER_SETUP=false  
38    
39  #unset vars which may kill us  #unset vars which may kill us
40  unset ALX_SERIAL ALX_STATE  unset ALX_SERIAL ALX_STATE
41    
42    
43  #setup needed directories  #setup needed directories
44  [ ! -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  
   
   
 validate_networking(){  
  #source /opt/alx-config/Configurator/config_functions.sh  
   
  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  
   
  #set update flag  
  ALX_NETWORK_SETUP=true  
  fi  
  ((i++))  
  done  
 }  
   
   
   
 validate_xserver(){  
  #source /opt/alx-config/Configurator/config_functions.sh  
   
  local x i all LOCAL_XSERVER DB_XSERVER SETTINGSPATH  
   
  #all arrays:  
  # ->  xmodule resolution depth mouse monvendor monmodel hsync vref  
   
   #xserver  
  #get settings from local system  
  #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  
   
  #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  
   
  SETTINGSPATH=${SETTINGS_TEMPLATE}/menu  
  if [ "${DB_XSERVER[0]}" != "*NULL*" \  
  -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  
 }  
45    
46    
47  validate_sessions(){  validate_sessions(){
  #source /opt/alx-config/Configurator/config_functions.sh  
48    
49   local x i all LOCAL_SESSIONS DB_SESSIONS SETTINGSPATH count   local x i all LOCAL_SESSIONS DB_SESSIONS SETTINGSPATH count
50    
# Line 623  validate_sessions(){ Line 108  validate_sessions(){
108  }  }
109    
110    
111  validate_printing(){  update_system_settings(){
112   #source /opt/alx-config/Configurator/config_functions.sh   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}
113    
114   local x i k all LOCAL_PRINTER DB_PRINTER SETTINGSPATH count   # imports network settings from db
115     config_networking
  #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}" ]  
  then  
  for x in ${all}  
  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  
   
 }  
116    
117  update_system_settings(){   # imports x11 settings from db
118   source /opt/alx-config/Configurator/config_functions.sh   config_x11
119    
  echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}  
   
  echo  
  echo "network"  
  validate_networking  
  echo  
  echo "xserver"  
  validate_xserver  
  echo  
  echo "sessions"  
  validate_sessions  
  echo  
  #echo "printers"  
  #validate_printing  
120   #echo   #echo
121     #echo "sessions"
122   if [ "${ALX_NETWORK_SETUP}" == "true" ]   #validate_sessions
123   then   #echo
124   echo -e ${COLMAGENTA}"Updating network settings"${COLDEFAULT}  
125   setup_modules   # imports printer settings from db
126   setup_network   config_printing
127   fi  }
128    
129   if [ "${ALX_XSERVER_SETUP}" == "true" ]  # 1.serial 2.mtime 3.mac
130   then  validate_serial()
131   echo -e ${COLMAGENTA}"Updating xserver settings"${COLDEFAULT}  {
132   setup_xfree   local serial
133   fi   local db_serial
134     local mtime
135   if [ "${ALX_SESSION_SETUP}" == "true" ]   local mac
136    
137     # abort if params are missing
138     [ $# -ne 3 ] && return 1
139    
140     serial=$1
141     mtime=$2
142     mac=$3
143    
144     db_serial=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
145     "select serial from client_serials where mtime='${mtime}' and mac='${mac}'" )
146    
147     if [[ ${db_serial} = ${serial} ]]
148   then   then
149   echo -e ${COLMAGENTA}"Updating session settings"${COLDEFAULT}   return 0
150   setup_sessions   else
151     return 1
152   fi   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}  
153  }  }
154    
155  get_system_serial(){  get_system_serial(){
# Line 778  get_system_serial(){ Line 157  get_system_serial(){
157   local CUR_IP CUR_MAC CUR_MTIME   local CUR_IP CUR_MAC CUR_MTIME
158    
159   #check if serial file exists   #check if serial file exists
160   if [ -f /etc/alx-config/serial ]   if [ -f /etc/alxconfig-ng/serial ]
161   then   then
162   source /etc/alx-config/serial   source /etc/alxconfig-ng/serial
163    
164   # if system is already configured, it *has* a hostname.   # if system is already configured, it *has* a hostname.
165   # so we take the hostname of this system here   # so we take the hostname of this system here
166   source /etc/hostname   source /etc/hostname
167    
168   #start preliminary networking (dhcp)   #start preliminary networking (dhcp)
169   preliminary_network start   preliminary_network start
170    
171   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')
172   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)
173   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
174    
175   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."
176    
177   #nice serial output   #nice serial output
178   $CURS_UP   $CURS_UP
179   $SET_WCOL   $SET_WCOL
180   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  
181    
182   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"   if validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}"
183   then   then
# Line 837  get_system_serial(){ Line 192  get_system_serial(){
192   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}
193   ALX_HW_DETECT=true   ALX_HW_DETECT=true
194   /etc/init.d/hwdetect start   /etc/init.d/hwdetect start
195    
196   #set hostname to alx_default_hostname   #set hostname to alx_default_hostname
197   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
198   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"
199    
200   #update the hostname on the system for sure   #update the hostname on the system for sure
201   echo "HOSTNAME=${HOSTNAME}" > /etc/hostname   echo "HOSTNAME=${HOSTNAME}" > /etc/hostname
202    
203   #start preliminary networking (dhcp)   #start preliminary networking (dhcp)
204   preliminary_network start   preliminary_network start
205    
206   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')
207   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)
208   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
209    
210   echo -e ${COLOREDSTAR} "Trying to get new serial ..."   echo -e ${COLOREDSTAR} "Trying to get new serial ..."
211    
212   #request new serial   #request new serial
213   #ALX_REG_DATE="$(date +%F)"   #ALX_REG_DATE="$(date +%F)"
214    
215   #we're using the mtime now (better for vaildating the serial)   #we're using the mtime now (better for vaildating the serial)
216   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
217   "insert into client_serials(   "insert into client_serials(
# Line 867  get_system_serial(){ Line 222  get_system_serial(){
222   '${CUR_MTIME}',   '${CUR_MTIME}',
223   '${CUR_MAC}'   '${CUR_MAC}'
224   );"   );"
225    
226   #then validate and retrieve serial   #then validate and retrieve serial
227    
228   ### warning must be changed that only the LAST ID will be fetched,  ###   ### warning must be changed that only the LAST ID will be fetched,  ###
229   ### or you get error if the computer name and date are the same     ###   ### or you get error if the computer name and date are the same     ###
230   ### you have more then one serial number than                       ###   ### you have more than one serial number then                       ###
231    
  #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}'")  
   
232   #select highest id only (added max)   #select highest id only (added max)
233   ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
234   "select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'")   "select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'")
# Line 888  get_system_serial(){ Line 239  get_system_serial(){
239   $CURS_UP   $CURS_UP
240   $SET_WCOL   $SET_WCOL
241   echo "[ SN: ${ALX_SERIAL} ]"   echo "[ SN: ${ALX_SERIAL} ]"
242    
243   #set ALX_STATE to ok so everybody that everything was ok   #set ALX_STATE to ok so everybody that everything was ok
244   ALX_STATE=ok   ALX_STATE=ok
245    
246   echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alx-config/serial   echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial
247   echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alx-config/serial   echo "ALX_REG_DATE=${CUR_MTIME}" >> /etc/alxconfig-ng/serial
248    
249   evaluate_retval   evaluate_retval
250   else   else
251   #print false (works only if this is the first statement here)   #print false (works only if this is the first statement here)
252   evaluate_retval   evaluate_retval
253    
254   #set ALX_STATE to error so everybody sees there was an error   #set ALX_STATE to error so everybody sees there was an error
255   ALX_STATE=error   ALX_STATE=error
256    
257   #show an error that no new serial was found   #show an error that no new serial was found
258   #nice serial output   #nice serial output
259   $CURS_UP   $CURS_UP
# Line 910  get_system_serial(){ Line 261  get_system_serial(){
261   echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]"   echo -e "[ SN: ${COLRED}None, 0${COLDEFAULT} ]"
262   fi   fi
263   fi   fi
264    
265   #write current state to temp file   #write current state to temp file
266   echo "ALX_STATE=${ALX_STATE}" > /etc/alx-config/state/state   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state
267  }  }
268    
269    
270  check_is_configured() {  check_is_configured() {
271   if [ -f /etc/alx-config/state/configured ]   if [ -f /etc/alxconfig-ng/state/configured ]
272   then   then
273   export ALX_CONFIGURED=true   export ALX_CONFIGURED=true
274   else   else
# Line 1006  import_settings_to_db() { Line 357  import_settings_to_db() {
357  }  }
358    
359  # imports current settings to the local system resolved by the hardware detection  # imports current settings to the local system resolved by the hardware detection
360    # we only need the network settings
361  import_settings_local(){  import_settings_local(){
362   #note: networking is always 'dhcp' if hw was autodetected   #note: networking is always 'dhcp' if hw was autodetected
363   #note: default_domain/hostname is set in config.rc   #note: default_domain/hostname is set in config.rc
364    
365   #to be safe, we do some sanity checks   #to be safe, we do some sanity checks
366   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain   [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain
367   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx   [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx
368    
369   #vars used by hwdetect   #vars used by hwdetect
370   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
371   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
372   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE   local MOUSETYPE XMOUSETYPE FULLNAME DEVICE
373    
   
374   #get setting from hwdetect   #get setting from hwdetect
375   source /etc/sysconfig/hwsetup/knoppix   source /etc/sysconfig/hwsetup/knoppix
376   source /etc/sysconfig/hwsetup/mouse  
   
377   echo   echo
378   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}
379    
380     [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH}
381   #allready configured, no update needed so we put it to system   echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules
  SETTINGSPATH=${SETTINGS_TEMPLATE}/system  
   
   
  #network  
  echo -e "      Network settings ..."  
   
  [ ! -d ${SETTINGSPATH}/modules ] && install -d ${SETTINGSPATH}/modules  
  echo "${NETCARD_DRIVER}" > ${SETTINGSPATH}/modules/modules  
   
  [ ! -d ${SETTINGSPATH}/network ] && install -d ${SETTINGSPATH}/network  
  ( echo "${ALX_DEFAULT_HOSTNAME}" > ${SETTINGSPATH}/network/hostname;  
   echo "${ALX_DEFAULT_DOMAIN}" > ${SETTINGSPATH}/network/domain;  
   echo "dhcp" > ${SETTINGSPATH}/network/networking )  
382   evaluate_retval   evaluate_retval
383    
   
  #xserver  
  echo -e "      Graphic settings ..."  
   
  [ ! -d ${SETTINGSPATH}/vga ] && install -d ${SETTINGSPATH}/vga  
  [ ! -d ${SETTINGSPATH}/mouse ] && install -d ${SETTINGSPATH}/mouse  
  [ ! -d ${SETTINGSPATH}/monitor ] && install -d ${SETTINGSPATH}/monitor  
  ( echo "${XMODULE}" > ${SETTINGSPATH}/vga/vga;  
   echo "16" > ${SETTINGSPATH}/vga/vgadepth;  
   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;)  
  evaluate_retval  
   
384   #set system state to 'already configured'   #set system state to 'already configured'
385   touch /etc/alx-config/state/configured   touch /etc/alxconfig-ng/state/configured
386  }  }
387    
388  #start|stop  #start|stop
389  preliminary_network(){  preliminary_network(){
390   local module   local module
391    
392   if [ -f /etc/alx-config/state/configured ]   if [ -f /etc/alxconfig-ng/state/configured ]
393   then   then
394   #get module name   #get module name
395   module=$(cat ${SETTINGS_TEMPLATE}/system/modules/modules)   module=$(cat ${SETTINGSPATH}/modules)
396   modprobe ${module}   modprobe ${module}
397   else   else
398   #vars used by hwdetect   #vars used by hwdetect
399   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME   local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME
400   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER   local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER
401    
402   #get setting from hwdetect   #get setting from hwdetect
403   source /etc/sysconfig/hwsetup/knoppix   source /etc/sysconfig/hwsetup/knoppix
404   modprobe ${NETCARD_DRIVER}   modprobe ${NETCARD_DRIVER}
405   fi   fi
406    
407   case $1 in   case $1 in
408   start)   start)
409   # keeping like always safe:   # keeping like always safe:
# Line 1097  preliminary_network(){ Line 417  preliminary_network(){
417   else   else
418   rm -f /var/run/dhcpcd-eth?.pid   rm -f /var/run/dhcpcd-eth?.pid
419   fi   fi
420    
421   echo -e ${COLMAGENTA}"Starting preliminary network ... "${COLDEFAULT}   echo -e ${COLMAGENTA}"Starting preliminary network ... "${COLDEFAULT}
422   #dhcpcd &> /dev/null #&& echo "ok" || echo "false"   dhcpcd &> /dev/null
423    
424   # aka_fix ########################################   # aka_fix ########################################
425   ifconfig eth0 128.20.222.222 netmask 255.255.0.0 up   #ifconfig eth0 128.20.222.222 netmask 255.255.0.0 up
426   route del default gw 128.20.50.13 &> /dev/null   #route del default gw 128.20.50.13 &> /dev/null
427   route add default gw 128.20.50.21 &> /dev/null   #route add default gw 128.20.50.21 &> /dev/null
428   echo "nameserver 128.20.50.21" > /etc/resolv.conf   #echo "nameserver 128.20.50.21" > /etc/resolv.conf
429   ##################################################   ##################################################
430    
431   evaluate_retval   evaluate_retval
432   ;;   ;;
433    
434   stop)   stop)
435   echo -e ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT}   echo -e ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT}
436   ifconfig eth0 down   ifconfig eth0 down
437   if ps -A|grep dhcpcd > /dev/null   if ps -A|grep dhcpcd > /dev/null
438   then   then
  #echo -en ${COLMAGENTA}"Stopping preliminary network ... "${COLDEFAULT}  
439   dhcpcd -z  &> /dev/null   dhcpcd -z  &> /dev/null
440   fi   fi
441   evaluate_retval   evaluate_retval
442   ;;   ;;
443    
444   *)   *)
445   echo "Usage: preliminary_network {start|stop}"   echo "Usage: preliminary_network {start|stop}"
446   ;;   ;;
# Line 1146  case $1 in Line 468  case $1 in
468   stop)   stop)
469   #unset_alx_connected #--> now in alxsetstate-rc6   #unset_alx_connected #--> now in alxsetstate-rc6
470   # ! important !: del systemstate   # ! important !: del systemstate
471   [ -f /etc/alx-config/state/state ] && rm /etc/alx-config/state/state   [ -f /etc/alxconfig-ng/state/state ] && rm /etc/alxconfig-ng/state/state
472   sleep 0.1   sleep 0.1
473   ;;   ;;
474   *)   *)

Legend:
Removed from v.225  
changed lines
  Added in v.226