2019-02-09 06:14:44 +01:00
|
|
|
#!/bin/bash -ex
|
2022-07-12 00:50:05 +02:00
|
|
|
# shellcheck disable=SC2034
|
2018-10-30 06:20:45 +01:00
|
|
|
|
2019-06-01 19:16:05 +02:00
|
|
|
mkdir -p /etc/pihole/
|
2018-01-31 17:07:55 +01:00
|
|
|
mkdir -p /var/run/pihole
|
2019-04-12 05:17:22 +02:00
|
|
|
|
2021-04-20 00:06:00 +02:00
|
|
|
CORE_LOCAL_REPO=/etc/.pihole
|
|
|
|
WEB_LOCAL_REPO=/var/www/html/admin
|
|
|
|
|
2021-09-12 17:46:19 +02:00
|
|
|
setupVars=/etc/pihole/setupVars.conf
|
2017-01-08 17:42:39 +01:00
|
|
|
|
2022-07-12 16:18:33 +02:00
|
|
|
detect_arch() {
|
2023-05-11 22:07:53 +02:00
|
|
|
DETECTED_ARCH=$(arch)
|
2021-09-12 23:34:24 +02:00
|
|
|
S6_ARCH=$DETECTED_ARCH
|
|
|
|
case $DETECTED_ARCH in
|
|
|
|
armel)
|
2022-09-22 22:55:21 +02:00
|
|
|
S6_ARCH="armhf";;
|
2023-05-11 23:09:12 +02:00
|
|
|
armv7l)
|
2022-07-12 16:18:33 +02:00
|
|
|
S6_ARCH="armhf";;
|
2021-09-12 23:34:24 +02:00
|
|
|
i386)
|
2022-07-12 19:34:37 +02:00
|
|
|
S6_ARCH="i686";;
|
2021-09-12 23:34:24 +02:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2022-07-12 16:18:33 +02:00
|
|
|
|
2022-09-19 22:46:46 +02:00
|
|
|
DOCKER_TAG=$(cat /pihole.docker.tag)
|
2022-04-11 22:09:02 +02:00
|
|
|
# Helps to have some additional tools in the dev image when debugging
|
2022-09-19 22:46:46 +02:00
|
|
|
if [[ "${DOCKER_TAG}" = 'nightly' || "${DOCKER_TAG}" = 'dev' ]]; then
|
2022-04-11 22:09:02 +02:00
|
|
|
apt-get update
|
2023-02-16 01:09:47 +01:00
|
|
|
apt-get install --no-install-recommends -y nano less vim-tiny
|
2022-04-11 22:09:02 +02:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
fi
|
|
|
|
|
2022-07-12 16:18:33 +02:00
|
|
|
detect_arch
|
|
|
|
|
2022-09-19 22:46:46 +02:00
|
|
|
S6_OVERLAY_VERSION=v3.1.1.2
|
|
|
|
|
2022-07-12 16:18:33 +02:00
|
|
|
curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" | tar Jxpf - -C /
|
|
|
|
curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz" | tar Jxpf - -C /
|
2018-11-01 04:40:00 +01:00
|
|
|
|
2022-08-25 20:27:24 +02:00
|
|
|
# IMPORTANT: #########################################################################
|
|
|
|
# Move /init somewhere else to prevent issues with podman/RHEL #
|
|
|
|
# See: https://github.com/pi-hole/docker-pi-hole/issues/1176#issuecomment-1227587045 #
|
|
|
|
mv /init /s6-init #
|
|
|
|
######################################################################################
|
|
|
|
|
2018-07-01 00:16:16 +02:00
|
|
|
# Preseed variables to assist with using --unattended install
|
|
|
|
{
|
|
|
|
echo "PIHOLE_INTERFACE=eth0"
|
|
|
|
echo "IPV4_ADDRESS=0.0.0.0"
|
|
|
|
echo "IPV6_ADDRESS=0:0:0:0:0:0"
|
|
|
|
echo "PIHOLE_DNS_1=8.8.8.8"
|
|
|
|
echo "QUERY_LOGGING=true"
|
|
|
|
echo "INSTALL_WEB_SERVER=true"
|
|
|
|
echo "INSTALL_WEB_INTERFACE=true"
|
|
|
|
echo "LIGHTTPD_ENABLED=true"
|
|
|
|
}>> "${setupVars}"
|
|
|
|
source $setupVars
|
|
|
|
|
2017-01-08 17:42:39 +01:00
|
|
|
export USER=pihole
|
2018-07-01 00:16:16 +02:00
|
|
|
|
2021-04-20 00:06:00 +02:00
|
|
|
export PIHOLE_SKIP_OS_CHECK=true
|
|
|
|
|
|
|
|
# Run the installer in unattended mode using the preseeded variables above and --reconfigure so that local repos are not updated
|
2021-09-12 17:46:19 +02:00
|
|
|
curl -sSL https://install.pi-hole.net | bash -sex -- --unattended
|
|
|
|
|
2021-12-10 21:51:35 +01:00
|
|
|
# At this stage, if we are building a :nightly tag, then switch the Pi-hole install to dev versions
|
2022-09-19 22:46:46 +02:00
|
|
|
if [[ "${DOCKER_TAG}" = 'nightly' ]]; then
|
2021-12-10 21:51:35 +01:00
|
|
|
yes | pihole checkout dev
|
|
|
|
fi
|
2021-09-12 17:46:19 +02:00
|
|
|
|
2019-06-01 19:16:05 +02:00
|
|
|
sed -i '/^WEBPASSWORD/d' /etc/pihole/setupVars.conf
|
2018-01-01 18:18:29 +01:00
|
|
|
|
2021-08-05 00:41:39 +02:00
|
|
|
# sed a new function into the `pihole` script just above the `helpFunc()` function for later use.
|
2018-01-01 18:18:29 +01:00
|
|
|
sed -i $'s/helpFunc() {/unsupportedFunc() {\\\n echo "Function not supported in Docker images"\\\n exit 0\\\n}\\\n\\\nhelpFunc() {/g' /usr/local/bin/pihole
|
2021-12-10 21:51:35 +01:00
|
|
|
|
2021-08-05 00:41:39 +02:00
|
|
|
# Replace a few of the `pihole` options with calls to `unsupportedFunc`:
|
|
|
|
# pihole -up / pihole updatePihole
|
2018-12-11 21:16:04 +01:00
|
|
|
sed -i $'s/)\s*updatePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
|
2021-08-05 00:41:39 +02:00
|
|
|
# pihole uninstall
|
|
|
|
sed -i $'s/)\s*uninstallFunc/) unsupportedFunc/g' /usr/local/bin/pihole
|
2021-12-10 21:51:35 +01:00
|
|
|
# pihole -r / pihole reconfigure
|
|
|
|
sed -i $'s/)\s*reconfigurePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
|
2021-08-05 00:41:39 +02:00
|
|
|
|
2023-01-23 18:52:39 +01:00
|
|
|
# Move macvendor.db to root dir See https://github.com/pi-hole/docker-pi-hole/issues/1137
|
|
|
|
# During startup we will change FTL's configuration to point to this file instead of /etc/pihole/macvendor.db
|
2022-07-10 17:54:22 +02:00
|
|
|
# If user goes on to bind monunt this directory to their host, then we can easily ensure macvendor.db is the latest
|
|
|
|
# (it is otherwise only updated when FTL is updated, which doesn't happen as part of the normal course of running this image)
|
|
|
|
mv /etc/pihole/macvendor.db /macvendor.db
|
|
|
|
|
2023-02-16 00:53:43 +01:00
|
|
|
|
|
|
|
## Remove the default lighttpd unconfigured config:
|
2023-05-11 22:07:53 +02:00
|
|
|
if [ -f /etc/lighttpd/conf-enabled/99-unconfigured.conf ]; then
|
|
|
|
rm /etc/lighttpd/conf-enabled/99-unconfigured.conf
|
|
|
|
fi
|
2023-02-16 00:53:43 +01:00
|
|
|
## Remove the default lighttpd placeholder page for good measure
|
2023-05-11 22:07:53 +02:00
|
|
|
if [ -f /var/www/html/index.lighttpd.html ]; then
|
|
|
|
rm /var/www/html/index.lighttpd.html
|
|
|
|
fi
|
2023-04-30 06:31:18 +02:00
|
|
|
## Remove redundant directories created by the installer to reduce docker image size
|
2023-05-02 19:15:18 +02:00
|
|
|
rm -rf /tmp/*
|
2023-02-16 00:53:43 +01:00
|
|
|
|
2022-03-31 20:49:35 +02:00
|
|
|
if [ ! -f /.piholeFirstBoot ]; then
|
|
|
|
touch /.piholeFirstBoot
|
|
|
|
fi
|
2022-09-22 22:55:21 +02:00
|
|
|
echo 'Docker install successful'
|