Subject: rc.d and dhclient and dhclient-exit-hooks
To: None <tech-userlevel@netbsd.org>
From: Michael Richardson <mcr@sandelman.ottawa.on.ca>
List: tech-userlevel
Date: 09/11/2001 23:56:46
-----BEGIN PGP SIGNED MESSAGE-----


  I been trying to figure out why my notebook hangs if I let it start amd.
[What specifically happens is that it lets me login, and start some windows,
but all the shells hang]. It doesn't happen if I login and start amd manually.

  The way that I have things configured is that I use
/etc/dhclient-exit-hooks to select various configurations based upon what
IP I got (deducing that amd should only be run on my home network).

  (not-conf is used to set up IPsec SPD when I'm not at home...)

  I realized on my way home today what the problem may be. 
  Looking at the output of rcorder, it appears that dhclient gets started
before rpcbind, named, etc. As the dhclient script will start amd (via
"/etc/rc.d/amd forcestart") some period later, it is probably starting at a
random time, and likely before something it needs has started properly.
  
  So, what I really need is a way for an rc script to indicate that it
has more stuff to do, but it needs to defer until later ("the end") would be
fine. Moving dhclient to the end makes sense once all the daemons have an
event system to listen to so that they can discover that there are new
interfaces, etc..

  I'm looking for suggestions/thoughts/etc.
  
Here is my /etc/dhclient-exit-hooks
  
gotip() {
        if [ x$new_ip_address != x ] ; then

          # take "$new_ip_address" and look for scripts to run
          # in /etc/dhclient/when-conf and /etc/dhclient/when-notconf

          if [ -f /etc/dhclient/when-conf/$new_ip_address ]
          then
                echo Running /etc/dhclient/when-conf/$new_ip_address
                sh /etc/dhclient/when-conf/$new_ip_address $new_ip_address
          fi

          /bin/ls /etc/dhclient/when-notconf | grep -v $new_ip_address | while r
ead conf
          do
                echo Running /etc/dhclient/when-notconf/$conf
                sh /etc/dhclient/when-notconf/$conf $new_ip_address
          done
        fi
}

case $reason in
        BOUND) gotip;;
        REBOOT) gotip;;
esac

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: latin1
Comment: Processed by Mailcrypt 3.5.6, an Emacs/PGP interface

iQCVAwUBO57c/YqHRg3pndX9AQGqqwP9FJzislD1ZKRpYBDnAcfECj9CMdHF0t9D
N8q9MknF/R8CFfNmBoaLlkAaCU/tmMoegwgkIu63FKpLIWdA3ptEWi71/y76yCbA
CVMDxXuL4cJkyA9gLrynvcRsThakUC8n0QDUqzovn6TVwPKglNYT0nezUXTC5GJ2
pZ95tPY1+c4=
=hQ6u
-----END PGP SIGNATURE-----