[slack-ru] Re: /etc/rc.d/rc.*

  • From: Пашев Игорь Николаевич <pashev.igor@xxxxxxxxxx>
  • To: slack-ru@xxxxxxxxxxxxx
  • Date: Tue, 16 Mar 2004 12:20:40 +0300

В сообщении от 15 Март 2004 13:34 Пашев Игорь Николаевич написал(a):
Кстати, у нас бывает DHCP-сервер в отключке, а IP очень нужен. Вот, что я 
сделал.

Изменения в  /etc/rc.d/rc.inet1
######################
# ETHERNET FUNCTIONS #
######################
Static_IP () {
        if [ ! "${IPADDR[$1]}" = "" ]; then # skip unconfigured interfaces
          # Determine broadcast address from the IP address and netmask:
          BROADCAST=`/bin/ipmask ${NETMASK[$1]} ${IPADDR[$1]} | cut -f 1 -d ' 
'`
          # Set up the ethernet card:
          echo "Configuring eth${1}:"
          echo "/sbin/ifconfig eth${1} ${IPADDR[$1]} broadcast ${BROADCAST} 
netmask ${NETMASK[$1]}"
          /sbin/ifconfig eth${1} ${IPADDR[$1]} broadcast ${BROADCAST} netmask 
${NETMASK[$1]}
        else
          if [ "$DEBUG_ETH_UP" = "yes" ]; then
            echo "eth${1} interface is not configured in /etc/rc.d/
rc.inet1.conf"
          fi
        fi
}


# Function to bring up an Ethernet interface.  If the interface is
# already up or does not yet exist (perhaps because the kernel driver
# is not loaded yet), do nothing.
eth_up() {
  # If the interface isn't in the kernel yet (but there's an alias for it in
  # modules.conf), then it should be loaded first:
  if ! grep eth${1}: /proc/net/dev 1> /dev/null ; then # no interface yet
    if /sbin/modprobe -c | grep -w "alias eth${1}" | grep -vw "alias eth${1} 
off" > /dev/null ; then
      /sbin/modprobe eth${1}
    fi
  fi
  if grep eth${1}: /proc/net/dev 1> /dev/null ; then # interface exists
    if ! /sbin/ifconfig | grep "eth${1} " 1> /dev/null ; then # interface not 
up    
      if [ "${USE_DHCP[$1]}" = "yes" ]; then # use DHCP to bring interface up
        echo "Use DHCP to bring interface up"
        if [ ! "${DHCP_HOSTNAME[$1]}" = "" ]; then
          /sbin/dhcpcd -t 10 -h ${DHCP_HOSTNAME[$1]} -d eth${1}
        else
          /sbin/dhcpcd -t 10 -d eth${1}
        fi
        if ! /sbin/ifconfig | grep "eth${1} " 1> /dev/null ; then # interface 
still 
not up
            Static_IP ${1}
        fi    
      else # bring up interface using a static IP address
        Static_IP ${1}
      fi
    else
      if [ "$DEBUG_ETH_UP" = "yes" ]; then
        echo "eth${1} is already up, skipping"
      fi
    fi 
  else
    if [ "$DEBUG_ETH_UP" = "yes" ]; then
      echo "eth${1} interface does not exist (yet)"
    fi
  fi
}

Изменения в  /etc/rc.d/rc.inet1.conf
# Config information for eth0:
IPADDR[0]="192.168.205.137"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]="yes" # <--- !
DHCP_HOSTNAME[0]=""

-- 
Никогда не было, чтобы чего-нибудь не было,
всегда было, чтобы что-нибудь было.


Other related posts: