mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-24 12:28:56 +00:00
Merge pull request #1691 from pi-hole/Clean_up
Remove unused DHCP_ACTIVE and fix shellcheck warnings
This commit is contained in:
9
build.sh
9
build.sh
@@ -43,8 +43,9 @@ check_branch_exists() {
|
|||||||
url="https://github.com/pi-hole/${repo}/blob/${branch}/README.md"
|
url="https://github.com/pi-hole/${repo}/blob/${branch}/README.md"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local http_code=$(curl -sI "$url" -o /dev/null -w "%{http_code}")
|
local http_code
|
||||||
if [ $http_code -ne 200 ]; then
|
http_code=$(curl -sI "$url" -o /dev/null -w "%{http_code}")
|
||||||
|
if [ "${http_code}" -ne 200 ]; then
|
||||||
echo "Error: $repo branch '$branch' not found. Exiting."
|
echo "Error: $repo branch '$branch' not found. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -121,7 +122,7 @@ done
|
|||||||
|
|
||||||
# Execute the docker build command
|
# Execute the docker build command
|
||||||
echo "Executing command: $DOCKER_BUILD_CMD"
|
echo "Executing command: $DOCKER_BUILD_CMD"
|
||||||
eval $DOCKER_BUILD_CMD
|
eval "${DOCKER_BUILD_CMD}"
|
||||||
|
|
||||||
# Check exit code of previous command
|
# Check exit code of previous command
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
@@ -133,5 +134,5 @@ if [ $? -ne 0 ]; then
|
|||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo "Successfully built Docker image with tag '$TAG'"
|
echo "Successfully built Docker image with tag '$TAG'"
|
||||||
docker images $TAG
|
docker images "${TAG}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ set_uid_gid() {
|
|||||||
if [ -n "${PIHOLE_UID}" ]; then
|
if [ -n "${PIHOLE_UID}" ]; then
|
||||||
if [[ ${currentUid} -ne ${PIHOLE_UID} ]]; then
|
if [[ ${currentUid} -ne ${PIHOLE_UID} ]]; then
|
||||||
echo " [i] Changing ID for user: pihole (${currentUid} => ${PIHOLE_UID})"
|
echo " [i] Changing ID for user: pihole (${currentUid} => ${PIHOLE_UID})"
|
||||||
usermod -o -u ${PIHOLE_UID} pihole
|
usermod -o -u "${PIHOLE_UID}" pihole
|
||||||
else
|
else
|
||||||
echo " [i] ID for user pihole is already ${PIHOLE_UID}, no need to change"
|
echo " [i] ID for user pihole is already ${PIHOLE_UID}, no need to change"
|
||||||
fi
|
fi
|
||||||
@@ -52,7 +52,7 @@ set_uid_gid() {
|
|||||||
if [ -n "${PIHOLE_GID}" ]; then
|
if [ -n "${PIHOLE_GID}" ]; then
|
||||||
if [[ ${currentGid} -ne ${PIHOLE_GID} ]]; then
|
if [[ ${currentGid} -ne ${PIHOLE_GID} ]]; then
|
||||||
echo " [i] Changing ID for group: pihole (${currentGid} => ${PIHOLE_GID})"
|
echo " [i] Changing ID for group: pihole (${currentGid} => ${PIHOLE_GID})"
|
||||||
groupmod -o -g ${PIHOLE_GID} pihole
|
groupmod -o -g "${PIHOLE_GID}" pihole
|
||||||
else
|
else
|
||||||
echo " [i] ID for group pihole is already ${PIHOLE_GID}, no need to change"
|
echo " [i] ID for group pihole is already ${PIHOLE_GID}, no need to change"
|
||||||
fi
|
fi
|
||||||
@@ -219,13 +219,12 @@ fix_capabilities() {
|
|||||||
echo " * ${i}"
|
echo " * ${i}"
|
||||||
done
|
done
|
||||||
|
|
||||||
setcap ${CAP_STR:1}+ep "$(which pihole-FTL)" || ret=$?
|
setcap "${CAP_STR:1}"+ep "$(which pihole-FTL)" || ret=$?
|
||||||
|
|
||||||
if [[ $DHCP_READY == false ]] && [[ $FTLCONF_dhcp_active == true ]]; then
|
if [[ $DHCP_READY == false ]] && [[ $FTLCONF_dhcp_active == true ]]; then
|
||||||
# DHCP is requested but NET_ADMIN is not available.
|
# DHCP is requested but NET_ADMIN is not available.
|
||||||
echo "ERROR: DHCP requested but NET_ADMIN is not available. DHCP will not be started."
|
echo "ERROR: DHCP requested but NET_ADMIN is not available. DHCP will not be started."
|
||||||
echo " Please add cap_net_admin to the container's capabilities or disable DHCP."
|
echo " Please add cap_net_admin to the container's capabilities or disable DHCP."
|
||||||
DHCP_ACTIVE='false'
|
|
||||||
setFTLConfigValue dhcp.active false
|
setFTLConfigValue dhcp.active false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ start() {
|
|||||||
echo " [i] Starting pihole-FTL ($FTL_CMD) as ${DNSMASQ_USER}"
|
echo " [i] Starting pihole-FTL ($FTL_CMD) as ${DNSMASQ_USER}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
capsh --user=$DNSMASQ_USER --keep=1 -- -c "/usr/bin/pihole-FTL $FTL_CMD >/dev/null" &
|
capsh --user="${DNSMASQ_USER}" --keep=1 -- -c "/usr/bin/pihole-FTL $FTL_CMD >/dev/null" &
|
||||||
# Notes on above:
|
# Notes on above:
|
||||||
# - DNSMASQ_USER default of pihole is in Dockerfile & can be overwritten by runtime container env
|
# - 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
|
# - /var/log/pihole/pihole*.log has FTL's output that no-daemon would normally print in FG too
|
||||||
@@ -103,7 +103,7 @@ start() {
|
|||||||
# Get the line number
|
# Get the line number
|
||||||
startFrom=$(grep -n '########## FTL started' /var/log/pihole/FTL.log | tail -1 | cut -d: -f1)
|
startFrom=$(grep -n '########## FTL started' /var/log/pihole/FTL.log | tail -1 | cut -d: -f1)
|
||||||
# Start the tail from the line number and background it
|
# Start the tail from the line number and background it
|
||||||
tail --follow=name -n +${startFrom} /var/log/pihole/FTL.log &
|
tail --follow=name -n +"${startFrom}" /var/log/pihole/FTL.log &
|
||||||
else
|
else
|
||||||
echo " [i] FTL log output is disabled. Remove the Environment variable TAIL_FTL_LOG, or set it to 1 to enable FTL log output."
|
echo " [i] FTL log output is disabled. Remove the Environment variable TAIL_FTL_LOG, or set it to 1 to enable FTL log output."
|
||||||
fi
|
fi
|
||||||
@@ -158,7 +158,7 @@ stop() {
|
|||||||
sleep 10
|
sleep 10
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit ${FTL_EXIT_CODE}
|
exit "${FTL_EXIT_CODE}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user