#!/bin/sh
# executed by udhcpc
# parameters: $1 and environment
#
# $1 is:
# deconfig: This argument is used when udhcpc starts, and
# when a leases is lost. The script should put the interface in an
# up, but deconfigured state, ie: ifconfig $interface 0.0.0.0.
#
# bound: This argument is used when udhcpc moves from an
# unbound, to a bound state. All of the paramaters are set in
# enviromental variables, The script should configure the interface,
# and set any other relavent parameters (default gateway, dns server,
# etc).
#
# renew: This argument is used when a DHCP lease is renewed. All of
# the paramaters are set in enviromental variables. This argument is
# used when the interface is already configured, so the IP address,
# will not change, however, the other DHCP paramaters, such as the
# default gateway, subnet mask, and dns server may change.
#
# nak: This argument is used with udhcpc receives a NAK message.
# The script with the deconfig argument will be called directly
# afterwards, so no changes to the network interface are neccessary.
# This hook is provided for purely informational purposes (the
# message option may contain a reason for the NAK).
#
# env: set | grep '^[a-z]*=' shows something like:
# dhcptype=5
# dns=172.16.22.2
# interface=eth0
# ip=172.16.42.177
# lease=97200
# mask=24
# outfile=dhcp.out
# router=172.16.42.98
# serverid=172.16.42.102
# subnet=255.255.255.0

# Do not mess up cfg if nothing really changes
if test "$1" != "bound"; then
    exit
fi
    
ip a add dev $interface $ip/$mask brd +
ip l set dev $interface up
