Author: pebender
Date: Sat Jan  3 10:24:50 2009
New Revision: 4160

Modified:
    trunk/gar-minimyth/html/minimyth/document-changelog.txt
     
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/conf
     
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/dhcp
     
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/conf.pm
     
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/dhcp.pm

Log:
- Fixed a bug that could cause the DHCP client to not restart correctly
   when being restarted so that it would use the DHCP override variables in
   minimyth.conf.



Modified: trunk/gar-minimyth/html/minimyth/document-changelog.txt
==============================================================================
--- trunk/gar-minimyth/html/minimyth/document-changelog.txt     (original)
+++ trunk/gar-minimyth/html/minimyth/document-changelog.txt     Sat Jan  3  
10:24:50 2009
@@ -1,7 +1,7 @@
  MiniMyth Changelog

   
--------------------------------------------------------------------------------
-Changes since 62 (2009-01-02):
+Changes since 62 (2009-01-03):

  Current MythTV versions
      MythTV 0.20-softpad: version 0.20.2.softpad, release-0-20-fixes branch  
svn 16082,
@@ -59,6 +59,9 @@
        enabled in minimyth.conf but no bluetooth device was present.
      - Fixed a bug that cuased MM_VIDEO_RESIZE_ENABLED to default to 'no'
        rather than ''.
+    - Fixed a bug that could cause the DHCP client to not restart correctly
+      when being restarted so that it would use the DHCP override  
variables in
+      minimyth.conf.

  Modified build system
      - Enabled building of wmgui in utils/cwiid package.

Modified:  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/conf
==============================================================================
---  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/conf
      
(original)
+++  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/conf
      
Sat Jan  3 10:24:50 2009
@@ -140,7 +140,7 @@
          . /etc/rc.d.sh/init.d/conf.d/${file}
      done

-    # Restart the DHCP client in order to pick up the processed DHCP  
override variables.
+    # Start the DHCP client now that we have created the DHCP override  
variables file.
      /etc/rc.d.sh/init.d/dhcp start

      # Clean configuration processing file state.

Modified:  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/dhcp
==============================================================================
---  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/dhcp
      
(original)
+++  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d.sh/init.d/dhcp
      
