On Fri, Nov 16, 2012 at 11:23 AM, Darethehair <span dir="ltr">&lt;<a href="mailto:darethehair@gmail.com" target="_blank">darethehair@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div class="im">
    On 16/11/12 10:41 AM, Thomas Mashos wrote:<br>
    <blockquote type="cite">That doesn&#39;t make sense, there is nothing that would
      have the NetworkManager depend on the backend to start (the
      networking start scripts are what is used in regular Ubuntu
      without any MythTV). What happens if you remove the script you
      added to check the network and then just stuck a &#39;<span style="line-height:1.1em;background-color:rgb(249,249,249)">sleep
        300&#39; (5 minutes) in the backend upstart script right before the
        backend starts?</span>
      <div class="gmail_extra"><br clear="all">
        Thanks,<br>
        <br>
        Thomas Mashos<br>
      </div>
    </blockquote></div>
    Adding a 300s delay in the &#39;mythtv-backend&#39; script just makes the
    boot take 5 minutes longer -- including the start of the
    &#39;network-manager&#39; :(<br>
    <br>
    However, through some deep digging, I have found a solution -- and I
    am very curious whether (at least part of) this could be applied to
    future packaging of MythTV to avoid problems for others...<br>
    <br>
    In my case, there were two parts to the solution:<br>
    <br>
    1) An understanding that Linux Debian has moved to a &#39;dependency
    based boot sequence&#39; methology:<br>
    <br>
    <a href="http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot" target="_blank">http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot</a><br>
    <a href="http://wiki.debian.org/LSBInitScripts" target="_blank">http://wiki.debian.org/LSBInitScripts</a><br>
    <br>
    Previously, it used an older (SysV?) approach where the scripts in
    the various runlevel &#39;rcN.d&#39; directories were run in alphabetic
    order.  In this older system, I also would have had problems, since
    &#39;S21m&#39; occurs before &#39;S21n&#39;:<br>
    <br>
    darren@frodo2 /etc/rc2.d $ ls -1<br>
    ...<br>
    S21mythtv-backend<br>
    S21network-manager<br>
    ...<br>
    <br>
    OK, so I checked what the newer &#39;LSB&#39; fields were in the
    &#39;mythtv-backend&#39; script:<br>
    <br>
    ### BEGIN INIT INFO<br>
    # Provides:          mythtv-backend<br>
    # Required-Start:    $local_fs $remote_fs <br>
    # Required-Stop:     $local_fs $remote_fs <br>
    # Should-Start:      mysql<br>
    # Should-Stop:       mysql<br>
    # Default-Start:     2 3 4 5<br>
    # Default-Stop:      0 1 6<br>
    # Short-Description: Start/Stop the MythTV server.<br>
    ### END INIT INFO<br>
    <br>
    I changed it slightly so that &#39;network-manager&#39; is a &#39;required&#39;
    prerequisite:<br>
    <br>
    ### BEGIN INIT INFO<br>
    # Provides:          mythtv-backend<br>
    # Required-Start:    $local_fs $remote_fs network-manager<br>
    # Required-Stop:     $local_fs $remote_fs network-manager<br>
    # Should-Start:      mysql<br>
    # Should-Stop:       mysql<br>
    # Default-Start:     2 3 4 5<br>
    # Default-Stop:      0 1 6<br>
    # Short-Description: Start/Stop the MythTV server.<br>
    ### END INIT INFO<br>
    <br>
    I then ran the following command (I think it is required after
    making script changes like that):<br>
    <br>
    darren@frodo2 /etc/init.d $ sudo update-rc.d mythtv-backend defaults<br>
    <br>
    This appears to have changed the naming of the script in
    &#39;/etc/rc2.d&#39; so that it is alphabetically *after* the network start:<br>
    <br>
    darren@frodo2 /etc/rc2.d $ ls -1<br>
    ...<br>
    S21network-manager<br>
    ...<br>
    S22mythtv-backend<br>
    ...<br>
    <br>
    A reboot confirms the new order:<br>
    <br>
    darren@frodo1 /etc/rc2.d $ sudo sed $&#39;s/\^\[/\E/g;s/\[1G\[/\[27G\[/&#39;
    /var/log/boo<br>
    ...<br>
    Fri Nov 16 12:57:01 2012: [ ok ] Starting MySQL database server:
    mysqld . ..<br>
    Fri Nov 16 12:57:05 2012: [info] Checking for tables which need an
    upgrade, are corrupt or were <br>
    Fri Nov 16 12:57:05 2012: not closed cleanly..<br>
    Fri Nov 16 12:57:05 2012: [ ok ] Starting network connection
    manager: NetworkManager.<br>
    Fri Nov 16 12:57:06 2012: [ ok ] Starting MDM Display Manager: mdm.<br>
    Fri Nov 16 12:57:16 2012: Starting MythTV server: mythbackend .<br>
    ...<br>
    <br>
    I found out from experimention that merely manually renaming the
    scripts in &#39;/etc/rc2.d&#39; wasn&#39;t good enough -- those &#39;LSB&#39; fields are
    required.<br>
    <br>
    Not sure what the (say) Ubuntu scripts order system is, so I think
    that what I said above doesn&#39;t apply to those folks.<br>
    <br>
    2) Though I was very optimistic that the above would solve all my
    problems, it did not.  Apparently, waiting for &#39;network-manager&#39; to
    start isn&#39;t quite good enough.  So I added my home-made script back
    into &#39;mythtv-backend&#39;:<br>
    <br>
    #! /bin/sh<br>
    /usr/local/bin/wait4net.sh 60 &gt; /tmp/wait4net.out 2&gt;
    /tmp/wait4net.err<br>
    ...<br>
    <br>
    After rebooting again, I saw the fruits of my labors i.e. it took
    about another 5s for the wireless IP address to be established:<br>
    <br>
    darren@frodo1 /etc/init.d $ cat /tmp/wait4net.out<br>
    Fri Nov 16 12:57:12 CST 2012 not yet! attempt: 1<br>
    Fri Nov 16 12:57:13 CST 2012 not yet! attempt: 2<br>
    Fri Nov 16 12:57:14 CST 2012 not yet! attempt: 3<br>
    Fri Nov 16 12:57:15 CST 2012 not yet! attempt: 4<br>
    Fri Nov 16 12:57:16 CST 2012 not yet! attempt: 5<br>
    Fri Nov 16 12:57:16 CST 2012 success! after attempt: 6<br>
    ...<br>
    wlan1     Link encap:Ethernet  HWaddr 00:14:d1:36:cf:c8  <br>
              inet addr:192.168.1.101  Bcast:192.168.1.255 
    Mask:255.255.255.0<br>
              inet6 addr: fe80::214:d1ff:fe36:cfc8/64 Scope:Link<br>
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br>
              RX packets:3 errors:0 dropped:0 overruns:0 frame:0<br>
              TX packets:7 errors:0 dropped:0 overruns:0 carrier:0<br>
              collisions:0 txqueuelen:1000 <br>
              RX bytes:670 (670.0 B)  TX bytes:1114 (1.0 KiB)<br>
    <br>
    On my remote frontend, &#39;mythfrontend&#39; started up fine with no more
    connection errors!<br>
    <br>
    Comments anyone?  Does part #1 of my solution make sense for Debian
    folks running MythTV?<br>
    <br>
    Thanks<br>
    <br>
  </div>

</blockquote></div><br></div><div class="gmail_extra">Sorry for the confusion. I responded to Nick Rout claiming this should be resolved by the Ubuntu/Debian packagers, and confused what we were talking about (which is Linux Mint Debian Edition).</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Debian does not use Upstart by default, so anything I&#39;ve said mentioning the Upstart scripts won&#39;t apply unless you&#39;ve switched it to use Upstart rather than Sysvinit. Because of this you&#39;ve got to muck around with these startup scripts to get everything set in the proper order with enough delays so everything can start properly.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Ubuntu uses Upstart, so (obviously) anything I&#39;ve said about Upstart applies here, including the bits where the MythTV Backend startup scripts DEPEND on the networking stack to be up. Thus if the OP had been using Ubuntu, this wouldn&#39;t have happened (unless the stack was up, but the DHCP server was really slow to give out an address).</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">So in conclusion, my bad for forgetting the OS we were talking about.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks,<br><br>Thomas Mashos<br>

</div>