@ -83,6 +83,7 @@ PI_HOLE_INSTALL_DIR="/opt/pihole"
PI_HOLE_CONFIG_DIR = "/etc/pihole"
PI_HOLE_CONFIG_DIR = "/etc/pihole"
PI_HOLE_BIN_DIR = "/usr/local/bin"
PI_HOLE_BIN_DIR = "/usr/local/bin"
PI_HOLE_404_DIR = " ${ webroot } /pihole "
PI_HOLE_404_DIR = " ${ webroot } /pihole "
FTL_CONFIG_FILE = " ${ PI_HOLE_CONFIG_DIR } /pihole-FTL.conf "
if [ -z " $useUpdateVars " ] ; then
if [ -z " $useUpdateVars " ] ; then
useUpdateVars = false
useUpdateVars = false
fi
fi
@ -1264,35 +1265,30 @@ version_check_dnsmasq() {
# Copy the new Pi-hole DNS config file into the dnsmasq.d directory
# Copy the new Pi-hole DNS config file into the dnsmasq.d directory
install -D -m 644 -T " ${ dnsmasq_pihole_01_source } " " ${ dnsmasq_pihole_01_target } "
install -D -m 644 -T " ${ dnsmasq_pihole_01_source } " " ${ dnsmasq_pihole_01_target } "
printf "%b %b Installed %s\n" " ${ OVER } " " ${ TICK } " " ${ dnsmasq_pihole_01_target } "
printf "%b %b Installed %s\n" " ${ OVER } " " ${ TICK } " " ${ dnsmasq_pihole_01_target } "
# Replace our placeholder value s with the GLOBAL DNS variables that we populated earlier
# Add setting s with the GLOBAL DNS variables that we populated earlier
# First, s wap in the interface to listen on,
# First, s et the interface to listen on
sed -i " s/@INT@/ $PIHOLE_INTERFACE / " " ${ dnsmasq_pihole_01_target } "
addOrEditKeyValPair " ${ dnsmasq_pihole_01_target } " "interface" " $PIHOLE_INTERFACE "
if [ [ " ${ PIHOLE_DNS_1 } " != "" ] ] ; then
if [ [ " ${ PIHOLE_DNS_1 } " != "" ] ] ; then
# then swap in the primary DNS server.
# then add in the primary DNS server.
sed -i " s/@DNS1@/ $PIHOLE_DNS_1 / " " ${ dnsmasq_pihole_01_target } "
addOrEditKeyValPair " ${ dnsmasq_pihole_01_target } " "server" " $$ PIHOLE_DNS_1 "
else
# Otherwise, remove the line which sets DNS1.
sed -i '/^server=@DNS1@/d' " ${ dnsmasq_pihole_01_target } "
fi
fi
# Ditto if DNS2 is not empty
# Ditto if DNS2 is not empty
if [ [ " ${ PIHOLE_DNS_2 } " != "" ] ] ; then
if [ [ " ${ PIHOLE_DNS_2 } " != "" ] ] ; then
sed -i " s/@DNS2@/ $PIHOLE_DNS_2 / " " ${ dnsmasq_pihole_01_target } "
addKey " ${ dnsmasq_pihole_01_target } " " server= $PIHOLE_DNS_2 "
else
sed -i '/^server=@DNS2@/d' " ${ dnsmasq_pihole_01_target } "
fi
fi
# Set the cache size
# Set the cache size
sed -i " s/@CACHE_SIZE@/ $CACHE_SIZE / " " ${ dnsmasq_pihole_01_target } "
addOrEditKeyValPair " ${ dnsmasq_pihole_01_target } " "cache-size" " $$ CACHE_SIZE "
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' " ${ dnsmasq_conf } "
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' " ${ dnsmasq_conf } "
# If the user does not want to enable logging,
# If the user does not want to enable logging,
if [ [ " ${ QUERY_LOGGING } " = = false ] ] ; then
if [ [ " ${ QUERY_LOGGING } " = = false ] ] ; then
# disable it by commenting out the directive in the DNS config file
# remove itfrom the DNS config file
sed -i 's/^log-queries/#log-queries/' " ${ dnsmasq_pihole_01_target } "
removeKey " ${ dnsmasq_pihole_01_target } " "log-queries"
else
else
# Otherwise, enable it by uncommenting the directive in the DNS config file
# Otherwise, enable it by adding the directive to the DNS config file
sed -i 's/^#log-queries/log-queries/' " ${ dnsmasq_pihole_01_target } "
addKey " ${ dnsmasq_pihole_01_target } " "log-queries"
fi
fi
printf " %b Installing %s..." " ${ INFO } " " ${ dnsmasq_rfc6761_06_source } "
printf " %b Installing %s..." " ${ INFO } " " ${ dnsmasq_rfc6761_06_source } "
@ -1365,9 +1361,9 @@ installConfigs() {
chmod 644 " ${ PI_HOLE_CONFIG_DIR } /dns-servers.conf "
chmod 644 " ${ PI_HOLE_CONFIG_DIR } /dns-servers.conf "
# Install template file if it does not exist
# Install template file if it does not exist
if [ [ ! -r " ${ PI_HOLE_CONFIG_DIR} /pihole-FTL.conf " ] ] ; then
if [ [ ! -r " ${ FTL_CONFIG_FILE} " ] ] ; then
install -d -m 0755 ${ PI_HOLE_CONFIG_DIR }
install -d -m 0755 ${ PI_HOLE_CONFIG_DIR }
if ! install -T -o pihole -m 664 " ${ PI_HOLE_LOCAL_REPO } /advanced/Templates/pihole-FTL.conf " " ${ PI_HOLE_CONFIG_DIR} /pihole-FTL.conf " & >/dev/null; then
if ! install -T -o pihole -m 664 " ${ PI_HOLE_LOCAL_REPO } /advanced/Templates/pihole-FTL.conf " " ${ FTL_CONFIG_FILE} " & >/dev/null; then
printf " %b Error: Unable to initialize configuration file %s/pihole-FTL.conf\\n" " ${ COL_LIGHT_RED } " " ${ PI_HOLE_CONFIG_DIR } "
printf " %b Error: Unable to initialize configuration file %s/pihole-FTL.conf\\n" " ${ COL_LIGHT_RED } " " ${ PI_HOLE_CONFIG_DIR } "
return 1
return 1
fi
fi
@ -1784,30 +1780,24 @@ create_pihole_user() {
# This function saves any changes to the setup variables into the setupvars.conf file for future runs
# This function saves any changes to the setup variables into the setupvars.conf file for future runs
finalExports( ) {
finalExports( ) {
# If the setup variable file exists,
# set or update the variables in the file
if [ [ -e " ${ setupVars } " ] ] ; then
# update the variables in the file
addOrEditKeyValPair " ${ setupVars } " "PIHOLE_INTERFACE" " ${ PIHOLE_INTERFACE } "
sed -i.update.bak '/PIHOLE_INTERFACE/d;/PIHOLE_DNS_1\b/d;/PIHOLE_DNS_2\b/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;/CACHE_SIZE/d;/DNS_FQDN_REQUIRED/d;/DNS_BOGUS_PRIV/d;/DNSMASQ_LISTENING/d;' " ${ setupVars } "
addOrEditKeyValPair " ${ setupVars } " "PIHOLE_DNS_1" " ${ PIHOLE_DNS_1 } "
fi
addOrEditKeyValPair " ${ setupVars } " "PIHOLE_DNS_2" " ${ PIHOLE_DNS_2 } "
# echo the information to the user
addOrEditKeyValPair " ${ setupVars } " "QUERY_LOGGING" " ${ QUERY_LOGGING } "
{
addOrEditKeyValPair " ${ setupVars } " "INSTALL_WEB_SERVER" " ${ INSTALL_WEB_SERVER } "
echo " PIHOLE_INTERFACE= ${ PIHOLE_INTERFACE } "
addOrEditKeyValPair " ${ setupVars } " "INSTALL_WEB_INTERFACE" " ${ INSTALL_WEB_INTERFACE } "
echo " PIHOLE_DNS_1= ${ PIHOLE_DNS_1 } "
addOrEditKeyValPair " ${ setupVars } " "LIGHTTPD_ENABLED" " ${ LIGHTTPD_ENABLED } "
echo " PIHOLE_DNS_2= ${ PIHOLE_DNS_2 } "
addOrEditKeyValPair " ${ setupVars } " "CACHE_SIZE" " ${ CACHE_SIZE } "
echo " QUERY_LOGGING= ${ QUERY_LOGGING } "
addOrEditKeyValPair " ${ setupVars } " "DNS_FQDN_REQUIRED" " ${ DNS_FQDN_REQUIRED :- true } "
echo " INSTALL_WEB_SERVER= ${ INSTALL_WEB_SERVER } "
addOrEditKeyValPair " ${ setupVars } " "DNS_BOGUS_PRIV" " ${ DNS_BOGUS_PRIV :- true } "
echo " INSTALL_WEB_INTERFACE= ${ INSTALL_WEB_INTERFACE } "
addOrEditKeyValPair " ${ setupVars } " "DNSMASQ_LISTENING" " ${ DNSMASQ_LISTENING :- local } "
echo " LIGHTTPD_ENABLED= ${ LIGHTTPD_ENABLED } "
echo " CACHE_SIZE= ${ CACHE_SIZE } "
echo " DNS_FQDN_REQUIRED= ${ DNS_FQDN_REQUIRED :- true } "
echo " DNS_BOGUS_PRIV= ${ DNS_BOGUS_PRIV :- true } "
echo " DNSMASQ_LISTENING= ${ DNSMASQ_LISTENING :- local } "
} >> " ${ setupVars } "
chmod 644 " ${ setupVars } "
chmod 644 " ${ setupVars } "
# Set the privacy level
# Set the privacy level
sed -i '/PRIVACYLEVEL/d' " ${ PI_HOLE_CONFIG_DIR } /pihole-FTL.conf "
addOrEditKeyValPair " ${ FTL_CONFIG_FILE } " "PRIVACYLEVEL" " ${ PRIVACY_LEVEL } "
echo " PRIVACYLEVEL= ${ PRIVACY_LEVEL } " >> " ${ PI_HOLE_CONFIG_DIR } /pihole-FTL.conf "
# Bring in the current settings and the functions to manipulate them
# Bring in the current settings and the functions to manipulate them
source " ${ setupVars } "
source " ${ setupVars } "
@ -1895,6 +1885,16 @@ installPihole() {
printf " %b Failure in dependent script copy function.\\n" " ${ CROSS } "
printf " %b Failure in dependent script copy function.\\n" " ${ CROSS } "
exit 1
exit 1
fi
fi
# /opt/pihole/utils.sh should be installed by installScripts now, so we can use it
if [ -f " ${ PI_HOLE_INSTALL_DIR } /utils.sh " ] ; then
# shellcheck disable=SC1091
source " ${ PI_HOLE_INSTALL_DIR } /utils.sh "
else
printf " %b Failure: /opt/pihole/utils.sh does not exist .\\n" " ${ CROSS } "
exit 1
fi
# Install config files
# Install config files
if ! installConfigs; then
if ! installConfigs; then
printf " %b Failure in dependent config copy function.\\n" " ${ CROSS } "
printf " %b Failure in dependent config copy function.\\n" " ${ CROSS } "
@ -2569,8 +2569,8 @@ main() {
source " ${ setupVars } "
source " ${ setupVars } "
# Get the privacy level if it exists (default is 0)
# Get the privacy level if it exists (default is 0)
if [ [ -f " ${ PI_HOLE_CONFIG_DIR} /pihole-FTL.conf " ] ] ; then
if [ [ -f " ${ FTL_CONFIG_FILE} " ] ] ; then
PRIVACY_LEVEL = $( sed -ne 's/PRIVACYLEVEL=\(.*\)/\1/p' " ${ PI_HOLE_CONFIG_DIR} /pihole-FTL.conf " )
PRIVACY_LEVEL = $( sed -ne 's/PRIVACYLEVEL=\(.*\)/\1/p' " ${ FTL_CONFIG_FILE} " )
# If no setting was found, default to 0
# If no setting was found, default to 0
PRIVACY_LEVEL = " ${ PRIVACY_LEVEL :- 0 } "
PRIVACY_LEVEL = " ${ PRIVACY_LEVEL :- 0 } "