Remove the s6 directory to prevent confusion. I will try to remember where I was with the previous commit.

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2023-06-09 18:53:42 +01:00
parent d7a25836ad
commit 171c8108f9
No known key found for this signature in database
29 changed files with 1 additions and 330 deletions

View File

@ -1,2 +0,0 @@
#!/command/execlineb
background { bash -e /usr/local/bin/_postFTL.sh }

View File

@ -1,2 +0,0 @@
#!/command/execlineb
foreground { bash -e /usr/local/bin/_startup.sh }

View File

@ -1,2 +0,0 @@
#!/command/execlineb
foreground { bash -e /usr/local/bin/_uid-gid-changer.sh }

View File

@ -1,4 +0,0 @@
#!/command/with-contenv bash
s6-echo "Stopping cron"
killall -9 cron

View File

@ -1,3 +0,0 @@
#!/command/with-contenv bash
exec -c
fdmove -c 2 1 /usr/sbin/cron -f

View File

@ -1 +0,0 @@
longrun

View File

@ -1,4 +0,0 @@
#!/command/with-contenv bash
s6-echo "Stopping pihole-FTL"
killall -15 pihole-FTL

View File

@ -1,46 +0,0 @@
#!/command/with-contenv bash
if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
set -x ;
fi
# Remove possible leftovers from previous pihole-FTL processes
rm -f /dev/shm/FTL-* 2> /dev/null
rm /run/pihole/FTL.sock 2> /dev/null
# install /dev/null files to ensure they exist (create if non-existing, preserve if existing)
mkdir -pm 0755 /run/pihole /var/log/pihole
[[ ! -f /run/pihole-FTL.pid ]] && install /dev/null /run/pihole-FTL.pid
[[ ! -f /var/log/pihole/FTL.log ]] && install /dev/null /var/log/pihole/FTL.log
[[ ! -f /var/log/pihole/pihole.log ]] && install /dev/null /var/log/pihole/pihole.log
[[ ! -f /etc/pihole/dhcp.leases ]] && install /dev/null /etc/pihole/dhcp.leases
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
chown pihole:pihole /run/pihole-FTL.pid /var/log/pihole/FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases /run/pihole /etc/pihole
chmod 0644 /run/pihole-FTL.pid /var/log/pihole/FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases /etc/pihole/pihole.toml
# Ensure that permissions are set so that pihole-FTL can edit the files. We ignore errors as the file may not (yet) exist
chmod -f 0644 /etc/pihole/macvendor.db
# Chown database files to the user FTL runs as. We ignore errors as the files may not (yet) exist
chown -f pihole:pihole /etc/pihole/pihole-FTL.db /etc/pihole/gravity.db /etc/pihole/macvendor.db
# Chown database file permissions so that the pihole group (web interface) can edit the file. We ignore errors as the files may not (yet) exist
chmod -f 0664 /etc/pihole/pihole-FTL.db
# Backward compatibility for user-scripts that still expect log files in /var/log instead of /var/log/pihole/
# Should be removed with Pi-hole v6.0
if [ ! -f /var/log/pihole.log ]; then
ln -s /var/log/pihole/pihole.log /var/log/pihole.log
chown -h pihole:pihole /var/log/pihole.log
fi
if [ ! -f /var/log/pihole-FTL.log ]; then
ln -s /var/log/pihole/FTL.log /var/log/pihole-FTL.log
chown -h pihole:pihole /var/log/pihole-FTL.log
fi
capsh --user=$DNSMASQ_USER --keep=1 -- -c "/usr/bin/pihole-FTL $FTL_CMD >/dev/null 2>&1"
# Notes on above:
# - DNSMASQ_USER default of pihole is in Dockerfile & can be overwritten by runtime container env
# - /var/log/pihole/pihole*.log has FTL's output that no-daemon would normally print in FG too
# prevent duplicating it in docker logs by sending to dev null

View File

