use bridge interface by default
[automated-distro-installer] / fai / config / scripts / DEBIAN / 30-interface
1 #! /bin/bash
2
3 # modified from upstream fai example
4 error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
5
6 if ifclass DHCPC && [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
7 then
8 if ifclass VM; then
9 cat > $target/etc/network/interfaces <<-EOF
10 # generated by FAI
11 auto lo $NIC1
12 iface lo inet loopback
13 iface $NIC1 inet dhcp
14 EOF
15 else
16 cat > $target/etc/network/interfaces <<-EOF
17 # generated by FAI
18 auto lo br0
19 iface lo inet loopback
20 iface $NIC1 inet manual
21 # make a bridge by default so we can have bridged vms.
22 iface br0 inet dhcp
23 bridge_ports eth0
24 bridge_stp on
25 bridge_maxwait 0
26 bridge_fd 0
27 EOF
28 fi
29 elif [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
30 then
31 [ -n "$IPADDR" ] && cat > $target/etc/network/interfaces <<-EOF
32 # generated by FAI
33 auto lo $NIC1
34 iface lo inet loopback
35 iface $NIC1 inet static
36 address $IPADDR
37 netmask $NETMASK
38 broadcast $BROADCAST
39 gateway $GATEWAYS
40 hwaddress ether $(cat /sys/class/net/$NIC1/address)
41 EOF
42 [ -n "$NETWORK" ] && echo "localnet $NETWORK" > $target/etc/networks
43 if [ ! -L $target/etc/resolv.conf -a -e /etc/resolv.conf ]; then
44 cp -p /etc/resolv.conf $target/etc
45 fi
46 fi
47
48 # here fcopy is mostly used, when installing a client for running in a
49 # different subnet than during the installation
50 fcopy -iM /etc/resolv.conf
51 fcopy -iM /etc/network/interfaces /etc/networks
52
53 exit $error