Magellan Linux

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

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

revision 239 by niro, Tue Apr 12 20:46:52 2005 UTC revision 252 by niro, Thu Apr 14 19:12:21 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.7 2005-04-12 20:45:55 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.9 2005-04-14 19:12:21 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 32  source /usr/lib/alxconfig-ng/functions/c Line 32  source /usr/lib/alxconfig-ng/functions/c
32  source /usr/lib/alxconfig-ng/functions/config_printers  source /usr/lib/alxconfig-ng/functions/config_printers
33  source /usr/lib/alxconfig-ng/functions/config_sessions  source /usr/lib/alxconfig-ng/functions/config_sessions
34  source /usr/lib/alxconfig-ng/functions/config_x11  source /usr/lib/alxconfig-ng/functions/config_x11
35    source /usr/lib/alxconfig-ng/functions/config_auth
36    source /usr/lib/alxconfig-ng/functions/config_ssh_auth
37    
38  #check if mysql is available  #check if mysql is available
39  [ -x /usr/bin/mysql ] && MYSQL_ALX=true  [ -x /usr/bin/mysql ] && MYSQL_ALX=true
# Line 47  unset ALX_SERIAL ALX_STATE Line 49  unset ALX_SERIAL ALX_STATE
49  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state  [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state
50    
51    
 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  
 }  
   
   
52  update_system_settings(){  update_system_settings(){
53   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}   echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT}
54    
# Line 120  update_system_settings(){ Line 58  update_system_settings(){
58   # imports x11 settings from db   # imports x11 settings from db
59   config_x11   config_x11
60    
61   #echo   # imports session settings from db
  #echo "sessions"  
  #validate_sessions  
  #echo  
62   config_sessions   config_sessions
63    
64   # imports printer settings from db   # imports printer settings from db
65   config_printing   config_printing
66    
67     # imports auth settings from db
68     config_auth
69    
70     # exchange ssh rsa keys
71     config_ssh_auth
72  }  }
73    
74  get_system_serial(){  get_system_serial(){
# Line 308  import_settings_to_db() { Line 249  import_settings_to_db() {
249   '1024x768',   '1024x768',
250   '16',   '16',
251   '0'   '0'
252   );";   );"; )
253     evaluate_retval
254    
255   # input   # input
256    mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   echo -e "      Input settings ..."
257   "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";)   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
258     "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"
259     evaluate_retval
260    
261     # auth
262     echo -e "      Authentifcation settings ..."
263     mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
264     "insert into client_auth(
265     serial,
266     username,
267     shell,
268     vnc,
269     samba,
270     station
271     )
272     values(
273     '${ALX_SERIAL}',
274     '${ALX_UNPRIV_USER}',
275     '',
276     '',
277     '',
278     ''
279     );"
280     evaluate_retval
281    
282     # input
283     echo -e "      Autostart settings ..."
284     mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
285     "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
286   evaluate_retval   evaluate_retval
287  }  }
288    
# Line 343  import_settings_local(){ Line 313  import_settings_local(){
313    
314   #set system state to 'already configured'   #set system state to 'already configured'
315   touch /etc/alxconfig-ng/state/configured   touch /etc/alxconfig-ng/state/configured
316    
317     # default passwords are bad
318     #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root
319     #usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER}
320     #smbpasswd -a root foobar
321  }  }
322    
323  #start|stop  #start|stop
# Line 415  case $1 in Line 390  case $1 in
390   then   then
391   import_settings_to_db   import_settings_to_db
392   import_settings_local   import_settings_local
393    
394     # here we should also exchange the ssh keys
395     # or the system cannot be rebooted after
396     # the first start via the alx-webadmin
397     config_ssh_auth
398   fi   fi
399    
400   #now setup system configuration   #now setup system configuration
401   #alx_setup_or_whatever_it_will_be_called()   #alx_setup_or_whatever_it_will_be_called()
402   [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings   [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings
# Line 435  case $1 in Line 415  case $1 in
415   echo "Usage: $0 {start|stop} ..."   echo "Usage: $0 {start|stop} ..."
416   ;;   ;;
417  esac  esac
418    

Legend:
Removed from v.239  
changed lines
  Added in v.252