Get config options from pihole-FTL directly

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2023-02-11 13:59:28 +00:00
parent 4ec50469c7
commit 382367f968
No known key found for this signature in database
2 changed files with 10 additions and 39 deletions

View File

@ -5,13 +5,7 @@ if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
set -x ;
fi
gravityDBfile="/etc/pihole/gravity.db"
config_file="/etc/pihole/pihole-FTL.conf"
# make a point to mention which config file we're checking, as breadcrumb to revisit if/when pihole-FTL.conf is succeeded by TOML
echo " Checking if custom gravity.db is set in ${config_file}"
if [[ -f "${config_file}" ]]; then
gravityDBfile="$(grep --color=never -Po "^GRAVITYDB=\K.*" "${config_file}" 2> /dev/null || echo "/etc/pihole/gravity.db")"
fi
gravityDBfile=$(pihole-FTL --config files.gravity)
if [ -z "$SKIPGRAVITYONBOOT" ] || [ ! -f "${gravityDBfile}" ]; then
if [ -n "$SKIPGRAVITYONBOOT" ];then

View File

@ -9,8 +9,6 @@
# shellcheck source=/dev/null
. /opt/pihole/utils.sh
export FTLconf="/etc/pihole/pihole-FTL.conf"
export dnsmasqconfig="/etc/dnsmasq.d/01-pihole.conf"
export adlistFile="/etc/pihole/adlists.list"
fix_capabilities() {
@ -77,20 +75,6 @@ ensure_basic_configuration() {
# User is not passing in a custom location - so force FTL to use the file we moved to / during the build
setFTLConfigValue "files.macvendor" "/macvendor.db"
fi
# setup_or_skip_gravity
}
setup_FTL_User(){
# Run DNSMASQ as root user to avoid SHM permission issues
if grep -r -q '^\s*user=' /etc/dnsmasq.* ; then
# Change user that had been set previously to root
for f in $(grep -r -l '^\s*user=' /etc/dnsmasq.*); do
sed -i "/^\s*user=/ c\user=${DNSMASQ_USER}" "${f}"
done
else
echo -e "\nuser=${DNSMASQ_USER}" >> /etc/dnsmasq.conf
fi
}
apply_FTL_Configs_From_Env(){
@ -110,17 +94,18 @@ apply_FTL_Configs_From_Env(){
value="[\"${value//;/\",\"}\"]"
fi
if [ "$name" == "dns.reply.host.overwrite.v4" ]; then
name="dns.reply.host.overwrite_v4"
fi
if $(setFTLConfigValue "${name}" "${value}" 2>&1); then
echo " ${TICK} Applied pihole-FTL setting $name=$value"
if [ "$name" == "webserver.api.password" ]; then
masked_value=$(printf "%${#value}s" | tr " " "*")
else
echo " ${CROSS} Error Applying pihole-FTL setting $name=$value"
masked_value=$value
fi
if $(pihole-FTL --config "${name}" "${value}" > /ftlconfoutput); then
echo " ${TICK} Applied pihole-FTL setting $name=$masked_value"
else
echo " ${CROSS} Error Applying pihole-FTL setting $name=$masked_value"
echo " ${INFO} $(cat /ftlconfoutput)"
fi
done
echo "================================================================"
echo ""
@ -138,14 +123,6 @@ setup_FTL_query_logging(){
}
# setup_FTL_ProcessDNSSettings(){
# # Commit settings to 01-pihole.conf
# # shellcheck source=/dev/null
# #. /opt/pihole/webpage.sh
# # ProcessDNSSettings
# }
load_web_password_secret() {
# If WEBPASSWORD is not set at all, attempt to read password from WEBPASSWORD_FILE,