@ -1,27 +0,0 @@
#!/bin/bash
# This script contains function calls and lines that may rely on pihole-FTL to be running, it is run as part of a oneshot service on container startup
if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
set -x ;
fi
gravityDBfile=$(pihole-FTL --config files.gravity)
if [ -z "$SKIPGRAVITYONBOOT" ] || [ ! -f "${gravityDBfile}" ]; then
if [ -n "$SKIPGRAVITYONBOOT" ];then
echo " SKIPGRAVITYONBOOT is set, however ${gravityDBfile} does not exist (Likely due to a fresh volume). This is a required file for Pi-hole to operate."
echo " Ignoring SKIPGRAVITYONBOOT on this occaision."
fi
pihole -g
else
echo " Skipping Gravity Database Update."
fi
# Run update checker to check for newer container, and display version output
echo ""
pihole updatechecker
pihole -v
DOCKER_TAG=$(cat /pihole.docker.tag)
echo " Container tag is: ${DOCKER_TAG}"
echo ""

View File

@ -1,52 +0,0 @@
#!/bin/bash -e
if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
set -x ;
fi
# The below functions are all contained in bash_functions.sh
# shellcheck source=/dev/null
. /usr/local/bin/bash_functions.sh
# shellcheck source=/dev/null
SKIP_INSTALL=true . /etc/.pihole/automated\ install/basic-install.sh
echo " [i] Starting docker specific checks & setup for docker pihole/pihole"
# TODO:
#if [ ! -f /.piholeFirstBoot ] ; then
# echo " [i] Not first container startup so not running docker's setup, re-create container to run setup again"
#else
# regular_setup_functions
#fi
# Initial checks
# ===========================
fix_capabilities
# validate_env || exit 1
ensure_basic_configuration
apply_FTL_Configs_From_Env
# Web interface setup
# ===========================
load_web_password_secret
setup_web_password
# Misc Setup
# ===========================
setup_blocklists
# FTL setup
# ===========================
# setup_FTL_User
setup_FTL_query_logging
[ -f /.piholeFirstBoot ] && rm /.piholeFirstBoot
echo " [i] Docker start setup complete"
echo ""
echo " [i] pihole-FTL ($FTL_CMD) will be started as ${DNSMASQ_USER}"
echo ""

View File

@ -1,35 +0,0 @@
#!/bin/bash
set -e
if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
set -x ;
fi
modifyUser()
{
declare username=${1:-} newId=${2:-}
[[ -z ${username} || -z ${newId} ]] && return
local currentId=$(id -u ${username})
[[ ${currentId} -eq ${newId} ]] && return
echo " [i] Changing ID for user: ${username} (${currentId} => ${newId})"
usermod -o -u ${newId} ${username}
}
modifyGroup()
{
declare groupname=${1:-} newId=${2:-}
[[ -z ${groupname} || -z ${newId} ]] && return
local currentId=$(id -g ${groupname})
[[ ${currentId} -eq ${newId} ]] && return
echo " [i] Changing ID for group: ${groupname} (${currentId} => ${newId})"
groupmod -o -g ${newId} ${groupname}
}
modifyUser www-data ${WEB_UID}
modifyGroup www-data ${WEB_GID}
modifyUser pihole ${PIHOLE_UID}
modifyGroup pihole ${PIHOLE_GID}

View File

