Magellan Linux

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

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

revision 2140 by niro, Mon May 16 11:08:31 2011 UTC revision 2141 by niro, Tue May 17 10:51:57 2011 UTC
# Line 126  get_system_serial() Line 126  get_system_serial()
126   CUR_MAC=$(ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(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 ..."   rc_print "Trying to validate my serial ..."
130    
131   # nice serial output   # nice serial output
132   $CURS_UP   $CURS_UP
# Line 149  get_system_serial() Line 149  get_system_serial()
149   echo   echo
150   if [[ ${ALX_FORCED_RECHECK} = true ]]   if [[ ${ALX_FORCED_RECHECK} = true ]]
151   then   then
152   echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT}   rc_mecho "Hardware autodetection forced by system-administrator"
153   # always disable CONFD_NETWORKING here   # always disable CONFD_NETWORKING here
154   export ALX_CONFD_NETWORKING="false"   export ALX_CONFD_NETWORKING="false"
155   else   else
156   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}   rc_mecho "Preparing system for first boot"
157   fi   fi
158   ALX_HW_DETECT=true   ALX_HW_DETECT=true
159   hwsetup   hwsetup
# Line 189  get_system_serial() Line 189  get_system_serial()
189   # but first check the serial   # but first check the serial
190   source /etc/alxconfig-ng/serial   source /etc/alxconfig-ng/serial
191    
192   echo -e ${COLOREDSTAR} "Trying to validate my serial ..."   rc_print "Trying to validate my serial ..."
193    
194   # nice serial output   # nice serial output
195   $CURS_UP   $CURS_UP
# Line 217  get_system_serial() Line 217  get_system_serial()
217   return 0   return 0
218   fi   fi
219    
220   echo -e ${COLOREDSTAR} "Trying to get new serial ..."   rc_print "Trying to get new serial ..."
221    
222   # 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)
223   ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');   ALX_SERIAL=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');
# Line 289  import_settings_to_db() Line 289  import_settings_to_db()
289   source /etc/conf.d/hwsetup/mouse   source /etc/conf.d/hwsetup/mouse
290    
291   echo   echo
292   echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT}   rc_mecho "Importing detected settings to database"
293    
294   # network   # network
295   echo -e "      Network settings ..."   rc_mecho "      Network settings ..."
296   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
297   then   then
298   # get settings   # get settings
  #source ${rc_base}/init.d/network &> /dev/null  
