Skip to content

Commit

Permalink
Merge pull request #64 from diginc/2.9.5
Browse files Browse the repository at this point in the history
latest version of pi-hole/web, refactor, fixes
  • Loading branch information
diginc authored Oct 30, 2016
2 parents 2d5e698 + 7325ae3 commit c524927
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 43 deletions.
2 changes: 1 addition & 1 deletion AdminLTE
2 changes: 1 addition & 1 deletion AdminLTE_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.4.3.1
v1.4.4.2
8 changes: 4 additions & 4 deletions alpine.docker
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ RUN apk add --update \
# 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 \(re\)\{0,1\}start|dnsmasq -7 /etc/dnsmasq.d|g' \
/usr/local/bin/pihole \
/usr/local/bin/gravity.sh \
/usr/local/bin/whitelist.sh \
/usr/local/bin/blacklist.sh
/usr/local/bin/list.sh
COPY ./alpine/nginx.conf /etc/nginx/nginx.conf

# Original upstream pihole code being used
COPY ./pi-hole/adlists.default /etc/pihole/
COPY ./pi-hole/adlists.default /etc/.pihole/
COPY ./pi-hole/pihole /usr/local/bin/
RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole
COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/
Expand Down Expand Up @@ -63,7 +63,7 @@ RUN grep -q '^user=root' || echo 'user=root' >> /etc/dnsmasq.conf
# php config start passes special ENVs into
ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf'
ENV PHP_ERROR_LOG '/var/log/nginx/error.log'
COPY ./alpine/start.sh /
COPY ./start.sh /
COPY ./common_start.sh /

# IPV6 disable flag for networks/devices that do not support it
Expand Down
23 changes: 0 additions & 23 deletions alpine/start.sh

This file was deleted.

56 changes: 55 additions & 1 deletion common_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ setup_saved_variables() {
echo "IPv6_address=$ServerIPv6" >> /etc/pihole/setupVars.conf;
}

setup_dnsmasq() {
setup_dnsmasq_dns() {
local DNS1="${1:-8.8.8.8}"
local DNS2="${2:-8.8.4.4}"
local dnsType='default'
Expand All @@ -25,6 +25,43 @@ setup_dnsmasq() {
sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf
}

setup_dnsmasq_hostnames() {
# largely borrowed from automated install/basic-install.sh
local IPv4_address="${1}"
local IPv6_address="${2}"
local hostname="${3}"
local dnsmasq_pihole_01_location="/etc/dnsmasq.d/01-pihole.conf"

if [ -z "$hostname" ]; then
if [[ -f /etc/hostname ]]; then
hostname=$(</etc/hostname)
elif [ -x "$(command -v hostname)" ]; then
hostname=$(hostname -f)
fi
fi;

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}
fi

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}
fi

if [[ "${hostname}" != "" ]]; then
sed -i "s/@HOSTNAME@/$hostname/" ${dnsmasq_pihole_01_location}
else
sed -i '/^address=\/@HOSTNAME@*/d' ${dnsmasq_pihole_01_location}
fi
}

setup_php_env() {
case $IMAGE in
"debian") setup_php_env_debian ;;
Expand Down Expand Up @@ -53,6 +90,7 @@ setup_php_env_debian() {
}

setup_php_env_alpine() {
# Intentionally tabs, required by HEREDOC de-indentation (<<-)
cat <<-EOF > "$PHP_ENV_CONFIG"
[www]
env[PATH] = ${PATH}
Expand Down Expand Up @@ -113,3 +151,19 @@ test_configs_alpine() {
test_framework_stubbing() {
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)"; fi;
}

main() {
IMAGE="$1"
case $IMAGE in
"alpine")
gravity.sh # dnsmasq start included
php-fpm
nginx
;;
"debian")
gravity.sh # dnsmasq start included
service lighttpd start
;;
esac
tail -F /var/log/lighttpd/*.log /var/log/pihole.log
}
2 changes: 1 addition & 1 deletion debian-armhf.docker
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ 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/start.sh /
COPY ./start.sh /
COPY ./common_start.sh /

# IPv6 disable flag for networks/devices that do not support it
Expand Down
2 changes: 1 addition & 1 deletion debian.docker
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ 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/start.sh /
COPY ./start.sh /
COPY ./common_start.sh /

# IPv6 disable flag for networks/devices that do not support it
Expand Down
9 changes: 5 additions & 4 deletions docker-pi-hole.cron
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# 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
# or other cron file snippets.

# Your container name goes here:
DOCKER_NAME=pihole
Expand All @@ -21,10 +26,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# pihole software update commands are unsupported in docker!
#30 2 * * 7 root docker exec $DOCKER_NAME pihole updatePihole > /dev/null

# Pi-hole: Parse the log file before it is flushed and save the stats to a database
# This will be used for a historical view of your Pi-hole's performance
#50 23 * * * root docker exec $DOCKER_NAME dailyLog.sh # note: this is outdated > /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
2 changes: 1 addition & 1 deletion pi-hole_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.9.4
v2.9.5
9 changes: 4 additions & 5 deletions debian/start.sh → start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ export ServerIPv6
export PYTEST
export PHP_ENV_CONFIG
export PHP_ERROR_LOG
export HOSTNAME

validate_env
setup_saved_variables
setup_php_env
setup_dnsmasq "$DNS1" "$DNS2"
setup_dnsmasq_dns "$DNS1" "$DNS2"
setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME"
setup_ipv4_ipv6
test_configs
test_framework_stubbing

gravity.sh # dnsmasq start included
service lighttpd start

tail -F /var/log/lighttpd/*.log /var/log/pihole.log
main "$IMAGE"

0 comments on commit c524927

Please sign in to comment.