diff --git a/README.md b/README.md index c3bab6f..3494c76 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,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 diff --git a/bash_functions.sh b/bash_functions.sh index 65c33b9..40d220c 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -333,3 +333,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"