Magellan Linux

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

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

revision 229 by niro, Wed Mar 9 00:13:01 2005 UTC revision 275 by niro, Sun Jul 10 17:55:03 2005 UTC
# Line 11  Line 11 
11  #%before:  #%before:
12  #%after:  #%after:
13    
14  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.4 2005-03-09 00:13:01 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.14 2005-07-10 17:55:03 niro Exp $
15    
16  # checks first if the client was already configured and if it has an valid serial  # checks first if the client was already configured and if it has an valid serial
17  # if not it runs the autoconfiguration script  # if not it runs the autoconfiguration script
# Line 28  source $rc_functions Line 28  source $rc_functions
28  source /etc/alxconfig-ng/config.rc  source /etc/alxconfig-ng/config.rc
29  source /usr/lib/alxconfig-ng/functions/mysqlfunctions  source /usr/lib/alxconfig-ng/functions/mysqlfunctions
30  source /usr/lib/alxconfig-ng/functions/serial_functions  source /usr/lib/alxconfig-ng/functions/serial_functions
31    source /usr/lib/alxconfig-ng/functions/config_modules
32  source /usr/lib/alxconfig-ng/functions/config_network  source /usr/lib/alxconfig-ng/functions/config_network
33  source /usr/lib/alxconfig-ng/functions/config_printers  source /usr/lib/alxconfig-ng/functions/config_printers
34    source /usr/lib/alxconfig-ng/functions/config_sessions
35  source /usr/lib/alxconfig-ng/functions/config_x11  source /usr/lib/alxconfig-ng/functions/config_x11
36    source /usr/lib/alxconfig-ng/functions/config_auth
37    source /usr/lib/alxconfig-ng/functions/config_ssh_auth
38    
39  #check if mysql is available  #check if mysql is available
40  [ -x /usr/bin/mysql ] && MYSQL_ALX=true  [ -x /usr/bin/mysql ] && MYSQL_ALX=true
# Line 46  unset ALX_SERIAL ALX_STATE Line 50  unset ALX_SERIAL ALX_STATE
50  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state
51    
52    
 validate_sessions(){  
   
  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}" ]  
  then  
  for x in ${all}  
  do  
  DB_SESSIONS[${i}]=${x}  
  ((i++))  
  done  
  count=${i}  
  else  
  count=0  
  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  
 }  
   
   
53  update_system_settings(){  update_system_settings(){
54   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}
55    
56     # get the modules settings
57     # ! is the first thing that must be configured !
58     config_modules
59    
60   # imports network settings from db   # imports network settings from db
61   config_networking   config_networking
62    
63   # imports x11 settings from db   # imports x11 settings from db
64   config_x11   config_x11
65    
66   #echo   # imports session settings from db
67   #echo "sessions"   config_sessions
  #validate_sessions  
  #echo  
68    
69   # imports printer settings from db   # imports printer settings from db
70   config_printing   config_printing
71    
72     # imports auth settings from db
73     config_auth
74    
75     # exchange ssh rsa keys
76     HOME=/root config_ssh_auth
77  }  }
78    
79  get_system_serial(){  get_system_serial(){
# Line 137  get_system_serial(){ Line 85  get_system_serial(){
85   then   then
86   source /etc/alxconfig-ng/serial   source /etc/alxconfig-ng/serial
87    
  # if system is already configured, it *has* a hostname.  
  # so we take the hostname of this system here  
  source /etc/hostname  
   
88   #start preliminary networking (dhcp)   #start preliminary networking (dhcp)
89   preliminary_network start   preliminary_network start
90    
# Line 174  get_system_serial(){ Line 118  get_system_serial(){
118   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"   HOSTNAME="${ALX_DEFAULT_HOSTNAME}"
119    
120   #update the hostname on the system for sure   #update the hostname on the system for sure
121   echo "HOSTNAME=${HOSTNAME}" > /etc/hostname   echo "${HOSTNAME}" > /etc/hostname
122    
123   #start preliminary networking (dhcp)   #start preliminary networking (dhcp)
124   preliminary_network start   preliminary_network start
# Line 310  import_settings_to_db() { Line 254  import_settings_to_db() {
254   '1024x768',   '1024x768',
255   '16',   '16',
256   '0'   '0'
257   );";   );"; )
258     evaluate_retval
259    
260   # input   # input
261    mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   echo -e "      Input settings ..."
262   "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";)   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
263     "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"
264     evaluate_retval
265    
266     # auth
267     echo -e "      Authentifcation settings ..."
268     mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
269     "insert into client_auth(
270     serial,
271     username,
272     shell,
273     vnc,
274     samba,
275     station
276     )
277     values(
278     '${ALX_SERIAL}',
279     '${ALX_UNPRIV_USER}',
280     '',
281     '',
282     '',
283     ''
284     );"
285     evaluate_retval
286    
287     # exchange ssh rsa keys - the first boot needs this !
288     # or no reboot will work via the webadmin
289     echo -e "      SSH authentifcation settings ..."
290     HOME=/root config_ssh_auth
291     evaluate_retval
292    
293     # input
294     echo -e "      Autostart settings ..."
295     mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
296     "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
297   evaluate_retval   evaluate_retval
298  }  }
299    
# Line 345  import_settings_local(){ Line 324  import_settings_local(){
324    
325   #set system state to 'already configured'   #set system state to 'already configured'
326   touch /etc/alxconfig-ng/state/configured   touch /etc/alxconfig-ng/state/configured
327    
328     # create a fresh fluxbox directory
329     [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox
330     install -d ${ALX_UNPRIV_HOME}/.fluxbox
331    
332     # now generate fluxbox config files
333    
334     # fluxbox main config
335     cat ${ALX_SKELETONS}/fluxbox/init \
336     > ${ALX_UNPRIV_HOME}/.fluxbox/init
337    
338     # fluxbox menu header
339     cat ${ALX_SKELETONS}/fluxbox/menu.header \
340     > ${ALX_UNPRIV_HOME}/.fluxbox/menu
341    
342     # add a newline (maybe there is no crlf in the header)
343     echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
344    
345     # fluxbox menu footer
346     cat ${ALX_SKELETONS}/fluxbox/menu.footer \
347     >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
348    
349     # add a newline (maybe there is no crlf in the footer)
350     echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
351    
352     # default passwords are bad
353     #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root
354     #usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER}
355     #smbpasswd -a root foobar
356  }  }
357    
358  #start|stop  #start|stop
# Line 417  case $1 in Line 425  case $1 in
425   then   then
426   import_settings_to_db   import_settings_to_db
427   import_settings_local   import_settings_local
428    
429     # here we should also exchange the ssh keys
430     # or the system cannot be rebooted after
431     # the first start via the alx-webadmin
432     config_ssh_auth
433   fi   fi
434    
435   #now setup system configuration   #now setup system configuration
436   #alx_setup_or_whatever_it_will_be_called()   #alx_setup_or_whatever_it_will_be_called()
437   [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings   [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings
# Line 437  case $1 in Line 450  case $1 in
450   echo "Usage: $0 {start|stop} ..."   echo "Usage: $0 {start|stop} ..."
451   ;;   ;;
452  esac  esac
453    

Legend:
Removed from v.229  
changed lines
  Added in v.275