Merge pull request #129 from BarbarossaTM/feature/dhcp-config
Rename dhcp related interface options to dhcp-* and allow interface specific config file
This commit is contained in:
commit
cef4fafdb9
3 changed files with 20 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
# some users provide a shell fragment for the hostname property.
|
||||
[ -n "$IF_HOSTNAME" ] && IF_HOSTNAME=$(eval echo $IF_HOSTNAME)
|
||||
[ -n "$IF_DHCP_HOSTNAME" ] && IF_DHCP_HOSTNAME=$(eval echo $IF_DHCP_HOSTNAME)
|
||||
|
||||
determine_implementation() {
|
||||
[ -n "$IF_DHCP_PROGRAM" ] && echo "$IF_DHCP_PROGRAM" && return
|
||||
|
@ -14,20 +14,25 @@ determine_implementation() {
|
|||
start() {
|
||||
case "$1" in
|
||||
dhcpcd)
|
||||
[ -n "$IF_HOSTNAME" ] && optargs="$optargs -h $IF_HOSTNAME"
|
||||
[ -n "$IF_VENDOR" ] && optargs="$optargs -i $IF_VENDOR"
|
||||
[ -n "$IF_CLIENT" ] && optargs="$optargs -i $IF_CLIENT"
|
||||
[ -n "$IF_LEASETIME" ] && optargs="$optargs -l $IF_LEASETIME"
|
||||
[ -n "$IF_DHCP_HOSTNAME" ] && optargs="$optargs -h $IF_DHCP_HOSTNAME"
|
||||
[ -n "$IF_DHCP_VENDOR" ] && optargs="$optargs -i $IF_DHCP_VENDOR"
|
||||
[ -n "$IF_DHCP_CLIENT_ID" ] && optargs="$optargs -i $IF_DHCP_CLIENT_ID"
|
||||
[ -n "$IF_DHCP_LEASETIME" ] && optargs="$optargs -l $IF_DHCP_LEASETIME"
|
||||
${MOCK} /sbin/dhcpcd $optargs $IFACE
|
||||
;;
|
||||
dhclient)
|
||||
${MOCK} /usr/sbin/dhclient -pf /var/run/dhclient.$IFACE.pid $IFACE
|
||||
# Specific config file given?
|
||||
if [ -n "$IF_DHCP_CONFIG" ]; then
|
||||
optargs="$optargs -cf $IF_DHCP_CONFIG"
|
||||
fi
|
||||
|
||||
${MOCK} /usr/sbin/dhclient -pf /var/run/dhclient.$IFACE.pid $optarts $IFACE
|
||||
;;
|
||||
udhcpc)
|
||||
optargs=$(eval echo $IF_UDHCPC_OPTS)
|
||||
[ -n "$IF_HOSTNAME" ] && optargs="$optargs -x hostname:$IF_HOSTNAME"
|
||||
[ -n "$IF_CLIENT" ] && optargs="$optargs -c $IF_CLIENT"
|
||||
[ -n "$IF_SCRIPT" ] && optargs="$optargs -s $IF_SCRIPT"
|
||||
[ -n "$IF_DHCP_HOSTNAME" ] && optargs="$optargs -x hostname:$IF_DHCP_HOSTNAME"
|
||||
[ -n "$IF_DHCP_CLIENT_ID" ] && optargs="$optargs -c $IF_DHCP_CLIENT_ID"
|
||||
[ -n "$IF_DHCP_SCRIPT" ] && optargs="$optargs -s $IF_DHCP_SCRIPT"
|
||||
${MOCK} /sbin/udhcpc -b -R -p /var/run/udhcpc.$IFACE.pid -i $IFACE $optargs
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -32,6 +32,7 @@ struct remap_token {
|
|||
static const struct remap_token tokens[] = {
|
||||
{"bond-ad-sys-priority", "bond-ad-actor-sys-prio"}, /* ifupdown2 */
|
||||
{"bond-slaves", "bond-members"}, /* legacy ifupdown, ifupdown2 */
|
||||
{"client", "dhcp-client-id"}, /* legacy ifupdown */
|
||||
{"driver-message-level", "ethtool-msglvl"}, /* Debian ethtool integration */
|
||||
{"endpoint", "tunnel-remote"}, /* legacy ifupdown */
|
||||
{"ethernet-autoneg", "ethtool-ethernet-autoneg"}, /* Debian ethtool integration */
|
||||
|
@ -68,6 +69,8 @@ static const struct remap_token tokens[] = {
|
|||
{"hardware-irq-coalesce-tx-usecs-high", "ethtool-coalesce-tx-usecs-high"}, /* Debian ethtool integration */
|
||||
{"hardware-irq-coalesce-tx-usecs-irq", "ethtool-coalesce-tx-usecs-irq"}, /* Debian ethtool integration */
|
||||
{"hardware-irq-coalesce-tx-usecs-low", "ethtool-coalesce-tx-usecs-low"}, /* Debian ethtool integration */
|
||||
{"hostname", "dhcp-hostname"}, /* legacy ifupdown */
|
||||
{"leasetime", "dhcp-leastime"}, /* legacy ifupdown */
|
||||
{"link-autoneg", "ethtool-ethernet-autoneg"}, /* ifupdown2 */
|
||||
{"link-duplex", "ethtool-link-duplex"}, /* Debian ethtool integration */
|
||||
{"link-fec", "ethtool-link-fec"}, /* ifupdown2 */
|
||||
|
@ -85,6 +88,7 @@ static const struct remap_token tokens[] = {
|
|||
{"offload-ufo", "ethtool-offload-ufo"}, /* Debian ethtool integration */
|
||||
{"pointopoint", "point-to-point"}, /* legacy ifupdown, ifupdown2 */
|
||||
{"provider", "ppp-provider"}, /* legacy ifupdown, ifupdown2 */
|
||||
{"script", "dhcp-script"}, /* legacy ifupdown */
|
||||
{"rx-offload", "ethtool-offload-rx"}, /* ifupdown2 */
|
||||
{"tso-offload", "ethtool-offload-tso"}, /* ifupdown2 */
|
||||
{"ttl", "tunnel-ttl"}, /* legacy ifupdown */
|
||||
|
@ -92,6 +96,7 @@ static const struct remap_token tokens[] = {
|
|||
{"tunnel-physdev", "tunnel-dev"}, /* ifupdown2 */
|
||||
{"tx-offload", "ethtool-offload-tx"}, /* ifupdown2 */
|
||||
{"ufo-offload", "ethtool-offload-ufo"}, /* ifupdown2 */
|
||||
{"vendor", "dhcp-vendor"}, /* legacy ifupdown */
|
||||
{"vrf", "vrf-member"}, /* ifupdown2 */
|
||||
{"vxlan-local-tunnelip", "vxlan-local-ip"}, /* ifupdown2 */
|
||||
{"vxlan-remoteip", "vxlan-remote-ip"}, /* ifupdown2 */
|
||||
|
|
|
@ -48,7 +48,7 @@ udhcpc_opts_up_subshell_body() {
|
|||
}
|
||||
|
||||
hostname_subshell_body() {
|
||||
export IFACE=eth0 PHASE=up MOCK=echo IF_DHCP_PROGRAM=udhcpc IF_HOSTNAME="\$(echo test)"
|
||||
export IFACE=eth0 PHASE=up MOCK=echo IF_DHCP_PROGRAM=udhcpc IF_DHCP_HOSTNAME="\$(echo test)"
|
||||
atf_check -s exit:0 -o match:'/sbin/udhcpc -b -R -p /var/run/udhcpc.eth0.pid -i eth0 -x hostname:test' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue