home *** CD-ROM | disk | FTP | other *** search
/ HAKERIS 11 / HAKERIS 11.ISO / linux / system / LinuxConsole 0.4 / linuxconsole0.4install-en.iso / linuxconsole0.4.lcm / etc / hotplug / net.agent2 < prev    next >
Encoding:
Text File  |  2004-03-26  |  2.0 KB  |  85 lines

  1. #!/bin/bash
  2. #
  3. # Network hotplug policy agent for Linux 2.4 kernels
  4. #
  5. # Kernel NET hotplug params include:
  6. #    
  7. #    ACTION=%s [register or unregister]
  8. #    INTERFACE=%s
  9. #
  10. # HISTORY:
  11. #
  12. # 25-Feb-2001    Special case ppp and similar (redhat)
  13. # 23-Jan-2001    Log invocation of "ifup" if debugging
  14. # 04-Jan-2001    Initial version of "new" hotplug agent.
  15. #
  16. # $Id: net.agent,v 1.9 2001/09/07 15:57:39 dbrownell Exp $
  17. #
  18.  
  19. cd /etc/hotplug
  20. . hotplug.functions
  21. # DEBUG=yes export DEBUG
  22.  
  23. if [ "$INTERFACE" = "" ]; then
  24.     mesg Bad NET invocation: \$INTERFACE is not set
  25.     exit 1
  26. fi
  27.  
  28. case $ACTION in
  29. register)
  30.  
  31.     case $INTERFACE in
  32.     # interfaces that are registered after being "up" (?)
  33.     ppp*|ippp*|isdn*|plip*|lo*|irda*|tunl*)
  34.         debug_mesg assuming $INTERFACE is already up
  35.         exit 0
  36.         ;;
  37.     # interfaces that are registered then brought up
  38.     *)
  39.         # conform to network service
  40.         [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
  41.         
  42.         CFG=/etc/sysconfig/network-scripts/ifcfg-$INTERFACE
  43.         PCMCIA=/var/lib/pcmcia/stab
  44.         
  45.         if [ "$AUTOMATIC_IFCFG" != no -a "${INTERFACE:0:3}" == "eth" -a ! -r $CFG ]; then
  46.         if [ -r $PCMCIA ] && grep -q "$INTERFACE$" $PCMCIA; then
  47.             ONBOOT=no
  48.         else
  49.             ONBOOT=yes
  50.         fi
  51.         debug_mesg creating config file for $INTERFACE
  52.         cat > $CFG <<EOF
  53. DEVICE=$INTERFACE
  54. BOOTPROTO=dhcp
  55. ONBOOT=$ONBOOT
  56. EOF
  57.             fi
  58.  
  59.         if [ -r $CFG ]; then
  60.         # Mandrake Linux and similar
  61.         if [ "${INTERFACE:0:3}" == "eth" -a -x /sbin/ifplugd ] && ! grep -q '^MII_NOT_SUPPORTED' $CFG; then
  62.             IFPLUGD_ARGS="${IFPLUGD_ARGS=-w -b}"
  63.             debug_mesg invoke ifplugd $INTERFACE
  64.             exec /sbin/ifplugd $IFPLUGD_ARGS -i $INTERFACE >/dev/null
  65.         fi
  66.         
  67.         # RedHat and similar
  68.         if [ -x /sbin/ifup ]; then
  69.             debug_mesg invoke ifup $INTERFACE
  70.             exec /sbin/ifup $INTERFACE >/dev/null
  71.         else
  72.             mesg "how do I bring interfaces up on this distro?"
  73.         fi
  74.         fi
  75.         ;;
  76.     esac
  77.     mesg $1 $ACTION event not handled
  78.     ;;
  79.  
  80. *)
  81.     debug_mesg NET $ACTION event not supported
  82.     exit 1 ;;
  83.  
  84. esac
  85.