Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Raspberry pi stretch allow dhcpcd5 with /etc/network/interfaces
#!/bin/sh -e
#
# This file belongs in /usr/lib/dhcpcd5/dhcpcd how you get it there is up to you
#
DHCPCD=/sbin/dhcpcd
INTERFACES=/etc/network/interfaces
REGEX="^[[:space:]]*iface[[:space:]](*.*)[[:space:]]*inet[[:space:]]*(dhcp|static)"
EXCLUDES=""
if grep -q -E $REGEX $INTERFACES; then
#echo "Not running dhcpcd because $INTERFACES"
#echo "defines some interfaces that will use a"
#echo "DHCP client or static address"
#exit 6
for iface in `grep -E $REGEX $INTERFACES | cut -f2 -d" "`
do
if [[ $EXCLUDES != "" ]]; then
EXCLUDES="${EXCLUDES}|${iface}"
else
EXCLUDES="${iface}"
fi
done
EXCLUDES="(${EXCLUDES})"
fi
exec $DHCPCD -Z $EXCLUDES $@
@soslug

This comment has been minimized.

Copy link

commented Sep 7, 2017

Awesome fix Lewis now have wireless working as well - Cheers

@ekkithump

This comment has been minimized.

Copy link

commented Mar 3, 2018

Suggestion:
Check to see if that's a 'just in case' option or if it's actually automatic.
[as above]
do
if grep -q -E "^[[:space:]]auto[[:space:]]$iface" $INTERFACES
then
[as above]
fi

@Lewiscowles1986

This comment has been minimized.

Copy link
Owner Author

commented Mar 3, 2018

@ekkithump, what benefit would that have? This regex is actually the same one dhcpcd in debian stretch uses

@heartlandcoop-prichards

This comment has been minimized.

Copy link

commented Apr 12, 2018

Comment says This file belongs in /usr/lib/dhcpcd5/dhcpcd
But /usr/lib/dhcpcd5/dhcpcd is already a file.
I assume that you mean this file belongs in the directory /usr/lib/dhcpcd5?

@heartlandcoop-prichards

This comment has been minimized.

Copy link

commented Apr 12, 2018

Also I'm not sure if you want to replace the file /usr/lib/dhcpcd5/dhcpcd as this file has a .sh extension and /usr/lib/dhcpcd5/dhcpcd has no extension?

@Lewiscowles1986

This comment has been minimized.

Copy link
Owner Author

commented Jul 18, 2018

@heartlandcoop-prichards no it is meant to overwrite that file. The extension is meaningless

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.