From de0cddc3907f2b692a597b3f67f804e3ec1a936e Mon Sep 17 00:00:00 2001 From: Matthew Thode Date: Wed, 30 Mar 2016 19:48:19 -0500 Subject: [PATCH] Add Gentoo to the dhcp-all-interfaces element This makes use of the dhcpcd package and it's ability to run on all interfaces by default. We disable the privacy extensions and dhcp overriding the hostname (both are enabled by default). Other than that it 'just works' and was the method used to bring up interfaces on Gentoo Openstack images before we switched to building with DIB. Change-Id: I02c14927d70b22f560c6fc149fefca0f93933f56 --- elements/dhcp-all-interfaces/README.rst | 11 ++++++++--- elements/dhcp-all-interfaces/element-deps | 2 ++ .../install.d/50-dhcp-all-interfaces | 11 ++++++++++- .../install.d/60-remove-cloud-image-interfaces | 3 +++ elements/dhcp-all-interfaces/package-installs.yaml | 1 + elements/dhcp-all-interfaces/pkg-map | 10 ++++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 elements/dhcp-all-interfaces/element-deps create mode 100644 elements/dhcp-all-interfaces/package-installs.yaml create mode 100644 elements/dhcp-all-interfaces/pkg-map diff --git a/elements/dhcp-all-interfaces/README.rst b/elements/dhcp-all-interfaces/README.rst index 8a64b9c8..dd7a3f8c 100644 --- a/elements/dhcp-all-interfaces/README.rst +++ b/elements/dhcp-all-interfaces/README.rst @@ -9,6 +9,11 @@ to know ahead of time which one is which, so we will simply run a DHCP client on all interfaces with real MAC addresses (except lo) that are visible on the first boot. -The script /usr/local/sbin/dhcp-all-interfaces.sh will be called -early in each boot and will scan available network interfaces and -ensure they are configured properly before networking services are started. +On non-Gentoo based distributions the script +/usr/local/sbin/dhcp-all-interfaces.sh will be called early in each +boot and will scan available network interfaces and ensure they are +configured properly before networking services are started. + +On Gentoo based distributions we will install the dhcpcd package and +ensure the service starts at boot. This service automatically sets +up all interfaces found via dhcp and/or dhcpv6 (or SLAAC). diff --git a/elements/dhcp-all-interfaces/element-deps b/elements/dhcp-all-interfaces/element-deps new file mode 100644 index 00000000..73015c24 --- /dev/null +++ b/elements/dhcp-all-interfaces/element-deps @@ -0,0 +1,2 @@ +package-installs +pkg-map diff --git a/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces b/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces index 7b58e04f..f17b23a7 100755 --- a/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces +++ b/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces @@ -8,7 +8,10 @@ set -o pipefail SCRIPTDIR=$(dirname $0) -install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.sh /usr/local/sbin/dhcp-all-interfaces.sh +# this script is not needed on Gentoo. +if [ "$DISTRO_NAME" != "gentoo" ]; then + install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.sh /usr/local/sbin/dhcp-all-interfaces.sh +fi DIB_INIT_SYSTEM=$(dib-init-system) if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then @@ -19,4 +22,10 @@ elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then elif [ "$DIB_INIT_SYSTEM" == "sysv" ]; then install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.init /etc/init.d/dhcp-all-interfaces update-rc.d dhcp-all-interfaces defaults +elif [ "$DISTRO_NAME" == "gentoo" ]; then + # let ipv6 use normal slaac + sed -i 's/slaac/#slaac/g' /etc/dhcpcd.conf + # don't let dhcpcd set domain name or hostname + sed -i 's/domain_name\,\ domain_search\,\ host_name/domain_search/g' /etc/dhcpcd.conf + rc-update add dhcpcd default fi diff --git a/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces b/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces index 6d2cc621..4cfd0de7 100755 --- a/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces +++ b/elements/dhcp-all-interfaces/install.d/60-remove-cloud-image-interfaces @@ -18,6 +18,9 @@ rm -f /etc/network/interfaces.d/eth0.cfg # Debian rm -f /etc/network/interfaces.d/eth0 +# Gentoo +rm -f /etc/conf.d/net* + # /etc/network/interfaces distributions if [ -f "/etc/network/interfaces" ]; then printf "auto lo\niface lo inet loopback\n\n" > /etc/network/interfaces diff --git a/elements/dhcp-all-interfaces/package-installs.yaml b/elements/dhcp-all-interfaces/package-installs.yaml new file mode 100644 index 00000000..b1f71dfa --- /dev/null +++ b/elements/dhcp-all-interfaces/package-installs.yaml @@ -0,0 +1 @@ +dhcpcd: diff --git a/elements/dhcp-all-interfaces/pkg-map b/elements/dhcp-all-interfaces/pkg-map new file mode 100644 index 00000000..b2a2d8de --- /dev/null +++ b/elements/dhcp-all-interfaces/pkg-map @@ -0,0 +1,10 @@ +{ + "family": { + "gentoo": { + "dhcpcd": "net-misc/dhcpcd" + } + }, + "default": { + "dhcpcd": "" + } +}