mkimage-profiles/features.in/net-eth/rootfs/image-scripts.d/50-net-eth
Michael Shigorin 9d7538838c live, net-eth: add DHCP_TIMEOUT when appropriate
It's hardwired at 1/10 of the default /etc/net value
since 3 seconds are enough for properly functioning
DHCP servers in properly maintained networks (those
improper ones tend to have problems with 30 seconds
anyways), and waiting for too long makes users feel
bad for a reason.

Thanks msp@ for bringing attention to this.
2014-02-03 23:20:25 +04:00

55 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# parse interface configuration tuples:
# iface:proto[:ipv4addr/netmask[:ipv4gw]]
# and write it down as intended
fatal() { echo "error: $*" >&2; exit 1; }
# simple etcnet configurations are also picked up by NM
if type -t NetworkManager >&/dev/null ||
type -t connmand >&/dev/null; then
NMCTL=yes
else
NMCTL=no
fi
IFACEDIR="/etc/net/ifaces"
# uses global variables
write_iface() {
dir="$IFACEDIR/$iface"
mkdir -p "$dir"
append=
case "$proto" in
dhcp)
append="DHCP_TIMEOUT=3"
;;
static)
[ -n "$ipv4addr" ] || fatal "ipv4addr missing"
echo "$ipv4addr" > "$dir/ipv4address"
[ -z "$ipv4gw" ] ||
echo "default via $ipv4gw" > "$dir/ipv4route"
;;
*)
fatal "unknown proto value: $proto"
;;
esac
{
echo "TYPE=eth"
echo "DISABLED=no"
echo "BOOTPROTO=$proto"
echo "NM_CONTROLLED=$NMCTL"
echo "DISABLED=$NMCTL"
echo "#USE_IFPLUGD=yes"
[ -z "$append"] || echo "$append"
} > "$dir/options"
}
[ -z "$GLOBAL_NET_ETH" ] ||
echo "$GLOBAL_NET_ETH" \
| tr ' ' '\n' \
| while IFS=':' read iface proto ipv4addr ipv4gw; do
[ -n "$iface" -a -n "$proto" ] || continue
write_iface
done