Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a clean install of Mythbuntu 11.10 acting as a frontend only. It is networked using eth0 and I have a router acting as a DHCP server on the same subnet.

The frontend boots and automatically logs on and runs Myth frontend.

However approximated every 3 out of 4 boots, the box has not yet obtained an IP address via DHCP before myth starts. This causes Myth to enter a configuration mode. If I cancel out, then Myth starts normally, as the DHCP response has been received.

How do I change the boot to wait for a DHCP response before logging on?

share|improve this question

2 Answers 2

Three options for you, ranging from manual-but-easy to manual-and-need-a-doctorate (in that progression).

1. Don't use DHCP.

Allocate a static IP in your router (so it doesn't give that IP to another device) and then configure Ubuntu to use that static address. You can do that either with Network Manager (if you're using that) or by editing /etc/network/interfaces with something like this:

auto eth0
iface eth0 inet static
        address 192.168.0.4
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1

2. Have something sit and wait for your network to come up and have an IP

I'm talking about writing a script that checks to see if your network card is up. For simplicity you could combine whatever launches XBMC with a check like (stolen from the forums):

#!/bin/bash

until wget -q -O - http://www.google.com | grep Lucky > /dev/null; do
    sleep 10
done

xbmc

And call that script instead of calling xmbc directly.

3. Play around with Upstart and break it to do your will.

Upstart is what manages all the system things and manages when things run based on events that each job emits. This seems like the most pleasing route for you because you might be able to make it emit a signal exactly when it has a DHCP address assigned.

The problem is you'll have to really dig into the boot process to alter things. I don't know enough about it to reasonably help.

share|improve this answer
    
Thanks for your pointers; I did some investigating around upstart. I've put my solution in my answer below –  Andy Hitchman Oct 19 '11 at 8:25
up vote 1 down vote accepted

Thanks Oli, I went with your option 3, which I'll describe here in case anyone else is interested:

  1. Uninstall the network manager in xmbc (not sure this is essential, but I don't need it):

    # apt-get remove network-manager
    
  2. Configure /etc/network/interfaces by adding:

    auto eth0
    iface eth0 inet dhcp
    
  3. Tell lightdm so start only when an interface other than loopback comes up, in additional to the existing trigger conditions, by changing the start trigger in /etc/init/lightdm.conf

    start on ((filesystem
       and runlevel [!06]
       and started dbus
       and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
            or stopped udev-fallback-graphics)
       and net-device-up IFACE!=lo) 
      or runlevel PREVLEVEL=S)
    

I added the condition net-device-up IFACE!=lo.

So far it seems to work well.

share|improve this answer
    
That wasn't nearly as hideous as I'd feared it might be. Congratulations. –  Oli Oct 19 '11 at 18:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.