home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 16 / hacker16 / 16_HACKER16.ISO / linux / tpm-security-server-1.2.1.iso / archive / etc / rc.d / init.d / ifup < prev    next >
Encoding:
Text File  |  2004-01-29  |  2.2 KB  |  123 lines

  1. #!/bin/sh
  2.  
  3. . $1
  4.  
  5. if [ "x$ONBOOT" = "xno" ] ; then
  6.     echo "Interface $DEVICE will not be activated."
  7.     exit -1
  8. fi
  9.  
  10. if [ "x$WIRELESS" = "xyes" ] ; then
  11.     echo -n "Trying to set up wireless on $DEVICE"
  12.     CMDLINE="$DEVICE"
  13.  
  14.     if [ "x$WIRELESS_NICK" != "x" ] ; then
  15.         CMDLINE="$CMDLINE nick \"$WIRELESS_NICK\""
  16.     fi
  17.  
  18.     if [ "x$WIRELESS_MODE" != "x" ] ; then
  19.         CMDLINE="$CMDLINE mode \"$WIRELESS_MODE\""
  20.     fi
  21.  
  22.     if [ "x$WIRELESS_CHANNEL" != "x" ] ; then
  23.         CMDLINE="$CMDLINE channel \"$WIRELESS_CHANNEL\""
  24.     fi
  25.  
  26.     CMDLINEANYESSID="$CMDLINE essid any"
  27.     if [ "x$WIRELESS_ESSID" != "x" ] ; then
  28.         CMDLINE="$CMDLINE essid \"$WIRELESS_ESSID\""
  29.     fi
  30.  
  31.     iwconfig $CMDLINE
  32.     sleep 2
  33. fi
  34.  
  35.  
  36. echo -n "Trying to activate $DEVICE..."
  37. ifconfig $DEVICE 2>>/dev/null 1>>/dev/null
  38. if [ $? -ne 0 ] ; then
  39.     echo "could not activate"
  40.     exit -1
  41. fi
  42. echo "activated!"
  43.  
  44.  
  45.  
  46. if [ "x$WIRELESS" = "xyes" ] ; then
  47.     if [ "x$WIRELESS_KEY" != "x" ] ; then
  48.         iwconfig $DEVICE key $WIRELESS_KEY
  49.         iwconfig $DEVICE key restricted
  50.     fi
  51.  
  52.     iwconfig $CMDLINEANYESSID
  53.     sleep 10
  54.  
  55.     iwconfig $CMDLINE
  56. fi
  57.  
  58.  
  59.  
  60. # Check if DHCP should be used for interface
  61. if [ "x$BOOTPROTO" = "xdhcp" ] ; then
  62.     echo -n "Looking for DHCP address..."
  63.     if dhcpcd -t 5 $DEVICE ; then
  64.         echo "found DHCP address"
  65.         let ACTIVEIP++
  66.     else
  67.         echo "Could not find DHCP address"
  68.     fi
  69.     exit -1
  70. fi
  71.  
  72. # At this point, BOOTPROTO is assumed to be static,
  73. # So try to use the IP configuration information
  74. if [ "x$IPADDR" = "x" ] ; then
  75.     if [ "x$IPADDR_START" = "x" ] ; then
  76.         echo "No IP address specified for $DEVICE"
  77.         exit -1
  78.     else 
  79.         if [ "x$CLONENUM_START" = "x" ] ; then
  80.             CLONENUM=1
  81.         else
  82.             CLONENUM=$CLONENUM_START
  83.         fi
  84.         CMDLINE=""
  85.     fi
  86. else
  87.     CMDLINE="$DEVICE $IPADDR"            
  88.     CLONENUM=0
  89. fi
  90.  
  91.  
  92. if [ "x$NETMASK" != "x" ] ; then
  93.     CMDLINE="$CMDLINE netmask $NETMASK"
  94. fi
  95.  
  96. if [ "x$BROADCAST" != "x" ] ; then
  97.     CMDLINE="$CMDLINE broadcast $BROADCAST"
  98. fi
  99.  
  100.  
  101. if [ $CLONENUM -gt 0 ] ; then
  102.     NETADDR=`echo $IPADDR_START |cut -d. -f1-3`
  103.     HOSTADDR=`echo $IPADDR_START |cut -d. -f4`
  104.     ENDADDR=`echo $IPADDR_END |cut -d. -f4`
  105.     
  106.     for ((  ; HOSTADDR <= ENDADDR ; HOSTADDR++ )) ; do
  107.         echo "ifconfig $DEVICE:$CLONENUM $NETADDR.$HOSTADDR"
  108.         ifconfig $DEVICE:$CLONENUM $NETADDR.$HOSTADDR
  109.         let CLONENUM++
  110.  
  111.     done
  112.     
  113. else 
  114.     echo "ifconfig $CMDLINE"
  115.     ifconfig $CMDLINE
  116.     if [ $? -ne 0 ] ; then
  117.         exit -1
  118.     fi
  119. fi
  120.  
  121.  
  122. exit 0    
  123.