@ -1,94 +0,0 @@
#!/bin/bash -ex
# shellcheck disable=SC2034
mkdir -p /etc/pihole/
mkdir -p /var/run/pihole
CORE_LOCAL_REPO=/etc/.pihole
WEB_LOCAL_REPO=/var/www/html/admin
detect_arch() {
DETECTED_ARCH=$(dpkg --print-architecture)
S6_ARCH=$DETECTED_ARCH
case $DETECTED_ARCH in
amd64)
S6_ARCH="x86_64";;
armel)
S6_ARCH="armhf";;
armhf)
S6_ARCH="armhf";;
arm64)
S6_ARCH="aarch64";;
i386)
S6_ARCH="i686";;
esac
}
DOCKER_TAG=$(cat /pihole.docker.tag)
# Helps to have some additional tools in the dev image when debugging
if [[ "${DOCKER_TAG}" = 'nightly' || "${DOCKER_TAG}" = 'dev' ]]; then
apt-get update
apt-get install --no-install-recommends -y nano less
rm -rf /var/lib/apt/lists/*
fi
detect_arch
S6_OVERLAY_VERSION=v3.1.1.2
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 /
# 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 #
######################################################################################
export USER=pihole
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
# curl -sSL https://install.pi-hole.net | bash -sex -- --unattended
# # At this stage, if we are building a :nightly tag, then switch the Pi-hole install to dev versions
# if [[ "${DOCKER_TAG}" = 'nightly' ]]; then
# yes | pihole checkout dev
# fi
git clone https://github.com/pi-hole/adminLTE /var/www/html/admin
cd /var/www/html/admin
git checkout devel-v6
echo "new/http" | tee /etc/pihole/ftlbranch
git clone https://github.com/pi-hole/pi-hole /etc/.pihole
cd /etc/.pihole
git checkout development-v6
bash -ex /etc/.pihole/automated\ install/basic-install.sh --unattended
pihole-FTL --config webserver.api.pwhash ""
# sed a new function into the `pihole` script just above the `helpFunc()` function for later use.
sed -i $'s/helpFunc() {/unsupportedFunc() {\\\n echo "Function not supported in Docker images"\\\n exit 0\\\n}\\\n\\\nhelpFunc() {/g' /usr/local/bin/pihole
# Replace a few of the `pihole` options with calls to `unsupportedFunc`:
# pihole -up / pihole updatePihole
sed -i $'s/)\s*updatePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
# pihole uninstall
sed -i $'s/)\s*uninstallFunc/) unsupportedFunc/g' /usr/local/bin/pihole
# pihole -r / pihole reconfigure
sed -i $'s/)\s*reconfigurePiholeFunc/) unsupportedFunc/g' /usr/local/bin/pihole
# 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
# 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
if [ ! -f /.piholeFirstBoot ]; then
touch /.piholeFirstBoot
fi
echo 'Docker install successful'

View File

@ -1,53 +0,0 @@
#!/bin/bash
# This script patches all service commands into the appropriate s6- commands
# pi-hole upstream scripts need a 'service' interface. why not systemd? docker said so.
start() {
restart
}
stop() {
/command/s6-svc -wD -d -T2500 /run/service/"$service"
}
restart() {
local pid
# Get the PID(s) of the service we are asking to restart
mapfile -t pids < <(pgrep "$service")
# Only attempt to stop the service if it is already running
if [ "${#pids[@]}" -gt 0 ]; then
stop
for pid in "${pids[@]}"; do
# Loop until we are certain that the process has been stopped
while test -d /proc/"$pid"; do
sleep 0.2
done
done
fi
# Check it hasn't been started by something else in the meantime
pid=$(pgrep "$service")
# Only attempt to start the service if it is not already running
if [ -z "$pid" ]; then
/command/s6-svc -wu -u -T2500 /run/service/"$service"
fi
}
status() {
/command/s6-svstat /run/service/"$service"
}
service="$1"
command="$2"
if [[ ! -d "/run/service/$service" ]] ; then
echo "s6 service not found for $service, exiting..."
exit
fi;
${command} "${service}"

View File

@ -79,7 +79,7 @@ mkdir -pm 0755 /run/pihole /var/log/pihole
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
chown pihole:pihole /run/pihole-FTL.pid /var/log/pihole/FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases /run/pihole /etc/pihole
chmod 0644 /run/pihole-FTL.pid /var/log/pihole/FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases /etc/pihole/pihole.toml
chmod 0644 /run/pihole-FTL.pid /var/log/pihole/FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases # /etc/pihole/pihole.toml
# Ensure that permissions are set so that pihole-FTL can edit the files. We ignore errors as the file may not (yet) exist
chmod -f 0644 /etc/pihole/macvendor.db || true