From c5f682d1e7471bc4cdc42e7e62b650b3107f09d0 Mon Sep 17 00:00:00 2001 From: Ignacio Serrano Date: Sat, 23 Jan 2021 17:20:47 +0100 Subject: [PATCH 1/2] allows DHCP server setup with env vars Signed-off-by: Ignacio Serrano --- bash_functions.sh | 16 ++++++++++++++++ start.sh | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/bash_functions.sh b/bash_functions.sh index 92e9d1d..7972635 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -332,3 +332,19 @@ setup_admin_email() { pihole -a -e "$EMAIL" fi } + +setup_dhcp() { + if [ -z "${DHCP_START}" ] || [ -z "${DHCP_END}" ] || [ -z "${DHCP_ROUTER}" ]; then + echo "ERROR: Won't enable DHCP server because mandatory Environment variables are missing: DHCP_START, DHCP_END and/or DHCP_ROUTER" + change_setting "DHCP_ACTIVE" "false" + else + change_setting "DHCP_ACTIVE" "${DHCP_ACTIVE}" + change_setting "DHCP_START" "${DHCP_START}" + change_setting "DHCP_END" "${DHCP_END}" + change_setting "DHCP_ROUTER" "${DHCP_ROUTER}" + change_setting "DHCP_LEASETIME" "${DHCP_LEASETIME}" + change_setting "PIHOLE_DOMAIN" "${PIHOLE_DOMAIN}" + change_setting "DHCP_IPv6" "${DHCP_IPv6}" + change_setting "DHCP_rapid_commit" "${DHCP_rapid_commit}" + fi +} diff --git a/start.sh b/start.sh index c5fdc2b..da5d222 100755 --- a/start.sh +++ b/start.sh @@ -30,6 +30,14 @@ export ADMIN_EMAIL export WEBUIBOXEDLAYOUT export QUERY_LOGGING export PIHOLE_DNS_ +export DHCP_ACTIVE +export DHCP_START +export DHCP_END +export DHCP_ROUTER +export DHCP_LEASETIME +export PIHOLE_DOMAIN +export DHCP_IPv6 +export DHCP_rapid_commit export adlistFile='/etc/pihole/adlists.list' @@ -118,6 +126,8 @@ else fi fi +[[ -n "${DHCP_ACTIVE}" && ${DHCP_ACTIVE} == "true" ]] && echo "Setting DHCP server" && setup_dhcp + setup_web_port "$WEB_PORT" setup_web_password "$WEBPASSWORD" setup_temp_unit "$TEMPERATUREUNIT" From e40ed3b5ccc896884fad104bd6605b987578eb23 Mon Sep 17 00:00:00 2001 From: Ignacio Serrano Date: Sat, 23 Jan 2021 18:18:39 +0100 Subject: [PATCH 2/2] update doc README.md with DHCP server setup Signed-off-by: Ignacio Serrano --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2230051..64912e4 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,14 @@ There are other environment variables if you want to customize various things in | `WEBUIBOXEDLAYOUT: `
*Optional Default: boxed* | Use boxed layout (helpful when working on large screens) | `SKIPGRAVITYONBOOT`:
*Optional Default: Not Set* | Use this option to skip updating the Gravity Database when booting up the container. By default this environment variable is not set so the Gravity Database will be updated when the container starts up. Setting this environment variable to 1 (or anything) will cause the Gravity Database to not be updated when container starts up. | `QUERY_LOGGING: <"true"\|"false">`
*Optional* *Default: "true"* | Enable query logging or not. +| `DHCP_ACTIVE: <"true"\|"false">`
*Optional* *Default: "false"* | Enable DHCP server. Static DHCP leases can be configured with a custom `/etc/dnsmasq.d/04-pihole-static-dhcp.conf` +| `DHCP_START: `
*Optional* *Default: Not Set* | Start of the range of IP addresses to hand out by the DHCP server (mandatory if DHCP server is enabled). +| `DHCP_END: `
*Optional* *Default: Not Set* | End of the range of IP addresses to hand out by the DHCP server (mandatory if DHCP server is enabled). +| `DHCP_ROUTER: `
*Optional* *Default: Not Set* | Router (gateway) IP address sent by the DHCP server (mandatory if DHCP server is enabled). +| `DHCP_LEASETIME: `
*Optional* *Default: 24* | DHCP lease time in hours. +| `PIHOLE_DOMAIN: `
*Optional* *Default: lan* | Domain name sent by the DHCP server. +| `DHCP_IPv6: <"true"\|"false">`
*Optional* *Default: "false"* | Enable DHCP server IPv6 support (SLAAC + RA). +| `DHCP_rapid_commit <"true"\|"false">`
*Optional* *Default: "false"* | Enable DHCPv4 rapid commit (fast address assignment). ## Deprecated environment variables: While these may still work, they are likely to be removed in a future version. Where applicible, alternative variable names are indicated. Please review the table above for usage of the alternative variables