Skip to content

Instantly share code, notes, and snippets.

@specialcircumstances
Forked from Lewiscowles1986/dhcpcd.sh
Created April 16, 2020 13:36
Show Gist options
  • Save specialcircumstances/fa8c2d87777ae551c25eaafe45878672 to your computer and use it in GitHub Desktop.
Save specialcircumstances/fa8c2d87777ae551c25eaafe45878672 to your computer and use it in GitHub Desktop.
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 $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment