1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/bin/sh
#******************************************************************
#ident /etc/netenv/netenv_setup Time-stamp: <03/03/31 08:47:21 bav>
#******************************************************************
# Gerd Bavendiek bav@epost.de 03-03-11
#
# If there is a variable NETENV_SCRIPT pointing to this executable
# file, netenv will source this script during boot.
#
# This is an Debian-only example. It creates an
# /etc/network/interfaces in a hopefully safe manner.
# This way non PCMCIA-NIC-users can use netenv on Debian without
# further configuration steps.
#------------------------------------------------------------------
print_action()
{
echo -e netenv: $* " ... \c"
}
print_status()
{
if [ $? -eq 0 ]; then
echo done
else
echo failed
fi
}
if ! grep Debian /etc/issue >/dev/null 2>&1; then
print_action Doing nothing, as this is obviously no Debian
echo
exit 0
fi
# Save /etc/network/interfaces if it has not been created by netenv
if grep netenv /etc/network/interfaces >/dev/null 2>&1; then
cp -p /etc/network/interfaces /etc/network/interfaces.pre-netenv
print_action /etc/network/interfaces was backuped as /etc/network/interfaces.pre-netenv
fi
print_action creating new /etc/network/interfaces
(
echo "# /etc/network/interfaces autogenerated by netenv "`date`
echo "# old /etc/network/interfaces backup as /etc/network/interfaces.pre-netenv"
echo auto lo
echo iface lo inet loopback
echo auto eth0
if [ "$BOOTPROTO" = "dhcp" ]; then
echo iface eth0 inet dhcp
else
echo iface eth0 inet static
echo address $IPADDR
echo netmask $NETMASK
echo network $NETWORK
echo broadcast $BROADCAST
echo gateway $GATEWAY
fi
) > /etc/network/interfaces
print_status done
|