docker-pi-hole/install.sh

59 lines
2.2 KiB
Bash
Raw Normal View History

2017-01-08 17:42:39 +01:00
#!/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
2017-01-11 03:38:42 +01:00
mv "$(which systemctl)" /bin/no_systemctl && \
2017-01-08 17:42:39 +01:00
# debconf-apt-progress seems to hang so get rid of it too
2017-01-11 03:38:42 +01:00
mv "$(which debconf-apt-progress)" /bin/no_debconf-apt-progress
2017-01-08 17:42:39 +01:00
# 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"
2017-01-11 03:38:42 +01:00
# shellcheck disable=SC2016
2017-01-08 17:42:39 +01:00
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"
2017-01-09 02:13:16 +01:00
sed -i '/LIGHTTPD_CFG/d' "${PIHOLE_INSTALL}"
sed -i '/etc\/cron.d\//d' "${PIHOLE_INSTALL}"
2017-01-11 03:38:42 +01:00
LIGHTTPD_USER="nginx" # shellcheck disable=SC2034
LIGHTTPD_GROUP="nginx" # shellcheck disable=SC2034
LIGHTTPD_CFG="lighttpd.conf.debian" # shellcheck disable=SC2034
DNSMASQ_USER="dnsmasq" # shellcheck disable=SC2034
2017-01-08 17:42:39 +01:00
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[@]
sed -i "/sleep 2/ d" /etc/init.d/dnsmasq # SLOW
2017-01-08 17:42:39 +01:00
elif [[ "$IMAGE" == 'alpine' ]] ; then
apk add \
dnsmasq \
nginx \
ca-certificates \
php5-fpm php5-json php5-openssl libxml2 \
bc bash curl perl sudo git
fi
2017-01-09 06:43:12 +01:00
git clone --depth 1 "${piholeGitUrl}" "${PI_HOLE_LOCAL_REPO}"
git clone --depth 1 "${webInterfaceGitUrl}" "${webInterfaceDir}"
2017-01-08 17:42:39 +01:00
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
2017-01-09 06:43:12 +01:00
echo 'done'