#!/bin/sh # # This script sets up the /etc/network/interface file for the new # image. # # Steve # -- # http://www.steve.org.uk/ prefix=$1 dist=$2 # # Sets up the networking installation for Debian GNU/Linux. # function setupDebian { if [[ -z "${dhcp}" ]]; then # # We have a static IP address # cat <${prefix}/etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address ${ip} gateway ${gateway} netmask ${netmask} # post-up ethtool -K eth0 tx off # # The commented out line above will disable TCP checksumming which # might resolve problems for some users. It is disabled by default # E_O_STATIC else # # The host is using DHCP. # cat < ${prefix}/etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp # post-up ethtool -K eth0 tx off # # The commented out line above will disable TCP checksumming which # might resolve problems for some users. It is disabled by default # E_O_DHCP fi } # # Setup networking for CentOS4 # function setupCentOS4 { # # Test for static vs. DHCP # if [[ -z "${dhcp}" ]]; then cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=${ip} NETMASK=${netmask} GATEWAY=${gateway} E_O_STATIC else cat <${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes E_O_DHCP fi # # Don't forget to setup the default route. # cat <${prefix}/etc/sysconfig/network NETWORKING=yes GATEWAY=${gateway} HOSTNAME=${hostname} EOF } # # Entry point to the script. # case "${dist}" in sarge|etch|sid) setupDebian ;; centos4) setupCentOS4 ;; *) echo "Unknown distribution '${dist}'. Fixme"; exit; ;; esac