diff --git a/AdminLTE b/AdminLTE index 3e6955d..f76317b 160000 --- a/AdminLTE +++ b/AdminLTE @@ -1 +1 @@ -Subproject commit 3e6955d4a01d78bb8c73a8f9fcec6d3be51bea4c +Subproject commit f76317baf38cc937461ae70c0ad118f59dbc391b diff --git a/AdminLTE_version.txt b/AdminLTE_version.txt index b51aaae..e70ef1d 100644 --- a/AdminLTE_version.txt +++ b/AdminLTE_version.txt @@ -1 +1 @@ -v1.4.4.2 +v2.3 diff --git a/alpine.docker b/alpine.docker index ae33aac..0634999 100644 --- a/alpine.docker +++ b/alpine.docker @@ -2,28 +2,26 @@ FROM alpine:edge MAINTAINER adam@diginc.us ENV IMAGE alpine +ENV PATH /opt/pihole:${PATH} + +COPY install.sh /install.sh +ENV setupVars /etc/pihole/setupVars.conf +ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV TINI_VERSION v0.13.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static.asc /tini.asc # Tini and package requirements -RUN apk add --update gpgme && \ +RUN apk add --update 'gnupg<2.1.17-r0' && \ gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0527A9B7 && \ gpg --verify /tini.asc && \ chmod +x /tini && \ - apk add \ - dnsmasq \ - nginx \ - ca-certificates \ - php5-fpm php5-json php5-openssl libxml2 \ - bc bash curl perl sudo git && \ + apk add wget bash && \ + /install.sh && \ rm -rf /var/cache/apk/* # Customized from submodules -COPY ./pi-hole/gravity.sh /usr/local/bin/ -COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/ -COPY ./pi-hole/pihole /usr/local/bin/ RUN sed -i 's|service dnsmasq restart|kill -9 $(pidof dnsmasq); dnsmasq -7 /etc/dnsmasq.d|g' \ /usr/local/bin/pihole \ /usr/local/bin/gravity.sh \ diff --git a/bash_functions.sh b/bash_functions.sh index 5ece23b..26eeabe 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -1,3 +1,5 @@ +setupVars="${setupVars:-/etc/pihole/setupVars.conf}" + validate_env() { if [ -z "$ServerIP" ] ; then echo "ERROR: To function correctly you must pass an environment variables of 'ServerIP' into the docker container with the IP of your docker host from which you are passing web (80) and dns (53) ports from" @@ -8,8 +10,8 @@ validate_env() { setup_saved_variables() { # /tmp/piholeIP is the current override of auto-lookup in gravity.sh echo "$ServerIP" > /etc/pihole/piholeIP; - echo "IPv4_address=$ServerIP" > /etc/pihole/setupVars.conf; - echo "IPv6_address=$ServerIPv6" >> /etc/pihole/setupVars.conf; + echo "IPV4_ADDRESS=$ServerIP" > "${setupVars}"; + echo "IPV6_ADDRESS=$ServerIPv6" >> "${setupVars}"; } setup_dnsmasq_dns() { @@ -20,15 +22,16 @@ setup_dnsmasq_dns() { dnsType='custom' fi; + set -x echo "Using $dnsType DNS servers: $DNS1 & $DNS2" - sed -i "s/@DNS1@/$DNS1/" /etc/dnsmasq.d/01-pihole.conf && \ - sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf + sed -i 's/ProcessDnsmasqSettings/ProcessDNSSettings/g' /opt/pihole/webpage.sh + sudo pihole -a setdns "$DNS1" "$DNS2" } setup_dnsmasq_hostnames() { # largely borrowed from automated install/basic-install.sh - local IPv4_address="${1}" - local IPv6_address="${2}" + local IPV4_ADDRESS="${1}" + local IPV6_ADDRESS="${2}" local hostname="${3}" local dnsmasq_pihole_01_location="/etc/dnsmasq.d/01-pihole.conf" @@ -40,16 +43,16 @@ setup_dnsmasq_hostnames() { fi fi; - if [[ "${IPv4_address}" != "" ]]; then - tmp=${IPv4_address%/*} - sed -i "s/@IPv4@/$tmp/" ${dnsmasq_pihole_01_location} + if [[ "${IPV4_ADDRESS}" != "" ]]; then + tmp=${IPV4_ADDRESS%/*} + sed -i "s/@IPV4@/$tmp/" ${dnsmasq_pihole_01_location} else - sed -i '/^address=\/pi.hole\/@IPv4@/d' ${dnsmasq_pihole_01_location} - sed -i '/^address=\/@HOSTNAME@\/@IPv4@/d' ${dnsmasq_pihole_01_location} + sed -i '/^address=\/pi.hole\/@IPV4@/d' ${dnsmasq_pihole_01_location} + sed -i '/^address=\/@HOSTNAME@\/@IPV4@/d' ${dnsmasq_pihole_01_location} fi - if [[ "${IPv6_address}" != "" ]]; then - sed -i "s/@IPv6@/$IPv6_address/" ${dnsmasq_pihole_01_location} + if [[ "${IPV6_ADDRESS}" != "" ]]; then + sed -i "s/@IPv6@/$IPV6_ADDRESS/" ${dnsmasq_pihole_01_location} else sed -i '/^address=\/pi.hole\/@IPv6@/d' ${dnsmasq_pihole_01_location} sed -i '/^address=\/@HOSTNAME@\/@IPv6@/d' ${dnsmasq_pihole_01_location} diff --git a/debian-armhf.docker b/debian-armhf.docker index a29ae6f..0181d4b 100644 --- a/debian-armhf.docker +++ b/debian-armhf.docker @@ -2,67 +2,26 @@ FROM jsurf/rpi-raspbian MAINTAINER adam@diginc.us RUN [ "cross-build-start" ] + ENV IMAGE debian +ENV PATH /opt/pihole:${PATH} + +COPY install.sh /install.sh +ENV setupVars /etc/pihole/setupVars.conf +ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV TINI_VERSION v0.13.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-armhf /tini ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-armhf.asc /tini.asc -# Tini and package requirements RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0527A9B7 && \ gpg --verify /tini.asc && \ chmod +x /tini && \ apt-get -q update && \ - apt-get install -y \ - dnsmasq \ - lighttpd \ - php5-common php5-cgi php5 \ - bc curl unzip wget sudo dnsutils && \ + apt-get install -y wget net-tools && \ + /install.sh && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* -# Original upstream pihole code being used -COPY ./pi-hole/gravity.sh /usr/local/bin/ -COPY ./pi-hole/adlists.default /etc/pihole/ -COPY ./pi-hole/adlists.default /etc/.pihole/ -COPY ./pi-hole/pihole /usr/local/bin/ -COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/ -RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole -COPY ./pi-hole/advanced/lighttpd.conf.debian /etc/lighttpd/lighttpd.conf -COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf -COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/ -COPY ./pi-hole/advanced/index* /var/www/html/pihole/ -RUN rm /var/www/html/index.lighttpd.html -COPY ./pi-hole/advanced/pihole.sudo /etc/sudoers.d/pihole -COPY ./AdminLTE /var/www/html/admin -COPY ./AdminLTE_version.txt /etc/ -COPY ./pi-hole_version.txt /etc/ -# Make pihole scripts fail searching for `systemctl`, -# which fails pretty miserably in docker compared to `service` -# For more info see docker/docker issue #7459 -RUN mv `which systemctl` /bin/no_systemctl - -ENV WEBLOGDIR /var/log/lighttpd -RUN mkdir -p /etc/pihole/ && \ - mkdir -p /var/www/html/pihole && \ - mkdir -p /var/www/html/admin/ && \ - chown www-data:www-data /var/www/html && \ - touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ - chown -R www-data.www-data ${WEBLOGDIR} && \ - chmod 775 /var/www/html && \ - lighty-enable-mod fastcgi fastcgi-php || true && \ - touch /var/log/pihole.log && \ - chmod 644 /var/log/pihole.log && \ - chown dnsmasq:root /var/log/pihole.log && \ - sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ - sed -i 's|"cd /etc/.pihole/ && git describe --tags --abbrev=0"|"cat /etc/pi-hole_version.txt"|g' /var/www/html/admin/footer.php && \ - sed -i 's|"git describe --tags --abbrev=0"|"cat /etc/AdminLTE_version.txt"|g' /var/www/html/admin/footer.php - -# This chould be eliminated if all (upstream) files were +x in git -RUN chmod +x /usr/local/bin/*.sh - -# Fix dnsmasq in docker -RUN grep -q '^user=root' || echo 'user=root' >> /etc/dnsmasq.conf - # php config start passes special ENVs into ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' @@ -76,7 +35,6 @@ ENV IPv6 True EXPOSE 53 53/udp EXPOSE 80 -# Tini doesn't work in ARM ENTRYPOINT ["/tini", "--"] CMD [ "/start.sh" ] diff --git a/debian.docker b/debian.docker index 1556d07..7b39d69 100644 --- a/debian.docker +++ b/debian.docker @@ -2,66 +2,24 @@ FROM debian:jessie MAINTAINER adam@diginc.us ENV IMAGE debian +ENV PATH /opt/pihole:${PATH} + +COPY install.sh /install.sh +ENV setupVars /etc/pihole/setupVars.conf +ENV PIHOLE_INSTALL /tmp/ph_install.sh ENV TINI_VERSION v0.13.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc -# Tini and package requirements RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0527A9B7 && \ gpg --verify /tini.asc && \ chmod +x /tini && \ apt-get -q update && \ - apt-get install -y \ - dnsmasq \ - lighttpd \ - php5-common php5-cgi php5 \ - bc curl unzip wget sudo dnsutils && \ + apt-get install -y wget net-tools && \ + /install.sh && \ rm -rf /var/cache/apt/archives /var/lib/apt/lists/* -# Original upstream pihole code being used -COPY ./pi-hole/gravity.sh /usr/local/bin/ -COPY ./pi-hole/adlists.default /etc/pihole/ -COPY ./pi-hole/adlists.default /etc/.pihole/ -COPY ./pi-hole/pihole /usr/local/bin/ -COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/ -RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole -COPY ./pi-hole/advanced/lighttpd.conf.debian /etc/lighttpd/lighttpd.conf -COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf -COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/ -COPY ./pi-hole/advanced/index* /var/www/html/pihole/ -RUN rm /var/www/html/index.lighttpd.html -COPY ./pi-hole/advanced/pihole.sudo /etc/sudoers.d/pihole -COPY ./AdminLTE /var/www/html/admin -COPY ./AdminLTE_version.txt /etc/ -COPY ./pi-hole_version.txt /etc/ -# Make pihole scripts fail searching for `systemctl`, -# which fails pretty miserably in docker compared to `service` -# For more info see docker/docker issue #7459 -RUN mv `which systemctl` /bin/no_systemctl - -ENV WEBLOGDIR /var/log/lighttpd -RUN mkdir -p /etc/pihole/ && \ - mkdir -p /var/www/html/pihole && \ - mkdir -p /var/www/html/admin/ && \ - chown www-data:www-data /var/www/html && \ - touch ${WEBLOGDIR}/access.log ${WEBLOGDIR}/error.log && \ - chown -R www-data.www-data ${WEBLOGDIR} && \ - chmod 775 /var/www/html && \ - lighty-enable-mod fastcgi fastcgi-php || true && \ - touch /var/log/pihole.log && \ - chmod 644 /var/log/pihole.log && \ - chown dnsmasq:root /var/log/pihole.log && \ - sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \ - sed -i 's|"cd /etc/.pihole/ && git describe --tags --abbrev=0"|"cat /etc/pi-hole_version.txt"|g' /var/www/html/admin/footer.php && \ - sed -i 's|"git describe --tags --abbrev=0"|"cat /etc/AdminLTE_version.txt"|g' /var/www/html/admin/footer.php - -# This chould be eliminated if all (upstream) files were +x in git -RUN chmod +x /usr/local/bin/*.sh - -# Fix dnsmasq in docker -RUN grep -q '^user=root' || echo 'user=root' >> /etc/dnsmasq.conf - # php config start passes special ENVs into ENV PHP_ENV_CONFIG '/etc/lighttpd/conf-enabled/15-fastcgi-php.conf' ENV PHP_ERROR_LOG '/var/log/lighttpd/error.log' diff --git a/docker-pi-hole.cron b/docker-pi-hole.cron index dac900c..2e34964 100644 --- a/docker-pi-hole.cron +++ b/docker-pi-hole.cron @@ -8,7 +8,7 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# +# # This file is under source-control of the Pi-hole installation and update # scripts, any changes made to this file will be overwritten when the softare # is updated or re-installed. Please make any changes to the appropriate crontab @@ -20,12 +20,12 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # Pi-hole: Update the ad sources once a week on Sunday at 01:59 # Download any updates from the adlists -59 1 * * 7 root docker exec $DOCKER_NAME pihole updateGravity > /dev/null +59 1 * * 7 root PATH="$PATH:/usr/local/bin/" docker exec $DOCKER_NAME pihole updateGravity > /dev/null # Update docker-pi-hole by pulling the latest docker image ane re-creating your container. # pihole software update commands are unsupported in docker! -#30 2 * * 7 root docker exec $DOCKER_NAME pihole updatePihole > /dev/null +#30 2 * * 7 root PATH="$PATH:/usr/local/bin/" docker exec $DOCKER_NAME pihole updatePihole > /dev/null # Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control # Stats will be viewable in the Web interface thanks to the cron job above -00 00 * * * root docker exec $DOCKER_NAME pihole flush > /dev/null +00 00 * * * root PATH="$PATH:/usr/local/bin/" docker exec $DOCKER_NAME pihole flush > /dev/null diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..bfee6bf --- /dev/null +++ b/install.sh @@ -0,0 +1,52 @@ +#!/bin/bash -x +mkdir -p /etc/pihole/ + +# Make pihole scripts fail searching for `systemctl`, +# which fails pretty miserably in docker compared to `service` +# For more info see docker/docker issue #7459 +mv `which systemctl` /bin/no_systemctl && \ +# debconf-apt-progress seems to hang so get rid of it too +mv `which debconf-apt-progress` /bin/no_debconf-apt-progress + +# Get the install functions +wget -O "$PIHOLE_INSTALL" https://install.pi-hole.net +if [[ "$IMAGE" == 'alpine' ]] ; then + sed -i '/OS distribution not supported/ i\ echo "Hi Alpine"' "$PIHOLE_INSTALL" + sed -i '/OS distribution not supported/,+1d' "$PIHOLE_INSTALL" + sed -i 's#nologin pihole#nologin pihole 2>/dev/null || adduser -S -s /sbin/nologin pihole#g' "$PIHOLE_INSTALL" + sed -i '/usermod -a -G/ s#$# 2> /dev/null || addgroup pihole ${LIGHTTPD_GROUP}#g' "$PIHOLE_INSTALL" + sed -i 's/www-data/nginx/g' "$PIHOLE_INSTALL" + LIGHTTPD_USER="nginx" + LIGHTTPD_GROUP="nginx" +fi +PH_TEST=true . "${PIHOLE_INSTALL}" + +# Run only what we need from installer +export USER=pihole +if [[ "$IMAGE" == 'debian' ]] ; then + install_dependent_packages INSTALLER_DEPS[@] + install_dependent_packages PIHOLE_DEPS[@] +elif [[ "$IMAGE" == 'alpine' ]] ; then + apk add \ + dnsmasq \ + nginx \ + ca-certificates \ + php5-fpm php5-json php5-openssl libxml2 \ + bc bash curl perl sudo git +fi +git clone --depth 1 ${piholeGitUrl} ${PI_HOLE_LOCAL_REPO} +git clone --depth 1 ${webInterfaceGitUrl} ${webInterfaceDir} + +export PIHOLE_INTERFACE=eth0 +export IPV4_ADDRESS=0.0.0.0 +export IPV6_ADDRESS=0:0:0:0:0:0 +export PIHOLE_DNS_1=8.8.8.8 +export PIHOLE_DNS_2=8.8.4.4 +export QUERY_LOGGING=true +installPihole | tee "${tmpLog}" + +mv "${tmpLog}" "${instalLogLoc}" + +# Fix dnsmasq in docker +grep -q '^user=root' || echo -e '\nuser=root' >> /etc/dnsmasq.conf +echo done diff --git a/pi-hole b/pi-hole index 69e3a45..b8545eb 160000 --- a/pi-hole +++ b/pi-hole @@ -1 +1 @@ -Subproject commit 69e3a45083bd311aecdbc3935986dac5ce64caa8 +Subproject commit b8545eb1df0836b02671cd2e3efb302041dd72e2 diff --git a/pi-hole_version.txt b/pi-hole_version.txt index a4d862d..9fda0b1 100644 --- a/pi-hole_version.txt +++ b/pi-hole_version.txt @@ -1 +1 @@ -v2.9.5 +v2.11 diff --git a/update.sh b/update.sh index 63c6eb9..068e54c 100755 --- a/update.sh +++ b/update.sh @@ -10,7 +10,7 @@ pushd AdminLTE ; git describe --tags --abbrev=0 > ../AdminLTE_version.txt ; popd cron='./docker-pi-hole.cron' cp -f pi-hole/advanced/pihole.cron ${cron}; sed -i '/Update the ad sources/ i\# Your container name goes here:\nDOCKER_NAME=pihole\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n' ${cron}; -sed -i "s|/usr/local/bin/|docker exec \$DOCKER_NAME |g" ${cron}; +sed -i "s|pihole |docker exec \$DOCKER_NAME pihole |g" ${cron}; sed -i '/docker exec/ s|$| > /dev/null|g' ${cron}; # docker-pi-hole users update their docker images, not git code