299   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in $(onboot_interface_list ${network_settings}/net.*)
300   do   do
301   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
302   echo "WARNING: only importing settings for interface [ ${iface} ] !"   rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
303   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || echo "Error: could not read '${network_settings}/net.${iface}'"
304   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
305    
306   mysqldo "insert into cfg_network(   mysqldo "insert into cfg_network(
# Line 373  import_settings_to_db() Line 372  import_settings_to_db()
372   evaluate_retval   evaluate_retval
373    
374   # xserver   # xserver
375   echo -e "      Graphic settings ..."   rc_mecho "      Graphic settings ..."
376   # xserver general   # xserver general
377   ( mysqldo "insert into cfg_graphic(   ( mysqldo "insert into cfg_graphic(
378   serial,   serial,
# Line 392  import_settings_to_db() Line 391  import_settings_to_db()
391   evaluate_retval   evaluate_retval
392    
393   # input   # input
394   echo -e "      Input settings ..."   rc_mecho "      Input settings ..."
395   mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"   mysqldo "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');"
396   evaluate_retval   evaluate_retval
397    
398   # auth   # auth
399   echo -e "      Authentification settings ..."   rc_mecho "      Authentification settings ..."
400   mysqldo "insert into client_auth(   mysqldo "insert into client_auth(
401   serial,   serial,
402   username,   username,
# Line 418  import_settings_to_db() Line 417  import_settings_to_db()
417    
418   # exchange ssh rsa keys - the first boot needs this !   # exchange ssh rsa keys - the first boot needs this !
419   # or no reboot will work via the webadmin   # or no reboot will work via the webadmin
420   echo -e "      SSH authentification settings ..."   rc_mecho "      SSH authentification settings ..."
421   HOME=/root config_ssh_auth   HOME=/root config_ssh_auth
422   evaluate_retval   evaluate_retval
423    
424   # autostart   # autostart
425   echo -e "      Autostart settings ..."   rc_mecho "      Autostart settings ..."
426   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"   mysqldo "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');"
427    
428   # screensaver   # screensaver
429   echo -e "      Screensaver settings ..."   rc_mecho "      Screensaver settings ..."
430   mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"   mysqldo "insert into cfg_screensaver(serial,screensaver) values('${ALX_SERIAL}','')"
431    
432   # version info   # version info
433     rc_mecho "      OS version info ..."
434   local alx_os   local alx_os
435   local alx_utils   local alx_utils
436   alx_os="$(< /etc/mageversion)"   alx_os="$(< /etc/mageversion)"
# Line 462  update_settings_in_db() Line 462  update_settings_in_db()
462   source /etc/conf.d/hwsetup/mouse   source /etc/conf.d/hwsetup/mouse
463    
464   echo   echo
465   echo -e ${COLMAGENTA}"Updating detected settings in database"${COLDEFAULT}   rc_mecho "Updating detected settings in database"
466    
467   # network   # network
468   echo -e "      Network settings ..."   rc_mecho "      Network settings ..."
469   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
470   then   then
471   # get settings   # get settings
# Line 473  update_settings_in_db() Line 473  update_settings_in_db()
473   for iface in $(onboot_interface_list ${network_settings}/net.*)   for iface in $(onboot_interface_list ${network_settings}/net.*)
474   do   do
475   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue   [[ $(< ${SETTINGSPATH}/confd-networking) != ${iface} ]] && continue
476   echo "WARNING: only importing settings for interface [ ${iface} ] !"   rc_echo "WARNING: only importing settings for interface [ ${iface} ] !"
477   source ${network_settings}/net.${iface} || exit 1   source ${network_settings}/net.${iface} || exit 1
478   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"   NETCARD_DRIVER="$(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f3)"
479    
# Line 514  update_settings_in_db() Line 514  update_settings_in_db()
514   evaluate_retval   evaluate_retval
515    
516   # xserver   # xserver
517   echo -e "      Graphic settings ..."   rc_mecho "      Graphic settings ..."
518   # xserver general   # xserver general
519   mysqldo "update cfg_graphic set   mysqldo "update cfg_graphic set
520   module='${XMODULE}',   module='${XMODULE}',
# Line 525  update_settings_in_db() Line 525  update_settings_in_db()
525   evaluate_retval   evaluate_retval
526    
527   # input   # input
528   echo -e "      Input settings ..."   rc_mecho "      Input settings ..."
529   mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"   mysqldo "update cfg_input set mouse='${XMOUSETYPE}' where serial=${ALX_SERIAL};"
530   evaluate_retval   evaluate_retval
531    
532   # version info   # version info
533     rc_mecho "      OS version info ..."
534   local alx_os   local alx_os
535   local alx_utils   local alx_utils
536   alx_os="$(< /etc/mageversion)"   alx_os="$(< /etc/mageversion)"
# Line 558  import_settings_local() Line 559  import_settings_local()
559   source /etc/conf.d/hwsetup/knoppix   source /etc/conf.d/hwsetup/knoppix
560    
561   echo   echo
562   echo -e ${COLMAGENTA}"Importing detected settings to local system"${COLDEFAULT}   rc_mecho "Importing detected settings to local system"
563    
564   if [[ ${ALX_CONFD_NETWORKING} = false ]]   if [[ ${ALX_CONFD_NETWORKING} = false ]]
565   then   then
# Line 567  import_settings_local() Line 568  import_settings_local()
568   echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0.conf   echo "alias eth0 ${NETCARD_DRIVER}" > /etc/modprobe.d/net.eth0.conf
569    
570   # regenerate modprobe.conf   # regenerate modprobe.conf
571   [ -x $(which modules-update) ] && modules-update || echo "cannot regen modprobe.conf"   [ -x $(which modules-update) ] && modules-update || rc_echo "modules-update not found!"
572   evaluate_retval   evaluate_retval
573   fi   fi
574    
# Line 687  preliminary_network() Line 688  preliminary_network()
688   # so we can delete all pid files if one exists   # so we can delete all pid files if one exists
689   if [[ ! -z $(pidof udhcpc) ]]   if [[ ! -z $(pidof udhcpc) ]]
690   then   then
691   echo -e ${COLMAGENTA}"Forcing network down"${COLDEFAULT}   rc_mecho "Forcing network down"
692   killall udhcpc &> /dev/null   killall udhcpc &> /dev/null
693   sleep 1   sleep 1
694   fi   fi
695   [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop   [[ ${ALX_CONFD_NETWORKING} = true ]] && ${rc_base}/init.d/network stop
696    
697   echo -e ${COLMAGENTA}"Starting preliminary networking ... "${COLDEFAULT}   rc_mecho "Starting preliminary networking ... "
698    
699   # start network configured from /etc/conf.d   # start network configured from /etc/conf.d
700   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
701   then   then
702   ${rc_base}/init.d/network start   ${rc_base}/init.d/network start
703   else   else
704   echo -e ${COLOREDSTAR}"Starting default dhcp based networking ... "${COLDEFAULT}   rc_print "Starting default dhcp based networking ... "
705   # -t 10 timeout of 10 secs   # -t 10 timeout of 10 secs
706   udhcpc -t 10 &> /dev/null   udhcpc -t 10 &> /dev/null
707   evaluate_retval   evaluate_retval
# Line 708  preliminary_network() Line 709  preliminary_network()
709   ;;   ;;
710    
711   stop)   stop)
712   echo -e ${COLMAGENTA}"Stopping preliminary networking ... "${COLDEFAULT}   rc_mecho "Stopping preliminary networking ... "
713   if [[ ${ALX_CONFD_NETWORKING} = true ]]   if [[ ${ALX_CONFD_NETWORKING} = true ]]
714   then   then
715   ${rc_base}/init.d/network stop   ${rc_base}/init.d/network stop
716   else   else
717   echo -e ${COLOREDSTAR}"Stopping default dhcp based networking ... "${COLDEFAULT}   rc_print "Stopping default dhcp based networking ... "
718   ifconfig eth0 down   ifconfig eth0 down
719   fi   fi
720   if [[ ! -z $(pidof udhcpc) ]]   if [[ ! -z $(pidof udhcpc) ]]
# Line 734  reset_system_settings() Line 735  reset_system_settings()
735  {  {
736   # force load of de kbdkeys   # force load of de kbdkeys
737   loadkeys -q de   loadkeys -q de
738   echo   rc_echo
739   echo -en ${COLRED}   rc_echo -en ${COLRED}
740   echo -n "*** Warning: you are about to reset *all* local settings on this system!"   rc_echo -n "*** Warning: you are about to reset *all* local settings on this system!"
741   echo -e ${COLDEFAULT}   rc_echo -e ${COLDEFAULT}
742   echo "*** Do you really want to continue ?"   rc_echo "*** Do you really want to continue ?"
743   echo -n "*** Enter 'yes' to continue, anything else to abort: "   rc_echo -n "*** Enter 'yes' to continue, anything else to abort: "
744   read kbinsert   read kbinsert
745   if [[ ${kbinsert} = yes ]]   if [[ ${kbinsert} = yes ]]
746   then   then
747   echo -en ${COLRED}   rc_echo -en ${COLRED}
748   echo -n "*** OK, you really want it ... killing all settings: "   rc_echo -n "*** OK, you really want it ... killing all settings: "
749   for i in 3 2 1 now   for i in 3 2 1 now
750   do   do
751   echo -n " ${i}"   rc_echo -n " ${i}"
752   sleep 1   sleep 1
753   done   done
754   echo -e ${COLDEFAULT}   rc_echo -e ${COLDEFAULT}
755    
756   ## reset all settings:   ## reset all settings:
757   rm -rf ${SETTINGSPATH}/*   rm -rf ${SETTINGSPATH}/*
# Line 776  reset_system_settings() Line 777  reset_system_settings()
777   # restore default networking   # restore default networking
778   cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0   cat ${ALX_SKELETONS}/net/net.eth0 > /etc/conf.d/net.eth0
779    
780   echo "I am done now, press [Enter] to reboot system ..."   rc_echo "I am done now, press [Enter] to reboot system ..."
781   else   else
782   echo "Aborted, press [Enter] to reboot system ..."   rc_echo "Aborted, press [Enter] to reboot system ..."
783   fi   fi
784   read   read
785   reboot   reboot
# Line 911  case $1 in Line 912  case $1 in
912   echo "Usage: $0 {start|stop} ..."   echo "Usage: $0 {start|stop} ..."
913   ;;   ;;
914  esac  esac
   

Legend:
Removed from v.2140  
changed lines
  Added in v.2141