mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #2384 from pi-hole/feature/install-privacy-level
Set FTL Privacy Level During Install
This commit is contained in:
commit
1789a2db29
2 changed files with 39 additions and 0 deletions
|
@ -59,6 +59,7 @@ IPV6_ADDRESS=""
|
||||||
# By default, query logging is enabled and the dashboard is set to be installed
|
# By default, query logging is enabled and the dashboard is set to be installed
|
||||||
QUERY_LOGGING=true
|
QUERY_LOGGING=true
|
||||||
INSTALL_WEB_INTERFACE=true
|
INSTALL_WEB_INTERFACE=true
|
||||||
|
PRIVACY_LEVEL=0
|
||||||
|
|
||||||
if [ -z "${USER}" ]; then
|
if [ -z "${USER}" ]; then
|
||||||
USER="$(id -un)"
|
USER="$(id -un)"
|
||||||
|
@ -1017,6 +1018,28 @@ setLogging() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Allow the user to set their FTL privacy level
|
||||||
|
setPrivacyLevel() {
|
||||||
|
local LevelCommand
|
||||||
|
local LevelOptions
|
||||||
|
|
||||||
|
LevelCommand=(whiptail --separate-output --radiolist "Select a privacy mode for FTL." "${r}" "${c}" 6)
|
||||||
|
|
||||||
|
# The default selection is level 0
|
||||||
|
LevelOptions=(
|
||||||
|
"0" "Show everything" on
|
||||||
|
"1" "Hide domains" off
|
||||||
|
"2" "Hide domains and clients" off
|
||||||
|
"3" "Anonymous mode" off
|
||||||
|
"4" "Disabled statistics" off
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get the user's choice
|
||||||
|
PRIVACY_LEVEL=$("${LevelCommand[@]}" "${LevelOptions[@]}" 2>&1 >/dev/tty) || (echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}" && exit 1)
|
||||||
|
|
||||||
|
printf " %b Privacy level %d" "${INFO}" "${PRIVACY_LEVEL}"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to ask the user if they want to install the dashboard
|
# Function to ask the user if they want to install the dashboard
|
||||||
setAdminFlag() {
|
setAdminFlag() {
|
||||||
# Local, named variables
|
# Local, named variables
|
||||||
|
@ -1718,6 +1741,10 @@ finalExports() {
|
||||||
echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}"
|
echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}"
|
||||||
}>> "${setupVars}"
|
}>> "${setupVars}"
|
||||||
|
|
||||||
|
# Set the privacy level
|
||||||
|
sed -i '/PRIVACYLEVEL/d' "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"
|
||||||
|
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}"
|
||||||
source "${PI_HOLE_LOCAL_REPO}/advanced/Scripts/webpage.sh"
|
source "${PI_HOLE_LOCAL_REPO}/advanced/Scripts/webpage.sh"
|
||||||
|
@ -2414,11 +2441,22 @@ main() {
|
||||||
setAdminFlag
|
setAdminFlag
|
||||||
# Let the user decide if they want query logging enabled...
|
# Let the user decide if they want query logging enabled...
|
||||||
setLogging
|
setLogging
|
||||||
|
# Let the user decide the FTL privacy level
|
||||||
|
setPrivacyLevel
|
||||||
else
|
else
|
||||||
# Setup adlist file if not exists
|
# Setup adlist file if not exists
|
||||||
installDefaultBlocklists
|
installDefaultBlocklists
|
||||||
|
|
||||||
# Source ${setupVars} to use predefined user variables in the functions
|
# Source ${setupVars} to use predefined user variables in the functions
|
||||||
source ${setupVars}
|
source ${setupVars}
|
||||||
|
|
||||||
|
# Get the privacy level if it exists (default is 0)
|
||||||
|
if [[ -f "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" ]]; then
|
||||||
|
PRIVACY_LEVEL=$(sed -ne 's/PRIVACYLEVEL=\(.*\)/\1/p' "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf")
|
||||||
|
|
||||||
|
# If no setting was found, default to 0
|
||||||
|
PRIVACY_LEVEL="${PRIVACY_LEVEL:-0}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Clone/Update the repos
|
# Clone/Update the repos
|
||||||
clone_or_update_repos
|
clone_or_update_repos
|
||||||
|
|
|
@ -81,6 +81,7 @@ def test_setupVars_saved_to_file(Pihole):
|
||||||
{}
|
{}
|
||||||
mkdir -p /etc/dnsmasq.d
|
mkdir -p /etc/dnsmasq.d
|
||||||
version_check_dnsmasq
|
version_check_dnsmasq
|
||||||
|
echo "" > /etc/pihole/pihole-FTL.conf
|
||||||
finalExports
|
finalExports
|
||||||
cat /etc/pihole/setupVars.conf
|
cat /etc/pihole/setupVars.conf
|
||||||
'''.format(set_setup_vars))
|
'''.format(set_setup_vars))
|
||||||
|
|
Loading…
Reference in a new issue