Sat Jan  3 10:24:50 2009
@@ -6,6 +6,7 @@

  start() {

+    local COMMAND
      local DHCLIENT_CONF
      local INTERFACE
      local INTERFACE_ITEM
@@ -14,25 +15,24 @@

      UDHCPC_CONF='/etc/udhcpc.conf'

-    # Create a 'udhcpc.conf' file.
-    /bin/rm -f "${UDHCPC_CONF}~"
-    /bin/mkdir -p "`/usr/bin/dirname ${UDHCPC_CONF}~`"
-    /bin/touch "${UDHCPC_CONF}~"
-    /bin/chmod 644 "${UDHCPC_CONF}~"
-    set | /bin/grep -e '^MM_DHCP_' > "${UDHCPC_CONF}~"
-    /bin/mv -f "${UDHCPC_CONF}~" "${UDHCPC_CONF}"
-
-    # If 'udhcpc' is running, then stop it.
-    if /usr/bin/test -n "`/bin/pidof udhcpc`" ; then
-        mm_message_output info "stopping DHCP client ..."
-        while /usr/bin/test -n "`/bin/pidof udhcpc`" 2> /dev/null ; do
-            /usr/bin/killall udhcpc
-        done
-    fi
-
      # Start 'udhcpc'.
      if /usr/bin/test -z "`/bin/pidof udhcpc`" ; then
          mm_message_output info "starting DHCP client ..."
+
+        # Create a 'udhcpc.conf' file.
+        /bin/rm -f "${UDHCPC_CONF}~"
+        /bin/mkdir -p "`/usr/bin/dirname ${UDHCPC_CONF}~`"
+        /bin/touch "${UDHCPC_CONF}~"
+        /bin/chmod 644 "${UDHCPC_CONF}~"
+        set | /bin/grep -e '^MM_DHCP_' > "${UDHCPC_CONF}~"
+        /bin/mv -f "${UDHCPC_CONF}~" "${UDHCPC_CONF}"
+
+        COMMAND='/sbin/udhcpc'
+        COMMAND="${COMMAND} -S"
+        COMMAND="${COMMAND} -p /var/run/udhcpc.pid"
+        COMMAND="${COMMAND} -s /etc/udhcpc.script"
+
+        # Determine network interface.
          INTERFACE=${MM_NETWORK_INTERFACE}
          if /usr/bin/test -z "${INTERFACE}" ; then
              # Locate a connected network interface.
@@ -54,14 +54,23 @@
              mm_message_output info "no network interface found, defaulting  
to 'eth0'."
              INTERFACE='eth0'
          fi
+        COMMAND="${COMMAND} -i ${INTERFACE}"

-        # Start DHCP on the interface.
+        # Reuse any existing IP address.
          IP_ADDRESS=`/sbin/ifconfig ${INTERFACE} | /bin/grep '^ *inet  
addr:' | /bin/sed 's%^ *inet addr:\([^ ]*\) .*%\1%'`
-        if /usr/bin/test -z "${IP_ADDRESS}" ; then
-            /sbin/udhcpc -S -p /var/run/udhcpc.pid -s /etc/udhcpc.script  
-i ${INTERFACE}                  > /var/log/udhcpc 2>&1
-        else
-            /sbin/udhcpc -S -p /var/run/udhcpc.pid -s /etc/udhcpc.script  
-i ${INTERFACE} -r ${IP_ADDRESS} > /var/log/udhcpc 2>&1
+        if /usr/bin/test -n "${IP_ADDRESS}" ; then
+            COMMAND="${COMMAND} -r ${IP_ADDRESS}"
          fi
+
+        # Decide whether or not to run once.
+        if /usr/bin/test ! -e /etc/conf.d/dhcp.override ; then
+            COMMAND="${COMMAND} -q"
+        fi
+
+        COMMAND="${COMMAND} > /var/log/udhcpc 2>&1"
+
+        # Start DHCP client on the interface.
+        ${COMMAND}
          if /usr/bin/test $? -ne 0 ; then
              mm_message_output err "error: DHCP on interface '${INTERFACE}'  
failed."
              exit 1

Modified:  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/conf.pm
==============================================================================
---  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/conf.pm
        
(original)
+++  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/conf.pm
        
Sat Jan  3 10:24:50 2009
@@ -127,7 +127,7 @@
      $self->_run($minimyth, 'MM_DHCP_.*');
      $minimyth->var_save({ 'file' => '/etc/conf.d/dhcp.override', 'filter'  
=> 'MM_DHCP_.*' });

-    # Restart the DHCP client in order to pick up the processed DHCP  
override variables.
+    # Start the DHCP client now that we have created the DHCP override  
variables file.
      require init::dhcp;
      init::dhcp->start($minimyth);


Modified:  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/dhcp.pm
==============================================================================
---  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/dhcp.pm
        
(original)
+++  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/etc/rc.d/init/dhcp.pm
        
Sat Jan  3 10:24:50 2009
@@ -9,22 +9,28 @@

  require MiniMyth;

+# If there is no DHCP override variables file (/etc/conf.d/dhcp.override)  
then
+# this routine will cause the DHCP client to run once and quit. Whereas, if
+# there is a DHCP override variables file, then this routine will cause  
the DHCP
+# client to run continuously.
  sub start
  {
      my $self     = shift;
      my $minimyth = shift;

-    # Create a 'udhcpc.conf' file.
-    $minimyth->var_save({ file => '/etc/udhcpc.conf', filter  
=> 'MM_DHCP_.*' });
-
-    # If 'udhcpc' is running, then stop it.
-    $self->stop($minimyth);
-
      # Start 'udhcpc'.
      if (! $minimyth->application_running('udhcpc'))
      {
          $minimyth->message_output('info', "starting DHCP client ...");

+        # Create a 'udhcpc.conf' file.
+        $minimyth->var_save({ file => '/etc/udhcpc.conf', filter  
=> 'MM_DHCP_.*' });
+
+        my $command = q(/sbin/udhcpc);
+        $command = $command . ' ' .  q(-S);
+        $command = $command . ' ' .  q(-p /var/run/udhcpc.pid);
+        $command = $command . ' ' .  q(-s /etc/udhcpc.script);
+
          # Determine network interface.
          my $interface = $minimyth->var_get('MM_NETWORK_INTERFACE');
          if (! $interface)
@@ -49,8 +55,9 @@
                  $interface = 'eth0';
              }
          }
+        $command = $command . ' ' . qq(-i $interface);

-        # Start DHCP on the interface.
+        # Reuse any existing IP address.
          my $ip_address = '';
          if ((-x '/sbin/ifconfig') &&
              (open(FILE, '-|', "/sbin/ifconfig $interface")))
@@ -62,21 +69,24 @@
              }
              close(FILE);
          }
-        if (! $ip_address)
+        if ($ip_address)
          {
-            if (system(qq(/sbin/udhcpc -S -p /var/run/udhcpc.pid -s  
/etc/udhcpc.script -i $interface                > /var/log/udhcpc 2>&1)) !=  
0)
-            {
-                $minimyth->message_output('err', "error: DHCP on  
interface '$interface' failed.");
-                return 0;
-            }
+            $command = $command . ' ' . qq(-r $ip_address);
          }
-        else
+
+        # Decide whether or not to run once.
+        if (! -e '/etc/conf.d/dhcp.override')
          {
-            if (system(qq(/sbin/udhcpc -S -p /var/run/udhcpc.pid -s  
/etc/udhcpc.script -i $interface -r $ip_address > /var/log/udhcpc 2>&1)) !=  
0)
-            {
-                $minimyth->message_output('err', "error: DHCP on  
interface '$interface' failed.");
-                return 0;
-            }
+            $command = $command . ' ' . qq(-q);
+        }
+
+        $command = $command . ' ' .  q(> /var/log/udhcpc 2>&1);
+
+        # Start DHCP client on the interface.
+        if (system($command) != 0)
+        {
+            $minimyth->message_output('err', "error: DHCP on  
interface '$interface' failed.");
+            return 0;
          }

          # Make sure we got an IP address.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"minimyth-commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/minimyth-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to