Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Schaper <dan.schaper@pi-hole.net>2022-10-31 23:23:35 +0300
committerGitHub <noreply@github.com>2022-10-31 23:23:35 +0300
commit871067acd89aa279abb38a4bd919653aab1a03ae (patch)
tree8e2d3bb04bd806c846db798410186d4011a5aaa1
parent01bf9ca42ae20ef3c83172fc74c1b9309bba6912 (diff)
parent06cf7afbc2646706186f74694d223c392135824a (diff)
Fix static IP not set if IP is already present in any way inside dhcpcd.conf (#4995)
Use grep and regex to find uncommented use of `static ip_address` with IP.
-rwxr-xr-xautomated install/basic-install.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index d4c1ce77..0fda391d 100755
--- a/automated install/basic-install.sh
+++ b/automated install/basic-install.sh
@@ -828,8 +828,11 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
# Configure networking via dhcpcd
setDHCPCD() {
- # Check if the IP is already in the file
- if grep -q "${IPV4_ADDRESS}" /etc/dhcpcd.conf; then
+ # Regex for matching a non-commented static ip address setting
+ local regex="^[ \t]*static ip_address[ \t]*=[ \t]*${IPV4_ADDRESS}[ \t]*$"
+
+ # Check if static IP is already set in file
+ if grep -xq "${regex}" /etc/dhcpcd.conf; then
printf " %b Static IP already configured\\n" "${INFO}"
# If it's not,
else