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 337 by niro, Thu Sep 22 22:14:38 2005 UTC alx-src/tags/alxconf_20060908_1/alxconfig-ng/init.d/alxsettings revision 375, Mon Feb 20 14:49:31 2006 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.22 2005-09-22 22:14:38 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.27 2005-10-11 12:10:15 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 97  update_system_settings() Line 97  update_system_settings()
97    
98  get_system_serial()  get_system_serial()
99  {  {
100     local CUR_IP CUR_MAC CUR_MTIME ALX_IFACE
101    
102   local CUR_IP CUR_MAC CUR_MTIME   if [[ ${ALX_CONFD_NETWORKING} = true ]]
103     then
104     ALX_IFACE="$(< ${SETTINGSPATH}/confd-networking)"
105     else
106     ALX_IFACE="eth0"
107     fi
108    
109   # check if serial file exists   # check if serial file exists
110   if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]   if [ -f /etc/alxconfig-ng/serial ] && [[ ${ALX_FORCED_RECHECK} = false ]]
# Line 116  get_system_serial() Line 122  get_system_serial()
122   exit 1   exit 1
123   fi   fi
124    
125   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp')
126   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)
127   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
128    
129   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."
# Line 211  get_system_serial() Line 217  get_system_serial()
217   echo -e ${COLOREDSTAR} "Trying to get new serial ..."   echo -e ${COLOREDSTAR} "Trying to get new serial ..."
218    
219   # request a new serial; one command now (cause must be done in the same session)   # request a new serial; one command now (cause must be done in the same session)
220   ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');
  "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');  
221   select last_insert_id();")   select last_insert_id();")
222    
223   if [[ ${ALX_SERIAL} != NULL ]]   if [[ ${ALX_SERIAL} != NULL ]]
# Line 222  get_system_serial() Line 227  get_system_serial()
227   $SET_WCOL   $SET_WCOL
228   echo "[ SN: ${ALX_SERIAL} ]"   echo "[ SN: ${ALX_SERIAL} ]"
229    
230   # set ALX_STATE to ok so everybody that everything was ok   # set ALX_STATE to ok so everybody knows that everything was ok
231   ALX_STATE=ok   ALX_STATE=ok
232    
233   echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial   echo "ALX_SERIAL=${ALX_SERIAL}" > /etc/alxconfig-ng/serial
# Line 246  get_system_serial() Line 251  get_system_serial()
251    
252   # write current state to temp file   # write current state to temp file
253   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state   echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state
254     echo "ALX_IFACE=${ALX_IFACE}" >> /etc/alxconfig-ng/state/state
255  }  }
256    
257    
# Line 295  import_settings_to_db() Line 301  import_settings_to_db()
301   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || exit 1
302   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"
303    
304   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_network(
  "insert into cfg_network(  
305   hostname,   hostname,
306   serial,   serial,
307   module,   module,
# Line 347  import_settings_to_db() Line 352  import_settings_to_db()
352   break   break
353   done   done
354   else   else
355   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_network(
  "insert into cfg_network(  
356   hostname,   hostname,
357   serial,   serial,
358   module,   module,
# Line 368  import_settings_to_db() Line 372  import_settings_to_db()
372   # xserver   # xserver
373   echo -e "      Graphic settings ..."   echo -e "      Graphic settings ..."
374   # xserver general   # xserver general
375   ( mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ( mysqldo "insert into cfg_graphic(
  "insert into cfg_graphic(  
376   serial,   serial,
377   module,   module,
378   resolution,   resolution,
# Line 387  import_settings_to_db() Line 390  import_settings_to_db()
390    
391   # input   # input
392   echo -e "      Input settings ..."   echo -e "      Input settings ..."
393   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"
  "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"  
394   evaluate_retval   evaluate_retval
395    
396   # auth   # auth
397   echo -e "      Authentifcation settings ..."   echo -e "      Authentification settings ..."
398   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into client_auth(
  "insert into client_auth(  
399   serial,   serial,
400   username,   username,
401   shell,   shell,
# Line 414  import_settings_to_db() Line 415  import_settings_to_db()
415    
416   # exchange ssh rsa keys - the first boot needs this !   # exchange ssh rsa keys - the first boot needs this !
417   # or no reboot will work via the webadmin   # or no reboot will work via the webadmin
418   echo -e "      SSH authentifcation settings ..."   echo -e "      SSH authentification settings ..."
419   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
420   evaluate_retval   evaluate_retval
421    
422   # input   # autostart
423   echo -e "      Autostart settings ..."   echo -e "      Autostart settings ..."
424   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
425   "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"  
426     # screensaver
427     echo -e "      Screensaver settings ..."
428     mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"
429    
430   evaluate_retval   evaluate_retval
431  }  }
432    
# Line 461  update_settings_in_db() Line 466  update_settings_in_db()
466   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || exit 1
467   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modules.d/net.${iface} | cut -d' ' -f3)"
468    
469   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_network set
  "update cfg_network set  
470   hostname='${ALX_DEFAULT_HOSTNAME}',   hostname='${ALX_DEFAULT_HOSTNAME}',
471   module='${NETCARD_DRIVER}',   module='${NETCARD_DRIVER}',
472   domain='${ALX_DEFAULT_DOMAIN}',   domain='${ALX_DEFAULT_DOMAIN}',
# Line 489  update_settings_in_db() Line 493  update_settings_in_db()
493   break   break
494   done   done
495   else   else
496   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_network set
  "update cfg_network set  
497   hostname='${ALX_DEFAULT_HOSTNAME}',   hostname='${ALX_DEFAULT_HOSTNAME}',
498   module='${NETCARD_DRIVER}',   module='${NETCARD_DRIVER}',
499   domain='${ALX_DEFAULT_DOMAIN}',   domain='${ALX_DEFAULT_DOMAIN}',
# Line 502  update_settings_in_db() Line 505  update_settings_in_db()
505   # xserver   # xserver
506   echo -e "      Graphic settings ..."   echo -e "      Graphic settings ..."
507   # xserver general   # xserver general
508   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_graphic set
  "update cfg_graphic set  
509   module='${XMODULE}',   module='${XMODULE}',
510   resolution='1024x768',   resolution='1024x768',
511   depth='16',   depth='16',
# Line 513  update_settings_in_db() Line 515  update_settings_in_db()
515    
516   # input   # input
517   echo -e "      Input settings ..."   echo -e "      Input settings ..."
518   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"
  "update cfg_input set  
  mouse='${XMOUSETYPE}'  
  where serial=${ALX_SERIAL};"  
519   evaluate_retval   evaluate_retval
520  }  }
521    
# Line 630  import_settings_local() Line 629  import_settings_local()
629   --icon-width "1" \   --icon-width "1" \
630   --icon-height "1"   --icon-height "1"
631    
632     # create a xinitrc
633     echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc
634    
635   # set correct permissions   # set correct permissions
636   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
637   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
638   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
639   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop
640   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc
641     chmod 0644 ${ALX_UNPRIV_HOME}/.xinitrc
  # default passwords are bad  
  #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root  
  #usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER}  
  #smbpasswd -a root foobar  
642  }  }
643    
644  # start|stop  # start|stop
# Line 680  preliminary_network() Line 678  preliminary_network()
678   else   else
679   rm -f /var/run/dhcpcd-eth?.pid   rm -f /var/run/dhcpcd-eth?.pid
680   fi   fi
681   [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop   [[ ${ALX_CONFD_NETWORKING} = true ]] && [[ ${RUNLEVEL} != S ]] && \
682     ${rc_base}/init.d/network stop
683    
684   echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT}   echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT}
685    
# Line 746  reset_system_settings() Line 744  reset_system_settings()
744   rm -f /etc/alxconfig-ng/serial   rm -f /etc/alxconfig-ng/serial
745   rm -rf /etc/alxconfig-ng/state   rm -rf /etc/alxconfig-ng/state
746    
747     # clear all printers & net-shares
748     :> /etc/cups/printers.conf
749     :> /etc/samba/smb.conf
750    
751     # remove inetd, cups & smb from init
752     rc-config del inetd &> /dev/null
753     rc-config del cups &> /dev/null
754     rc-config del samba &> /dev/null
755    
756     # remove all user settings
757     [ -d ${ALX_UNPRIV_HOME} ] && rm -rf ${ALX_UNPRIV_HOME}
758    
759     # remove all ica-sessions
760     find ${ALX_ICA_SESSIONS} -type f -name '*.ica' | xargs rm
761    
762     # remove all old nics and modules configs
763     find /etc/conf.d -type f -name 'net.*' | xargs rm
764     find /etc/modules.d -type f -name 'net.*' | xargs rm
765    
766     # restore default networking
767     cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0
768    
769   echo "I am done now, press [Enter] to reboot system ..."   echo "I am done now, press [Enter] to reboot system ..."
770   read   else
771   reboot   echo "Aborted, press [Enter] to reboot system ..."
772   fi   fi
773     read
774     reboot
775  }  }
776    
777  onboot_interface_list()  onboot_interface_list()
# Line 775  onboot_interface_list() Line 797  onboot_interface_list()
797   echo "${devices}"   echo "${devices}"
798  }  }
799    
800  # read values from files  # read values from net.* files
801  read_value()  read_value()
802  {  {
803   local var="$1"   local var="$1"
# Line 862  case $1 in Line 884  case $1 in
884    
885   # now setup system configuration   # now setup system configuration
886   # alx_setup_or_whatever_it_will_be_called()   # alx_setup_or_whatever_it_will_be_called()
887   [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings   [[ ${ALX_HW_DETECT} = false ]] && update_system_settings
888    
889   # stop at last the preliminary networking (dhcp)   # stop at last the preliminary networking (dhcp)
890   preliminary_network stop   preliminary_network stop

Legend:
Removed from v.337  
changed lines
  Added in v.375