diff --git a/README.md b/README.md index 15d2cbb..0db226d 100644 --- a/README.md +++ b/README.md @@ -98,25 +98,28 @@ There are other environment variables if you want to customize various things in | Docker Environment Var. | Description | | ----------------------- | ----------- | +| `ADMIN_EMAIL: `
*Optional Default: ''* | Set an administrative contact address for the Block Page | `TZ: `
**Recommended** *Default: UTC* | Set your [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to make sure logs rotate at local midnight instead of at UTC midnight. | `WEBPASSWORD: `
**Recommended** *Default: random* | http://pi.hole/admin password. Run `docker logs pihole \| grep random` to find your random pass. | `DNS1: `
*Optional* *Default: 8.8.8.8* | Primary upstream DNS provider, default is google DNS | `DNS2: `
*Optional* *Default: 8.8.4.4* | Secondary upstream DNS provider, default is google DNS, `no` if only one DNS should used -| `DNSSEC: `
*Optional* *Default: false* | Enable DNSSEC support -| `DNS_BOGUS_PRIV: `
*Optional* *Default: true* | Enable forwarding of reverse lookups for private ranges -| `DNS_FQDN_REQUIRED: `
*Optional* *Default: true* | Never forward non-FQDNs -| `CONDITIONAL_FORWARDING: `
*Optional* *Default: False* | Enable DNS conditional forwarding for device name resolution +| `DNSSEC: <"true"\|"false">`
*Optional* *Default: "false"* | Enable DNSSEC support +| `DNS_BOGUS_PRIV: <"true"\|"false">`
*Optional* *Default: "true"* | Enable forwarding of reverse lookups for private ranges +| `DNS_FQDN_REQUIRED: <"true"\|"false">`
*Optional* *Default: true* | Never forward non-FQDNs +| `CONDITIONAL_FORWARDING: <"true"\|"false">`
*Optional* *Default: "false"* | Enable DNS conditional forwarding for device name resolution | `CONDITIONAL_FORWARDING_IP: `
*Optional* | If conditional forwarding is enabled, set the IP of the local network router | `CONDITIONAL_FORWARDING_DOMAIN: `
*Optional* | If conditional forwarding is enabled, set the domain of the local network router | `CONDITIONAL_FORWARDING_REVERSE: `
*Optional* | If conditional forwarding is enabled, set the reverse DNS of the local network router (e.g. `0.168.192.in-addr.arpa`) | `ServerIP: `
**Recommended** | **--net=host mode requires** Set to your server's LAN IP, used by web block modes and lighttpd bind address | `ServerIPv6: `
*Required if using IPv6* | **If you have a v6 network** set to your server's LAN IPv6 to block IPv6 ads fully | `VIRTUAL_HOST: `
*Optional* *Default: $ServerIP* | What your web server 'virtual host' is, accessing admin through this Hostname/IP allows you to make changes to the whitelist / blacklists in addition to the default 'http://pi.hole/admin/' address -| `IPv6: `
*Optional* *Default: True* | For unraid compatibility, strips out all the IPv6 configuration from DNS/Web services when false. +| `IPv6: <"true"\|"false">`
*Optional* *Default: "true"* | For unraid compatibility, strips out all the IPv6 configuration from DNS/Web services when false. | `INTERFACE: `
*Advanced/Optional* | The default works fine with our basic example docker run commands. If you're trying to use DHCP with `--net host` mode then you may have to customize this or DNSMASQ_LISTENING. | `DNSMASQ_LISTENING: `
*Advanced/Optional* | `local` listens on all local subnets, `all` permits listening on internet origin subnets in addition to local. | `WEB_PORT: `
*Advanced/Optional* | **This will break the 'webpage blocked' functionality of Pi-hole** however it may help advanced setups like those running synology or `--net=host` docker argument. This guide explains how to restore webpage blocked functionality using a linux router DNAT rule: [Alternative Synology installation method](https://discourse.pi-hole.net/t/alternative-synology-installation-method/5454?u=diginc) | `DNSMASQ_USER: `
*Experimental Default: root* | Allows running FTLDNS as non-root. +| `TEMPERATUREUNIT`:
*Optional Default: c* | Set preferred temperature unit to `c`: Celsius, `k`: Kelvin, or `f` Fahrenheit units. +| `WEBUIBOXEDLAYOUT: `
*Optional Default: boxed* | Use boxed layout (helpful when working on large screens) To use these env vars in docker run format style them like: `-e DNS1=1.1.1.1` diff --git a/bash_functions.sh b/bash_functions.sh index 89de84a..e90ead4 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -48,7 +48,7 @@ prepare_configs() { # Also similar to preflights for FTL https://github.com/pi-hole/pi-hole/blob/master/advanced/Templates/pihole-FTL.service chown pihole:root /etc/lighttpd chown pihole:pihole "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" "/var/log/pihole" "${regexFile}" - chmod 644 "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" + chmod 644 "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" # not sure why pihole:pihole user/group write perms are not enough for web to write...dirty fix: chmod 777 "${regexFile}" touch /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log @@ -60,27 +60,11 @@ prepare_configs() { # Update version numbers pihole updatechecker # Re-write all of the setupVars to ensure required ones are present (like QUERY_LOGGING) - + # If the setup variable file exists, if [[ -e "${setupVars}" ]]; then - # update the variables in the file - local USERWEBPASSWORD="${WEBPASSWORD}" - . "${setupVars}" - # Stash and pop the user password to avoid setting the password to the hashed setupVar variable - WEBPASSWORD="${USERWEBPASSWORD}" - # Clean up old before re-writing the required setupVars - sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;' "${setupVars}" + cp -f "${setupVars}" "${setupVars}.update.bak" fi - # echo the information to the user - { - echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}" - echo "IPV4_ADDRESS=${IPV4_ADDRESS}" - echo "IPV6_ADDRESS=${IPV6_ADDRESS}" - echo "QUERY_LOGGING=${QUERY_LOGGING}" - echo "INSTALL_WEB_SERVER=${INSTALL_WEB_SERVER}" - echo "INSTALL_WEB_INTERFACE=${INSTALL_WEB_INTERFACE}" - echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}" - }>> "${setupVars}" } validate_env() { @@ -123,7 +107,7 @@ setup_dnsmasq_dns() { setupDNS1="${setupDNS1/PIHOLE_DNS_1=/}" setupDNS2="${setupDNS2/PIHOLE_DNS_2=/}" if [[ -n "$DNS1" && -n "$setupDNS1" ]] || \ - [[ -n "$DNS2" && -n "$setupDNS2" ]] ; then + [[ -n "$DNS2" && -n "$setupDNS2" ]] ; then echo "Docker DNS variables not used" fi echo "Existing DNS servers used (${setupDNS1:-unset} & ${setupDNS2:-unset})" @@ -174,9 +158,9 @@ setup_dnsmasq() { local dns2="$2" local interface="$3" local dnsmasq_listening_behaviour="$4" - # Coordinates + # Coordinates setup_dnsmasq_config_if_missing - setup_dnsmasq_dns "$dns1" "$dns2" + setup_dnsmasq_dns "$dns1" "$dns2" setup_dnsmasq_interface "$interface" setup_dnsmasq_listening_behaviour "$dnsmasq_listening_behaviour" setup_dnsmasq_user "${DNSMASQ_USER}" @@ -269,7 +253,7 @@ setup_web_port() { # Quietly exit early for empty or default if [[ -z "${1}" || "${1}" == '80' ]] ; then return ; fi - if ! echo $1 | grep -q '^[0-9][0-9]*$' ; then + if ! echo $1 | grep -q '^[0-9][0-9]*$' ; then echo "$warning - $1 is not an integer" return fi @@ -340,9 +324,8 @@ test_configs() { echo "::: All config checks passed, cleared for startup ..." } - setup_blocklists() { - local blocklists="$1" + local blocklists="$1" # Exit/return early without setting up adlists with defaults for any of the following conditions: # 1. skip_setup_blocklists env is set exit_string="(exiting ${FUNCNAME[0]} early)" @@ -380,3 +363,32 @@ setup_var_exists() { fi } +setup_temp_unit() { + local UNIT="$1" + # check if var is empty + if [[ "$UNIT" != "" ]] ; then + # check if we have valid units + if [[ "$UNIT" == "c" || "$UNIT" == "k" || $UNIT == "f" ]] ; then + pihole -a -${UNIT} + fi + fi +} + +setup_ui_layout() { + local LO=$1 + # check if var is empty + if [[ "$LO" != "" ]] ; then + # check if we have valid types boxed | traditional + if [[ "$LO" == "traditional" || "$LO" == "boxed" ]] ; then + change_setting "WEBUIBOXEDLAYOUT" "$WEBUIBOXEDLAYOUT" + fi + fi +} + +setup_admin_email() { + local EMAIL=$1 + # check if var is empty + if [[ "$EMAIL" != "" ]] ; then + pihole -a -e "$EMAIL" + fi +} diff --git a/start.sh b/start.sh index 9802985..5f18560 100755 --- a/start.sh +++ b/start.sh @@ -5,7 +5,7 @@ export ServerIP export ServerIPv6 export PYTEST export PHP_ENV_CONFIG -export PHP_ERROR_LOG +export PHP_ERROR_LOG export HOSTNAME export WEBLOGDIR export DNS1 @@ -21,12 +21,18 @@ export CONDITIONAL_FORWARDING export CONDITIONAL_FORWARDING_IP export CONDITIONAL_FORWARDING_DOMAIN export CONDITIONAL_FORWARDING_REVERSE +export TEMPERATUREUNIT +export ADMIN_EMAIL +export WEBUIBOXEDLAYOUT export adlistFile='/etc/pihole/adlists.list' # The below functions are all contained in bash_functions.sh . /bash_functions.sh +# Ensure we have all functions available to update our configurations +. /opt/pihole/webpage.sh + # PH_TEST prevents the install from actually running (someone should rename that) PH_TEST=true . $PIHOLE_INSTALL @@ -45,6 +51,12 @@ fix_capabilities generate_password validate_env || exit 1 prepare_configs +change_setting "PIHOLE_INTERFACE" "$PIHOLE_INTERFACE" +change_setting "IPV4_ADDRESS" "$IPV4_ADDRESS" +change_setting "QUERY_LOGGING" "$QUERY_LOGGING" +change_setting "INSTALL_WEB_SERVER" "$INSTALL_WEB_SERVER" +change_setting "INSTALL_WEB_INTERFACE" "$INSTALL_WEB_INTERFACE" +change_setting "LIGHTTPD_ENABLED" "$LIGHTTPD_ENABLED" change_setting "IPV4_ADDRESS" "$ServerIP" change_setting "IPV6_ADDRESS" "$ServerIPv6" change_setting "DNS_BOGUS_PRIV" "$DNS_BOGUS_PRIV" @@ -56,6 +68,9 @@ change_setting "CONDITIONAL_FORWARDING_DOMAIN" "$CONDITIONAL_FORWARDING_DOMAIN" change_setting "CONDITIONAL_FORWARDING_REVERSE" "$CONDITIONAL_FORWARDING_REVERSE" setup_web_port "$WEB_PORT" setup_web_password "$WEBPASSWORD" +setup_temp_unit "$TEMPERATUREUNIT" +setup_ui_layout "$WEBUIBOXEDLAYOUT" +setup_admin_email "$ADMIN_EMAIL" setup_dnsmasq "$DNS1" "$DNS2" "$INTERFACE" "$DNSMASQ_LISTENING_BEHAVIOUR" setup_php_env setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME"