From c6bcc0f87e25153b1f47c06833b97125f4e23ff8 Mon Sep 17 00:00:00 2001 From: name Date: Sat, 27 Aug 2016 21:07:04 +0300 Subject: [PATCH] armhf support --- debian-armhf.docker | 60 +++++++++++++++++++++++++++++++++++++++++++ debian-armhf/start.sh | 38 +++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 debian-armhf.docker create mode 100755 debian-armhf/start.sh diff --git a/debian-armhf.docker b/debian-armhf.docker new file mode 100644 index 0000000..c47c19e --- /dev/null +++ b/debian-armhf.docker @@ -0,0 +1,60 @@ +FROM resin/armv7hf-debian:jessie +MAINTAINER adam@diginc.us + +# Requirements +RUN apt-get -q update && \ + apt-get install -y \ + bash \ + dnsmasq \ + lighttpd \ + php5-common php5-cgi php5 \ + bc curl unzip wget sudo && \ + rm -rf /var/cache/apt/archives + +# Original upstream pihole code being used +COPY ./pi-hole/gravity.sh /usr/local/bin/ +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.html /var/www/html/pihole/index.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/ + +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' +COPY ./debian-armhf/start.sh / + +EXPOSE 53 53/udp +EXPOSE 80 + +ENTRYPOINT ["/bash", "-c"] +CMD /start.sh diff --git a/debian-armhf/start.sh b/debian-armhf/start.sh new file mode 100755 index 0000000..9e1d517 --- /dev/null +++ b/debian-armhf/start.sh @@ -0,0 +1,38 @@ +#!/bin/sh +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" + exit 1 +fi; + +# /tmp/piholeIP is the current override of auto-lookup in gravity.sh +echo "$ServerIP" > /etc/pihole/piholeIP; +sed -i "/bin-environment/ a\\\t\t\t\"ServerIP\" => \"${ServerIP}\"," $PHP_ENV_CONFIG +sed -i "/bin-environment/ a\\\t\t\t\"PHP_ERROR_LOG\" => \"${PHP_ERROR_LOG}\"," $PHP_ENV_CONFIG + +if [ -n "$VIRTUAL_HOST" ] ; then + sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${VIRTUAL_HOST}\"," $PHP_ENV_CONFIG +else + sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${ServerIP}\"," $PHP_ENV_CONFIG +fi; + +echo "Added ENV to php:" +grep -E '(VIRTUAL_HOST|ServerIP)' $PHP_ENV_CONFIG + +dnsType='default' +DNS1=${DNS1:-'8.8.8.8'} +DNS2=${DNS2:-'8.8.4.4'} +if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then + dnsType='custom' +fi; + +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 && \ + +dnsmasq --test -7 /etc/dnsmasq.d || exit 1 +lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1 + +gravity.sh # dnsmasq start included +service lighttpd start + +tail -F /var/log/lighttpd/*.log /var/log/pihole.log