2019-02-09 06:14:44 +01:00
|
|
|
#!/bin/bash -ex
|
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
|
|
|
# Source versions file
|
|
|
|
source /etc/pi-hole-versions
|
|
|
|
|
|
|
|
CORE_REMOTE_REPO=https://github.com/pi-hole/pi-hole
|
|
|
|
CORE_LOCAL_REPO=/etc/.pihole
|
|
|
|
WEB_REMOTE_REPO=https://github.com/pi-hole/adminLTE
|
|
|
|
WEB_LOCAL_REPO=/var/www/html/admin
|
|
|
|
setupVars=/etc/pihole/setupVars.conf
|
|
|
|
|
|
|
|
fetch_release_metadata() {
|
|
|
|
local directory="$1"
|
|
|
|
local version="$2"
|
|
|
|
pushd "$directory"
|
|
|
|
git fetch -t
|
|
|
|
git remote set-branches origin '*'
|
|
|
|
git fetch --depth 10
|
|
|
|
#if version number begins with a v, it's a version number
|
2021-04-20 00:20:58 +02:00
|
|
|
if [[ $version == v* ]]; then
|
2021-04-20 00:06:00 +02:00
|
|
|
git checkout master
|
|
|
|
git reset --hard "$version"
|
|
|
|
else # else treat it as a branch
|
|
|
|
git checkout "$version"
|
|
|
|
fi
|
|
|
|
popd
|
|
|
|
}
|
2017-01-08 17:42:39 +01:00
|
|
|
|
2018-11-01 04:40:00 +01:00
|
|
|
apt-get update
|
2021-04-20 00:06:00 +02:00
|
|
|
apt-get install --no-install-recommends -y curl procps ca-certificates git
|
2020-06-04 23:03:48 +02:00
|
|
|
# curl in armhf-buster's image has SSL issues. Running c_rehash fixes it.
|
|
|
|
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923479
|
|
|
|
c_rehash
|
2020-07-16 01:42:29 +02:00
|
|
|
ln -s `which echo` /usr/local/bin/whiptail
|
2018-11-01 04:40:00 +01:00
|
|
|
curl -L -s $S6OVERLAY_RELEASE | tar xvzf - -C /
|
|
|
|
mv /init /s6-init
|
|
|
|
|
2021-04-20 00:06:00 +02:00
|
|
|
# clone the remote repos to their local destinations
|
|
|
|
git clone "${CORE_REMOTE_REPO}" "${CORE_LOCAL_REPO}"
|
|
|
|
fetch_release_metadata "${CORE_LOCAL_REPO}" "${CORE_VERSION}"
|
|
|
|
|
|
|
|
git clone "${WEB_REMOTE_REPO}" "${WEB_LOCAL_REPO}"
|
|
|
|
fetch_release_metadata "${WEB_LOCAL_REPO}" "${WEB_VERSION}"
|
|
|
|
|
|
|
|
# FTL uses a local version file for the installer to determine which version we want
|
|
|
|
echo "${FTL_VERSION}" > /etc/pihole/ftlbranch
|
2017-01-08 17:42:39 +01:00
|
|
|
|
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
|
|
|
|
|
2019-09-18 05:13:12 +02:00
|
|
|
ln -s /bin/true /usr/local/bin/service
|
2021-04-20 00:06:00 +02:00
|
|
|
# Run the installer in unattended mode using the preseeded variables above and --reconfigure so that local repos are not updated
|
|
|
|
bash -ex "./${PIHOLE_INSTALL}" --unattended --reconfigure
|
2019-09-18 05:13:12 +02:00
|
|
|
rm /usr/local/bin/service
|
2020-02-16 18:43:21 +01:00
|
|
|
|
2018-07-01 00:16:16 +02:00
|
|
|
# IPv6 support for nc openbsd better than traditional
|
|
|
|
apt-get install -y --force-yes netcat-openbsd
|
2017-01-31 06:58:48 +01:00
|
|
|
|
2017-01-18 05:49:42 +01:00
|
|
|
sed -i 's/readonly //g' /opt/pihole/webpage.sh
|
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-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 checkout
|
2021-04-20 00:06:00 +02:00
|
|
|
sed -i $'s/)\s*piholeCheckoutFunc/) unsupportedFunc/g' /usr/local/bin/pihole
|
2021-08-05 00:41:39 +02:00
|
|
|
# pihole -r / pihole reconfigure
|
|
|
|
sed -i $'s/)\s*reconfigurePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
|
|
|
|
# pihole uninstall
|
|
|
|
sed -i $'s/)\s*uninstallFunc/) unsupportedFunc/g' /usr/local/bin/pihole
|
|
|
|
|
|
|
|
# Inject a message into the debug scripts Operating System section to indicate that the debug log comes from a Docker system.
|
2021-08-05 01:59:34 +02:00
|
|
|
sed -i $'s/echo_current_diagnostic "Operating system"/echo_current_diagnostic "Operating system"\\\n log_write "${INFO} Pi-hole Docker Container: ${PIHOLE_TAG:-PIHOLE_TAG is unset}"/g' /opt/pihole/piholeDebug.sh
|
2018-01-01 18:18:29 +01:00
|
|
|
|
2019-06-01 19:16:05 +02:00
|
|
|
touch /.piholeFirstBoot
|
2017-01-08 17:42:39 +01:00
|
|
|
|
2017-05-14 00:03:24 +02:00
|
|
|
echo 'Docker install successful'
|