small fixes and config changes
[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 # installed 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 # Some example I read had stp on, but i don't need stp,
23 # and it causes a vm to fail pxe boot, presumably unless
24 # you add some delay.
25 # http://wiki.libvirt.org/page/PXE_boot_%28or_dhcp%29_on_guest_failed
26 iface br0 inet dhcp
27 bridge_ports $NIC1
28 bridge_stp off
29 bridge_maxwait 0
30 EOF
31 fi
32 elif [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
33 then
34 [ -n "$IPADDR" ] && cat > $target/etc/network/interfaces <<-EOF
35 # generated by FAI
36 auto lo $NIC1
37 iface lo inet loopback
38 iface $NIC1 inet static
39 address $IPADDR
40 netmask $NETMASK
41 broadcast $BROADCAST
42 gateway $GATEWAYS
43 hwaddress ether $(cat /sys/class/net/$NIC1/address)
44 EOF
45 [ -n "$NETWORK" ] && echo "localnet $NETWORK" > $target/etc/networks
46 if [ ! -L $target/etc/resolv.conf -a -e /etc/resolv.conf ]; then
47 cp -p /etc/resolv.conf $target/etc
48 fi
49 fi
50
51 # here fcopy is mostly used, when installing a client for running in a
52 # different subnet than during the installation
53 fcopy -iM /etc/resolv.conf
54 fcopy -iM /etc/network/interfaces /etc/networks
55
56 exit $error