mirror of https://github.com/pi-hole/pi-hole
commit
ddbdb51d20
@ -0,0 +1,2 @@
|
||||
require:
|
||||
members: false
|
@ -1,3 +1,6 @@
|
||||
linters:
|
||||
shellcheck:
|
||||
shell: bash
|
||||
phpcs:
|
||||
csslint:
|
||||
flake8:
|
||||
|
@ -1,23 +0,0 @@
|
||||
# The below list amalgamates several lists we used previously.
|
||||
# See `https://github.com/StevenBlack/hosts` for details
|
||||
##StevenBlack's list
|
||||
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
||||
|
||||
##MalwareDomains
|
||||
https://mirror1.malwaredomains.com/files/justdomains
|
||||
|
||||
##Cameleon
|
||||
http://sysctl.org/cameleon/hosts
|
||||
|
||||
##Zeustracker
|
||||
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
|
||||
|
||||
##Disconnect.me Tracking
|
||||
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
||||
|
||||
##Disconnect.me Ads
|
||||
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||
|
||||
##Hosts-file.net
|
||||
https://hosts-file.net/ad_servers.txt
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC1090
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2018 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Query Domain Lists
|
||||
#
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
# Globals
|
||||
piholeDir="/etc/pihole"
|
||||
adListsList="$piholeDir/adlists.list"
|
||||
wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||
options="$*"
|
||||
adlist=""
|
||||
all=""
|
||||
exact=""
|
||||
blockpage=""
|
||||
matchType="match"
|
||||
|
||||
colfile="/opt/pihole/COL_TABLE"
|
||||
source "${colfile}"
|
||||
|
||||
# Print each subdomain
|
||||
# e.g: foo.bar.baz.com = "foo.bar.baz.com bar.baz.com baz.com com"
|
||||
processWildcards() {
|
||||
IFS="." read -r -a array <<< "${1}"
|
||||
for (( i=${#array[@]}-1; i>=0; i-- )); do
|
||||
ar=""
|
||||
for (( j=${#array[@]}-1; j>${#array[@]}-i-2; j-- )); do
|
||||
if [[ $j == $((${#array[@]}-1)) ]]; then
|
||||
ar="${array[$j]}"
|
||||
else
|
||||
ar="${array[$j]}.${ar}"
|
||||
fi
|
||||
done
|
||||
echo "${ar}"
|
||||
done
|
||||
}
|
||||
|
||||
# Scan an array of files for matching strings
|
||||
scanList(){
|
||||
# Escape full stops
|
||||
local domain="${1//./\\.}" lists="${2}" type="${3:-}"
|
||||
|
||||
# Prevent grep from printing file path
|
||||
cd "$piholeDir" || exit 1
|
||||
|
||||
# Prevent grep -i matching slowly: http://bit.ly/2xFXtUX
|
||||
export LC_CTYPE=C
|
||||
|
||||
# /dev/null forces filename to be printed when only one list has been generated
|
||||
# shellcheck disable=SC2086
|
||||
case "${type}" in
|
||||
"exact" ) grep -i -E -l "(^|\\s)${domain}($|\\s|#)" ${lists} /dev/null 2>/dev/null;;
|
||||
"wc" ) grep -i -o -m 1 "/${domain}/" ${lists} 2>/dev/null;;
|
||||
* ) grep -i "${domain}" ${lists} /dev/null 2>/dev/null;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ "${options}" == "-h" ]] || [[ "${options}" == "--help" ]]; then
|
||||
echo "Usage: pihole -q [option] <domain>
|
||||
Example: 'pihole -q -exact domain.com'
|
||||
Query the adlists for a specified domain
|
||||
|
||||
Options:
|
||||
-adlist Print the name of the block list URL
|
||||
-exact Search the block lists for exact domain matches
|
||||
-all Return all query matches within a block list
|
||||
-h, --help Show this help dialog"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -e "$adListsList" ]]; then
|
||||
echo -e "${COL_LIGHT_RED}The file $adListsList was not found${COL_NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Handle valid options
|
||||
if [[ "${options}" == *"-bp"* ]]; then
|
||||
exact="exact"; blockpage=true
|
||||
else
|
||||
[[ "${options}" == *"-adlist"* ]] && adlist=true
|
||||
[[ "${options}" == *"-all"* ]] && all=true
|
||||
if [[ "${options}" == *"-exact"* ]]; then
|
||||
exact="exact"; matchType="exact ${matchType}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Strip valid options, leaving only the domain and invalid options
|
||||
# This allows users to place the options before or after the domain
|
||||
options=$(sed -E 's/ ?-(bp|adlists?|all|exact) ?//g' <<< "${options}")
|
||||
|
||||
# Handle remaining options
|
||||
# If $options contain non ASCII characters, convert to punycode
|
||||
case "${options}" in
|
||||
"" ) str="No domain specified";;
|
||||
*" "* ) str="Unknown query option specified";;
|
||||
*[![:ascii:]]* ) domainQuery=$(idn2 "${options}");;
|
||||
* ) domainQuery="${options}";;
|
||||
esac
|
||||
|
||||
if [[ -n "${str:-}" ]]; then
|
||||
echo -e "${str}${COL_NC}\\nTry 'pihole -q --help' for more information."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Scan Whitelist and Blacklist
|
||||
lists="whitelist.txt blacklist.txt"
|
||||
mapfile -t results <<< "$(scanList "${domainQuery}" "${lists}" "${exact}")"
|
||||
if [[ -n "${results[*]}" ]]; then
|
||||
wbMatch=true
|
||||
# Loop through each result in order to print unique file title once
|
||||
for result in "${results[@]}"; do
|
||||
fileName="${result%%.*}"
|
||||
if [[ -n "${blockpage}" ]]; then
|
||||
echo "π ${result}"
|
||||
exit 0
|
||||
elif [[ -n "${exact}" ]]; then
|
||||
echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}"
|
||||
else
|
||||
# Only print filename title once per file
|
||||
if [[ ! "${fileName}" == "${fileName_prev:-}" ]]; then
|
||||
echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}"
|
||||
fileName_prev="${fileName}"
|
||||
fi
|
||||
echo " ${result#*:}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Scan Wildcards
|
||||
if [[ -e "${wildcardlist}" ]]; then
|
||||
# Determine all subdomains, domain and TLDs
|
||||
mapfile -t wildcards <<< "$(processWildcards "${domainQuery}")"
|
||||
for match in "${wildcards[@]}"; do
|
||||
# Search wildcard list for matches
|
||||
mapfile -t results <<< "$(scanList "${match}" "${wildcardlist}" "wc")"
|
||||
if [[ -n "${results[*]}" ]]; then
|
||||
if [[ -z "${wcMatch:-}" ]] && [[ -z "${blockpage}" ]]; then
|
||||
wcMatch=true
|
||||
echo " ${matchType^} found in ${COL_BOLD}Wildcards${COL_NC}:"
|
||||
fi
|
||||
case "${blockpage}" in
|
||||
true ) echo "π ${wildcardlist##*/}"; exit 0;;
|
||||
* ) echo " *.${match}";;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Get version sorted *.domains filenames (without dir path)
|
||||
lists=("$(cd "$piholeDir" || exit 0; printf "%s\\n" -- *.domains | sort -V)")
|
||||
|
||||
# Query blocklists for occurences of domain
|
||||
mapfile -t results <<< "$(scanList "${domainQuery}" "${lists[*]}" "${exact}")"
|
||||
|
||||
# Handle notices
|
||||
if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then
|
||||
echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists"
|
||||
exit 0
|
||||
elif [[ -z "${results[*]}" ]]; then
|
||||
# Result found in WL/BL/Wildcards
|
||||
exit 0
|
||||
elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then
|
||||
echo -e " ${INFO} Over 100 ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC}
|
||||
This can be overridden using the -all option"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Remove unwanted content from non-exact $results
|
||||
if [[ -z "${exact}" ]]; then
|
||||
# Delete lines starting with #
|
||||
# Remove comments after domain
|
||||
# Remove hosts format IP address
|
||||
mapfile -t results <<< "$(IFS=$'\n'; sed \
|
||||
-e "/:#/d" \
|
||||
-e "s/[ \\t]#.*//g" \
|
||||
-e "s/:.*[ \\t]/:/g" \
|
||||
<<< "${results[*]}")"
|
||||
# Exit if result was in a comment
|
||||
[[ -z "${results[*]}" ]] && exit 0
|
||||
fi
|
||||
|
||||
# Get adlist file content as array
|
||||
if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then
|
||||
for adlistUrl in $(< "${adListsList}"); do
|
||||
if [[ "${adlistUrl:0:4}" =~ (http|www.) ]]; then
|
||||
adlists+=("${adlistUrl}")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Print "Exact matches for" title
|
||||
if [[ -n "${exact}" ]] && [[ -z "${blockpage}" ]]; then
|
||||
plural=""; [[ "${#results[*]}" -gt 1 ]] && plural="es"
|
||||
echo " ${matchType^}${plural} for ${COL_BOLD}${domainQuery}${COL_NC} found in:"
|
||||
fi
|
||||
|
||||
for result in "${results[@]}"; do
|
||||
fileName="${result/:*/}"
|
||||
|
||||
# Determine *.domains URL using filename's number
|
||||
if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then
|
||||
fileNum="${fileName/list./}"; fileNum="${fileNum%%.*}"
|
||||
fileName="${adlists[$fileNum]}"
|
||||
|
||||
# Discrepency occurs when adlists has been modified, but Gravity has not been run
|
||||
if [[ -z "${fileName}" ]]; then
|
||||
fileName="${COL_LIGHT_RED}(no associated adlists URL found)${COL_NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "${blockpage}" ]]; then
|
||||
echo "${fileNum} ${fileName}"
|
||||
elif [[ -n "${exact}" ]]; then
|
||||
echo " ${fileName}"
|
||||
else
|
||||
if [[ ! "${fileName}" == "${fileName_prev:-}" ]]; then
|
||||
count=""
|
||||
echo " ${matchType^} found in ${COL_BOLD}${fileName}${COL_NC}:"
|
||||
fileName_prev="${fileName}"
|
||||
fi
|
||||
: $((count++))
|
||||
|
||||
# Print matching domain if $max_count has not been reached
|
||||
[[ -z "${all}" ]] && max_count="50"
|
||||
if [[ -z "${all}" ]] && [[ "${count}" -ge "${max_count}" ]]; then
|
||||
[[ "${count}" -gt "${max_count}" ]] && continue
|
||||
echo " ${COL_GRAY}Over ${count} results found, skipping rest of file${COL_NC}"
|
||||
else
|
||||
echo " ${result#*:}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Provides an automated migration subroutine to convert Pi-hole v3.x wildcard domains to Pi-hole v4.x regex filters
|
||||
#
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
# regexFile set in gravity.sh
|
||||
|
||||
wildcardFile="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||
|
||||
convert_wildcard_to_regex() {
|
||||
if [ ! -f "${wildcardFile}" ]; then
|
||||
return
|
||||
fi
|
||||
local addrlines domains uniquedomains
|
||||
# Obtain wildcard domains from old file
|
||||
addrlines="$(grep -oE "/.*/" ${wildcardFile})"
|
||||
# Strip "/" from domain names and convert "." to regex-compatible "\."
|
||||
domains="$(sed 's/\///g;s/\./\\./g' <<< "${addrlines}")"
|
||||
# Remove repeated domains (may have been inserted two times due to A and AAAA blocking)
|
||||
uniquedomains="$(uniq <<< "${domains}")"
|
||||
# Automatically generate regex filters and remove old wildcards file
|
||||
awk '{print "(^|\\.)"$0"$"}' <<< "${uniquedomains}" >> "${regexFile:?}" && rm "${wildcardFile}"
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
### This file contains parameters for FTL behavior.
|
||||
### At install, all parameters are commented out. The user can select desired options.
|
||||
### Options shown are the default configuration. No modification is needed for most
|
||||
### installations.
|
||||
### Visit https://docs.pi-hole.net/ftldns/configfile/ for more detailed parameter explanations
|
||||
|
||||
## Socket Listening
|
||||
## Listen only for local socket connections or permit all connections
|
||||
## Options: localonly, all
|
||||
#SOCKET_LISTENING=localonly
|
||||
|
||||
## Query Display
|
||||
## Display all queries? Set to no to hide query display
|
||||
## Options: yes, no
|
||||
#QUERY_DISPLAY=yes
|
||||
|
||||
## AAA Query Analysis
|
||||
## Allow FTL to analyze AAAA queries from pihole.log?
|
||||
## Options: yes, no
|
||||
#AAAA_QUERY_ANALYSIS=yes
|
||||
|
||||
## Resolve IPv6
|
||||
## Should FTL try to resolve IPv6 addresses to host names?
|
||||
## Options: yes, no
|
||||
#RESOLVE_IPV6=yes
|
||||
|
||||
## Resolve IPv4
|
||||
## Should FTL try to resolve IPv4 addresses to host names?
|
||||
## Options: yes, no
|
||||
#RESOLVE_IPV4=yes
|
||||
|
||||
## Max Database Days
|
||||
## How long should queries be stored in the database (days)?
|
||||
## Setting this to 0 disables the database
|
||||
## See: https://docs.pi-hole.net/ftldns/database/
|
||||
## Options: number of days
|
||||
#MAXDBDAYS=365
|
||||
|
||||
## Database Interval
|
||||
## How often do we store queries in FTL's database (minutes)?
|
||||
## See: https://docs.pi-hole.net/ftldns/database/
|
||||
## Options: number of minutes
|
||||
#DBINTERVAL=1.0
|
||||
|
||||
## Database File
|
||||
## Specify path and filename of FTL's SQLite3 long-term database.
|
||||
## Setting this to DBFILE= disables the database altogether
|
||||
## See: https://docs.pi-hole.net/ftldns/database/
|
||||
## Option: path to db file
|
||||
#DBFILE=/etc/pihole/pihole-FTL.db
|
||||
|
||||
## Max Log Age
|
||||
## Up to how many hours of queries should be imported from the database and logs (hours)?
|
||||
## Maximum is 744 (31 days)
|
||||
## Options: number of days
|
||||
#MAXLOGAGE=24.0
|
||||
|
||||
## FTL Port
|
||||
## On which port should FTL be listening?
|
||||
## Options: tcp port
|
||||
#FTLPORT=4711
|
||||
|
||||
## Privacy Level
|
||||
## Which privacy level is used?
|
||||
## See: https://docs.pi-hole.net/ftldns/privacylevels/
|
||||
## Options: 0, 1, 2, 3
|
||||
#PRIVACYLEVEL=0
|
||||
|
||||
## Ignore Localhost
|
||||
## Should FTL ignore queries coming from the local machine?
|
||||
## Options: yes, no
|
||||
#IGNORE_LOCALHOST=no
|
||||
|
||||
## Blocking Mode
|
||||
## How should FTL reply to blocked queries?
|
||||
## See: https://docs.pi-hole.net/ftldns/blockingmode/
|
||||
## Options: NULL, IP-AAAA-NODATA, IP, NXDOMAIN
|
||||
#BLOCKINGMODE=NULL
|
||||
|
||||
## Regex Debug Mode
|
||||
## Controls if FTLDNS should print extended details about regex matching into pihole-FTL.log.
|
||||
## See: https://docs.pi-hole.net/ftldns/regex/overview/
|
||||
## Options: true, false
|
||||
#REGEX_DEBUGMODE=false
|
@ -1,11 +1,79 @@
|
||||
_pihole() {
|
||||
local cur prev opts
|
||||
local cur prev opts opts_admin opts_checkout opts_chronometer opts_debug opts_interface opts_logging opts_privacy opts_query opts_update opts_version
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist checkout"
|
||||
prev2="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
case "${prev}" in
|
||||
"pihole")
|
||||
opts="admin blacklist checkout chronometer debug disable enable flush help logging query reconfigure regex restartdns status tail uninstall updateGravity updatePihole version wildcard whitelist"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
;;
|
||||
"whitelist"|"blacklist"|"wildcard"|"regex")
|
||||
opts_lists="\--delmode \--noreload \--quiet \--list \--nuke"
|
||||
COMPREPLY=( $(compgen -W "${opts_lists}" -- ${cur}) )
|
||||
;;
|
||||
"admin")
|
||||
opts_admin="celsius email fahrenheit hostrecord interface kelvin password privacylevel"
|
||||
COMPREPLY=( $(compgen -W "${opts_admin}" -- ${cur}) )
|
||||
;;
|
||||
"checkout")
|
||||
opts_checkout="core ftl web master dev"
|
||||
COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${cur}) )
|
||||
;;
|
||||
"chronometer")
|
||||
opts_chronometer="\--exit \--json \--refresh"
|
||||
COMPREPLY=( $(compgen -W "${opts_chronometer}" -- ${cur}) )
|
||||
;;
|
||||
"debug")
|
||||
opts_debug="-a"
|
||||
COMPREPLY=( $(compgen -W "${opts_debug}" -- ${cur}) )
|
||||
;;
|
||||
"logging")
|
||||
opts_logging="on off 'off noflush'"
|
||||
COMPREPLY=( $(compgen -W "${opts_logging}" -- ${cur}) )
|
||||
;;
|
||||
"query")
|
||||
opts_query="-adlist -all -exact"
|
||||
COMPREPLY=( $(compgen -W "${opts_query}" -- ${cur}) )
|
||||
;;
|
||||
"updatePihole"|"-up")
|
||||
opts_update="--check-only"
|
||||
COMPREPLY=( $(compgen -W "${opts_update}" -- ${cur}) )
|
||||
;;
|
||||
"version")
|
||||
opts_version="\--admin \--current \--ftl \--hash \--latest \--pihole"
|
||||
COMPREPLY=( $(compgen -W "${opts_version}" -- ${cur}) )
|
||||
;;
|
||||
"interface")
|
||||
if ( [[ "$prev2" == "admin" ]] || [[ "$prev2" == "-a" ]] ); then
|
||||
opts_interface="$(cat /proc/net/dev | cut -d: -s -f1)"
|
||||
COMPREPLY=( $(compgen -W "${opts_interface}" -- ${cur}) )
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
"privacylevel")
|
||||
if ( [[ "$prev2" == "admin" ]] || [[ "$prev2" == "-a" ]] ); then
|
||||
opts_privacy="0 1 2 3"
|
||||
COMPREPLY=( $(compgen -W "${opts_privacy}" -- ${cur}) )
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
"core"|"admin"|"ftl")
|
||||
if [[ "$prev2" == "checkout" ]]; then
|
||||
opts_checkout="master dev"
|
||||
COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${cur}) )
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
complete -F _pihole pihole
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,112 @@
|
||||
.TH "Pihole-FTL" "8" "pihole-FTL" "Pi-hole" "June 2018"
|
||||
.SH "NAME"
|
||||
pihole-FTL - Pi-hole : The Faster-Than-Light (FTL) Engine
|
||||
.br
|
||||
.SH "SYNOPSIS"
|
||||
\fBservice pihole-FTL \fR(\fBstart\fR|\fBstop\fR|\fBrestart\fR)
|
||||
.br
|
||||
|
||||
\fBpihole-FTL debug\fR
|
||||
.br
|
||||
\fBpihole-FTL test\fR
|
||||
.br
|
||||
\fBpihole-FTL -v\fR
|
||||
.br
|
||||
\fBpihole-FTL -t\fR
|
||||
.br
|
||||
\fBpihole-FTL -b\fR
|
||||
.br
|
||||
\fBpihole-FTL -f\fR
|
||||
.br
|
||||
\fBpihole-FTL -h\fR
|
||||
.br
|
||||
\fBpihole-FTL dnsmasq-test\fR
|
||||
.br
|
||||
\fBpihole-FTL --\fR (\fBoptions\fR)
|
||||
.br
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built daemon used to provide statistics needed for the Pi-hole Web Interface, and its API can be easily integrated into your own projects. Although it is an optional component of the Pi-hole ecosystem, it will be installed by default to provide statistics. As the name implies, FTL does its work \fIvery\fR \fIquickly\fR!
|
||||
.br
|
||||
|
||||
Usage
|
||||
.br
|
||||
|
||||
\fBservice pihole-FTL start\fR
|
||||
.br
|
||||
Start the pihole-FTL daemon
|
||||
.br
|
||||
|
||||
\fBservice pihole-FTL stop\fR
|
||||
.br
|
||||
Stop the pihole-FTL daemon
|
||||
.br
|
||||
|
||||
\fBservice pihole-FTL restart\fR
|
||||
.br
|
||||
If the pihole-FTP daemon is running, stop and then start, otherwise start.
|
||||
.br
|
||||
|
||||
Command line arguments
|
||||
.br
|
||||
|
||||
\fBdebug\fR
|
||||
.br
|
||||
Don't go into daemon mode (stay in foreground) + more verbose logging
|
||||
.br
|
||||
|
||||
\fBtest\fR
|
||||
.br
|
||||
Start FTL and process everything, but shut down immediately afterwards
|
||||
.br
|
||||
|
||||
\fB-v, version\fR
|
||||
.br
|
||||
Don't start FTL, show only version
|
||||
.br
|
||||
|
||||
\fB-t, tag\fR
|
||||
.br
|
||||
Don't start FTL, show only git tag
|
||||
.br
|
||||
|
||||
\fB-b, branch\fR
|
||||
.br
|
||||
Don't start FTL, show only git branch FTL was compiled from
|
||||
.br
|
||||
|
||||
\fB-f, no-daemon\fR
|
||||
.br
|
||||
Don't go into background (daemon mode)
|
||||
.br
|
||||
|
||||
\fB-h, help\fR
|
||||
.br
|
||||
Don't start FTL, show help
|
||||
.br
|
||||
|
||||
\fBdnsmasq-test\fR
|
||||
.br
|
||||
Test resolver config file syntax
|
||||
.br
|
||||
|
||||
\fB--\fR (options)
|
||||
.br
|
||||
Pass options to internal dnsmasq resolver
|
||||
.br
|
||||
.SH "EXAMPLE"
|
||||
Command line arguments can be arbitrarily combined, e.g:
|
||||
.br
|
||||
|
||||
\fBpihole-FTL debug test\fR
|
||||
.br
|
||||
|
||||
Start ftl in foreground with more verbose logging, process everything and shutdown immediately
|
||||
.br
|
||||
.SH "SEE ALSO"
|
||||
\fBpihole\fR(8), \fBpihole-FTL.conf\fR(5)
|
||||
.br
|
||||
.SH "COLOPHON"
|
||||
|
||||
Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net
|
||||
.br
|
@ -0,0 +1,102 @@
|
||||
.TH "pihole-FTL.conf" "5" "pihole-FTL.conf" "pihole-FTL.conf" "June 2018"
|
||||
.SH "NAME"
|
||||
|
||||
pihole-FTL.conf - FTL's config file
|
||||
.br
|
||||
.SH "DESCRIPTION"
|
||||
|
||||
/etc/pihole/pihole-FTL.conf will be read by \fBpihole-FTL(8)\fR on startup.
|
||||
.br
|
||||
|
||||
\fBSOCKET_LISTENING=localonly|all\fR
|
||||
.br
|
||||
Listen only for local socket connections or permit all connections
|
||||
.br
|
||||
|
||||
\fBQUERY_DISPLAY=yes|no\fR
|
||||
.br
|
||||
Display all queries? Set to no to hide query display
|
||||
.br
|
||||
|
||||
\fBAAAA_QUERY_ANALYSIS=yes|no\fR
|
||||
.br
|
||||
Allow FTL to analyze AAAA queries from pihole.log?
|
||||
.br
|
||||
|
||||
\fBRESOLVE_IPV6=yes|no\fR
|
||||
.br
|
||||
Should FTL try to resolve IPv6 addresses to host names?
|
||||
.br
|
||||
|
||||
\fBRESOLVE_IPV4=yes|no\fR
|
||||
.br
|
||||
Should FTL try to resolve IPv4 addresses to host names?
|
||||
.br
|
||||
|
||||
\fBMAXDBDAYS=365\fR
|
||||
.br
|
||||
How long should queries be stored in the database?
|
||||
.br
|
||||
Setting this to 0 disables the database
|
||||
.br
|
||||
|
||||
\fBDBINTERVAL=1.0\fR
|
||||
.br
|
||||
How often do we store queries in FTL's database [minutes]?
|
||||
.br
|
||||
|
||||
\fBDBFILE=/etc/pihole/pihole-FTL.db\fR
|
||||
.br
|
||||
Specify path and filename of FTL's SQLite long-term database.
|
||||
.br
|
||||
Setting this to DBFILE= disables the database altogether
|
||||
.br
|
||||
|
||||
\fBMAXLOGAGE=24.0\fR
|
||||
.br
|
||||
Up to how many hours of queries should be imported from the database and logs?
|
||||
.br
|
||||
Maximum is 744 (31 days)
|
||||
.br
|
||||
|
||||
\fBFTLPORT=4711\fR
|
||||
.br
|
||||
On which port should FTL be listening?
|
||||
.br
|
||||
|
||||
\fBPRIVACYLEVEL=0|1|2|3\fR
|
||||
.br
|
||||
Which privacy level is used?
|
||||
.br
|
||||
0 - show everything
|
||||
.br
|
||||
1 - hide domains
|
||||
.br
|
||||
2 - hide domains and clients
|
||||
.br
|
||||
3 - paranoia mode (hide everything)
|
||||
.br
|
||||
|
||||
\fBIGNORE_LOCALHOST=no|yes\fR
|
||||
.br
|
||||
Should FTL ignore queries coming from the local machine?
|
||||
.br
|
||||
|
||||
\fBBLOCKINGMODE=IP|IP-AAAA-NODATA|NXDOMAIN|NULL\fR
|
||||
.br
|
||||
How should FTL reply to blocked queries?
|
||||
.br
|
||||
|
||||
For each setting, the option shown first is the default.
|
||||
.br
|
||||
.SH "SEE ALSO"
|
||||
|
||||
\fBpihole\fR(8), \fBpihole-FTL\fR(8)
|
||||
.br
|
||||
.SH "COLOPHON"
|
||||
|
||||
Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built daemon used to provide statistics needed for the Pi-hole Web Interface, and its API can be easily integrated into your own projects. Although it is an optional component of the Pi-hole ecosystem, it will be installed by default to provide statistics. As the name implies, FTL does its work \fIvery quickly\fR!
|
||||
.br
|
||||
|
||||
Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net
|
||||
.br
|
@ -0,0 +1,361 @@
|
||||
.TH "Pi-hole" "8" "Pi-hole" "Pi-hole" "May 2018"
|
||||
.SH "NAME"
|
||||
|
||||
Pi-hole : A black-hole for internet advertisements
|
||||
.br
|
||||
.SH "SYNOPSIS"
|
||||
|
||||
\fBpihole\fR (\fB-w\fR|\fB-b\fR|\fB--wild\fR|\fB--regex\fR) [options] domain(s)
|
||||
.br
|
||||
\fBpihole -a\fR \fB-p\fR password
|
||||
.br
|
||||
\fBpihole -a\fR (\fB-c|-f|-k\fR)
|
||||
.br
|
||||
\fBpihole -a\fR [\fB-r\fR hostrecord]
|
||||
.br
|
||||
\fBpihole -a -e\fR email
|
||||
.br
|
||||
\fBpihole -a -i\fR interface
|
||||
.br
|
||||
\fBpihole -a -l\fR privacylevel
|
||||
.br
|
||||
\fBpihole -c\fR [-j|-r|-e]
|
||||
.br
|
||||
\fBpihole\fR \fB-d\fR [-a]
|
||||
.br
|
||||
\fBpihole -f
|
||||
.br
|
||||
pihole -r
|
||||
.br
|
||||
pihole -t
|
||||
.br
|
||||
pihole -g\fR
|
||||
.br
|
||||
\fBpihole\fR -\fBq\fR [options]
|
||||
.br
|
||||
\fBpihole\fR \fB-l\fR (\fBon|off|off noflush\fR)
|
||||
.br
|
||||
\fBpihole -up \fR[--checkonly]
|
||||
.br
|
||||
\fBpihole -v\fR [-p|-a|-f] [-c|-l|-hash]
|
||||
.br
|
||||
\fBpihole uninstall
|
||||
.br
|
||||
pihole status
|
||||
.br
|
||||
pihole restartdns\fR
|
||||
.br
|
||||
\fBpihole\fR (\fBenable\fR|\fBdisable\fR [time])
|
||||
.br
|
||||
\fBpihole\fR \fBcheckout\fR repo [branch]
|
||||
.br
|
||||
\fBpihole\fR \fBhelp\fR
|
||||
.br
|
||||
.SH "DESCRIPTION"
|
||||
|
||||
Available commands and options:
|
||||
.br
|
||||
|
||||
\fB-w, whitelist\fR [options] [<domain1> <domain2 ...>]
|
||||
.br
|
||||
Adds or removes specified domain or domains tho the Whitelist
|
||||
.br
|
||||
|
||||
\fB-b, blacklist\fR [options] [<domain1> <domain2 ...>]
|
||||
.br
|
||||
Adds or removes specified domain or domains to the blacklist
|
||||
.br
|
||||
|
||||
\fB--wild, wildcard\fR [options] [<domain1> <domain2 ...>]
|
||||
.br
|
||||
Add or removes specified domain to the wildcard blacklist
|
||||
.br
|
||||
|
||||
\fB--regex, regex\fR [options] [<regex1> <regex2 ...>]
|
||||
.br
|
||||
Add or removes specified regex filter to the regex blacklist
|
||||
.br
|
||||
|
||||
(Whitelist/Blacklist manipulation options):
|
||||
.br
|
||||
-d, --delmode Remove domain(s) from the list
|
||||
.br
|
||||
-nr, --noreload Update list without refreshing dnsmasq
|
||||
.br
|
||||
-q, --quiet Make output less verbose
|
||||
.br
|
||||
-l, --list Display all your listed domains
|
||||
.br
|
||||
--nuke Removes all entries in a list
|
||||
.br
|
||||
|
||||
\fB-d, debug\fR [-a]
|
||||
.br
|
||||
Start a debugging session
|
||||
.br
|
||||
|
||||
-a Enable automated debugging
|
||||
.br
|
||||
|
||||
\fB-f, flush\fR
|
||||
.br
|
||||
Flush the Pi-hole log
|
||||
.br
|
||||
|
||||
\fB-r, reconfigure\fR
|
||||
.br
|
||||
Reconfigure or Repair Pi-hole subsystems
|
||||
.br
|
||||
|
||||
\fB-t, tail\fR
|
||||
.br
|
||||
View the live output of the Pi-hole log
|
||||
.br
|
||||
|
||||
\fB-a, admin\fR [options]
|
||||
.br
|
||||
|
||||
(Admin options):
|
||||
.br
|
||||
-p, password Set Web Interface password
|
||||
.br
|
||||
-c, celsius Set Celsius as preferred temperature unit
|
||||
.br
|
||||
-f, fahrenheit Set Fahrenheit as preferred temperature unit
|
||||
.br
|
||||
-k, kelvin Set Kelvin as preferred temperature unit
|
||||
.br
|
||||
-r, hostrecord Add a name to the DNS associated to an
|
||||
IPv4/IPv6 address
|
||||
.br
|
||||
-e, email Set an administrative contact address for the
|
||||
Block Page
|
||||
.br
|
||||
-i, interface Specify dnsmasq's interface listening behavior
|
||||
.br
|
||||
-l, privacylevel <level> Set privacy level
|
||||
(0 = lowest, 3 = highest)
|
||||
.br
|
||||
|
||||
\fB-c, chronometer\fR [options]
|
||||
.br
|
||||
Calculates stats and displays to an LCD
|
||||
.br
|
||||
|
||||
(Chronometer Options):
|
||||
.br
|
||||
-j, --json Output stats as JSON formatted string
|
||||
.br
|
||||
-r, --refresh Set update frequency (in seconds)
|
||||
.br
|
||||
-e, --exit Output stats and exit witout refreshing
|
||||
.br
|
||||
|
||||
\fB-g, updateGravity\fR
|
||||
.br
|
||||
Update the list of ad-serving domains
|
||||
.br
|
||||
|
||||
\fB-q, query\fR [option]
|
||||
.br
|
||||
Query the adlists for a specified domain
|
||||
.br
|
||||
|
||||
(Query options):
|
||||
.br
|
||||
-adlist Print the name of the block list URL
|
||||
.br
|
||||
-exact Search the block lists for exact domain matches
|
||||
.br
|
||||
-all Return all query matches within a block list
|
||||
.br
|
||||
|
||||
\fB-h, --help, help\fR
|
||||
.br
|
||||
Show a help dialog
|
||||
.br
|
||||
|
||||
\fB-l, logging\fR [on|off|off noflush]
|
||||
.br
|
||||
Specify whether the Pi-hole log should be used
|
||||
.br
|
||||
|
||||
(Logging options):
|
||||
.br
|
||||
on Enable the Pi-hole log at /var/log/pihole.log
|
||||
.br
|
||||
off Disable and flush the Pi-hole log at
|
||||
/var/log/pihole.log
|
||||
.br
|
||||
off noflush Disable the Pi-hole log at /var/log/pihole.log
|
||||
.br
|
||||
|
||||
\fB-up, updatePihole\fR [--check-only]
|
||||
.br
|
||||
Update Pi-hole subsystems
|
||||
.br
|
||||
|
||||
--check-only Exit script before update is performed.
|
||||
.br
|
||||
|
||||
\fB-v, version\fR [repo] [options]
|
||||
.br
|
||||
Show installed versions of Pi-hole, Web Interface & FTL
|
||||
.br
|
||||
|
||||
.br
|
||||
(repo options):
|
||||
.br
|
||||
-p, --pihole Only retrieve info regarding Pi-hole repository
|
||||
.br
|
||||
-a, --admin Only retrieve info regarding AdminLTE
|
||||
repository
|
||||
.br
|
||||
-f, --ftl Only retrieve info regarding FTL repository
|
||||
.br
|
||||
(version options):
|
||||
.br
|
||||
-c, --current Return the current version
|
||||
.br
|
||||
-l, --latest Return the latest version
|
||||
.br
|
||||
--hash Return the Github hash from your local
|
||||
repositories
|
||||
.br
|
||||
|
||||
\fBuninstall\fR
|
||||
.br
|
||||
Uninstall Pi-hole from your system
|
||||
.br
|
||||
|
||||
\fBstatus\fR
|
||||
.br
|
||||
Display the running status of Pi-hole subsystems
|
||||
.br
|
||||
|
||||
\fBenable\fR
|
||||
.br
|
||||
Enable Pi-hole subsystems
|
||||
.br
|
||||
|
||||
\fBdisable\fR [time]
|
||||
.br
|
||||
Disable Pi-hole subsystems, optionally for a set duration
|
||||
.br
|
||||
|
||||
(time options):
|
||||
.br
|
||||
#s Disable Pi-hole functionality for # second(s)
|
||||
.br
|
||||
#m Disable Pi-hole functionality for # minute(s)
|
||||
.br
|
||||
|
||||
\fBrestartdns\fR
|
||||
.br
|
||||
Restart Pi-hole subsystems
|
||||
.br
|
||||
|
||||
\fBcheckout\fR [repo] [branch]
|
||||
.br
|
||||
Switch Pi-hole subsystems to a different Github branch
|
||||
.br
|
||||
|
||||
(repo options):
|
||||
.br
|
||||
core Change the branch of Pi-hole's core subsystem
|
||||
.br
|
||||
web Change the branch of Admin Console subsystem
|
||||
.br
|
||||
ftl Change the branch of Pi-hole's FTL subsystem
|
||||
.br
|
||||
(branch options):
|
||||
.br
|
||||
master Update subsystems to the latest stable release
|
||||
.br
|
||||
dev Update subsystems to the latest development
|
||||
release
|
||||
.br
|
||||
branchname Update subsystems to the specified branchname
|
||||
.br
|
||||
.SH "EXAMPLE"
|
||||
|
||||
Some usage examples
|
||||
.br
|
||||
|
||||
Whitelist/blacklist manipulation
|
||||
.br
|
||||
|
||||
\fBpihole -w iloveads.example.com\fR
|
||||
.br
|
||||
Adds "iloveads.example.com" to whitelist
|
||||
.br
|
||||
|
||||
\fBpihole -b -d noads.example.com\fR
|
||||
.br
|
||||
Removes "noads.example.com" from blacklist
|
||||
.br
|
||||
|
||||
\fBpihole --wild example.com\fR
|
||||
.br
|
||||
Adds example.com as a wildcard - would block all subdomains of
|
||||
example.com, including example.com itself.
|
||||
.br
|
||||
|
||||
\fBpihole --regex "ad.*\\.example\\.com$"\fR
|
||||
.br
|
||||
Adds "ad.*\\.example\\.com$" to the regex blacklist.
|
||||
Would block all subdomains of example.com which start with "ad"
|
||||
.br
|
||||
|
||||
Changing the Web Interface password
|
||||
.br
|
||||
|
||||
\fBpihole -a -p ExamplePassword\fR
|
||||
.br
|
||||
Change the password to "ExamplePassword"
|
||||
.br
|
||||
|
||||
Updating lists from internet sources
|
||||
.br
|
||||
|
||||
\fBpihole -g\fR
|
||||
.br
|
||||
Update the list of ad-serving domains
|
||||
.br
|
||||
|
||||
Displaying version information
|
||||
.br
|
||||
|
||||
\fBpihole -v -a -c\fR
|
||||
.br
|
||||
Display the current version of AdminLTE
|
||||
.br
|
||||
|
||||
Temporarily disabling Pi-hole
|
||||
.br
|
||||
|
||||
\fBpihole disable 5m\fR
|
||||
.br
|
||||
Disable Pi-hole functionality for five minutes
|
||||
.br
|
||||
|
||||
Switching Pi-hole subsystem branches
|
||||
.br
|
||||
|
||||
\fBpihole checkout master\fR
|
||||
.br
|
||||
Switch to master branch
|
||||
.br
|
||||
|
||||
\fBpihole checkout core dev\fR
|
||||
.br
|
||||
Switch to core development branch
|
||||
.br
|
||||
.SH "SEE ALSO"
|
||||
|
||||
\fBlighttpd\fR(8), \fBpihole-FTL\fR(8)
|
||||
.br
|
||||
.SH "COLOPHON"
|
||||
|
||||
Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net.
|
||||
.br
|
@ -0,0 +1,6 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
setup_requires=['pytest-runner'],
|
||||
tests_require=['pytest'],
|
||||
)
|
@ -0,0 +1,25 @@
|
||||
# Recommended way to run tests
|
||||
|
||||
Make sure you have Docker and Python w/pip package manager.
|
||||
|
||||
From command line all you need to do is:
|
||||
|
||||
- `pip install tox`
|
||||
- `tox`
|
||||
|
||||
Tox handles setting up a virtual environment for python dependancies, installing dependancies, building the docker images used by tests, and finally running tests. It's an easy way to have travis-ci like build behavior locally.
|
||||
|
||||
## Alternative py.test method of running tests
|
||||
|
||||
You're responsible for setting up your virtual env and dependancies in this situation.
|
||||
|
||||
```
|
||||
py.test -vv -n auto -m "build_stage"
|
||||
py.test -vv -n auto -m "not build_stage"
|
||||
```
|
||||
|
||||
The build_stage tests have to run first to create the docker images, followed by the actual tests which utilize said images. Unless you're changing your dockerfiles you shouldn't have to run the build_stage every time - but it's a good idea to rebuild at least once a day in case the base Docker images or packages change.
|
||||
|
||||
# How do I debug python?
|
||||
|
||||
Highly recommended: Setup PyCharm on a **Docker enabled** machine. Having a python debugger like PyCharm changes your life if you've never used it :)
|
@ -0,0 +1,16 @@
|
||||
FROM fedora:latest
|
||||
|
||||
ENV GITDIR /etc/.pihole
|
||||
ENV SCRIPTDIR /opt/pihole
|
||||
|
||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||
ADD . $GITDIR
|
||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
||||
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||
|
||||
RUN true && \
|
||||
chmod +x $SCRIPTDIR/*
|
||||
|
||||
ENV PH_TEST true
|
||||
|
||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
@ -0,0 +1,209 @@
|
||||
import pytest
|
||||
from conftest import (
|
||||
tick_box,
|
||||
info_box,
|
||||
cross_box,
|
||||
mock_command,
|
||||
mock_command_2,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('fedora'), ])
|
||||
def test_epel_and_remi_not_installed_fedora(Pihole):
|
||||
'''
|
||||
confirms installer does not attempt to install EPEL/REMI repositories
|
||||
on Fedora
|
||||
'''
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
assert distro_check.stdout == ''
|
||||
|
||||
epel_package = Pihole.package('epel-release')
|
||||
assert not epel_package.is_installed
|
||||
remi_package = Pihole.package('remi-release')
|
||||
assert not remi_package.is_installed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_release_supported_version_check_centos(Pihole):
|
||||
'''
|
||||
confirms installer exits on unsupported releases of CentOS
|
||||
'''
|
||||
# mock CentOS release < 7 (unsupported)
|
||||
mock_command_2(
|
||||
'rpm',
|
||||
{"-q --queryformat '%{VERSION}' centos-release'": (
|
||||
'5',
|
||||
'0'
|
||||
)},
|
||||
Pihole
|
||||
)
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
expected_stdout = cross_box + (' CentOS is not suported.')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
expected_stdout = 'Please update to CentOS release 7 or later'
|
||||
assert expected_stdout in distro_check.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_enable_epel_repository_centos(Pihole):
|
||||
'''
|
||||
confirms the EPEL package repository is enabled when installed on CentOS
|
||||
'''
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
expected_stdout = info_box + (' Enabling EPEL package repository '
|
||||
'(https://fedoraproject.org/wiki/EPEL)')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
expected_stdout = tick_box + ' Installed epel-release'
|
||||
assert expected_stdout in distro_check.stdout
|
||||
epel_package = Pihole.package('epel-release')
|
||||
assert epel_package.is_installed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_php_upgrade_default_optout_centos(Pihole):
|
||||
'''
|
||||
confirms the default behavior to opt-out of installing PHP7 from REMI
|
||||
'''
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
||||
'Deprecated PHP may be in use.')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
remi_package = Pihole.package('remi-release')
|
||||
assert not remi_package.is_installed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_php_upgrade_user_optout_centos(Pihole):
|
||||
'''
|
||||
confirms installer behavior when user opt-out of installing PHP7 from REMI
|
||||
(php not currently installed)
|
||||
'''
|
||||
# Whiptail dialog returns Cancel for user prompt
|
||||
mock_command('whiptail', {'*': ('', '1')}, Pihole)
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
||||
'Deprecated PHP may be in use.')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
remi_package = Pihole.package('remi-release')
|
||||
assert not remi_package.is_installed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_php_upgrade_user_optin_centos(Pihole):
|
||||
'''
|
||||
confirms installer behavior when user opt-in to installing PHP7 from REMI
|
||||
(php not currently installed)
|
||||
'''
|
||||
# Whiptail dialog returns Continue for user prompt
|
||||
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
assert 'opt-out' not in distro_check.stdout
|
||||
expected_stdout = info_box + (' Enabling Remi\'s RPM repository '
|
||||
'(https://rpms.remirepo.net)')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
expected_stdout = tick_box + (' Remi\'s RPM repository has '
|
||||
'been enabled for PHP7')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
remi_package = Pihole.package('remi-release')
|
||||
assert remi_package.is_installed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_php_version_lt_7_detected_upgrade_default_optout_centos(Pihole):
|
||||
'''
|
||||
confirms the default behavior to opt-out of upgrading to PHP7 from REMI
|
||||
'''
|
||||
# first we will install the default php version to test installer behavior
|
||||
php_install = Pihole.run('yum install -y php')
|
||||
assert php_install.rc == 0
|
||||
php_package = Pihole.package('php')
|
||||
default_centos_php_version = php_package.version.split('.')[0]
|
||||
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
||||
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
||||
'Deprecated PHP may be in use.')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
remi_package = Pihole.package('remi-release')
|
||||
assert not remi_package.is_installed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_php_version_lt_7_detected_upgrade_user_optout_centos(Pihole):
|
||||
'''
|
||||
confirms installer behavior when user opt-out to upgrade to PHP7 via REMI
|
||||
'''
|
||||
# first we will install the default php version to test installer behavior
|
||||
php_install = Pihole.run('yum install -y php')
|
||||
assert php_install.rc == 0
|
||||
php_package = Pihole.package('php')
|
||||
default_centos_php_version = php_package.version.split('.')[0]
|
||||
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
||||
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
||||
# Whiptail dialog returns Cancel for user prompt
|
||||
mock_command('whiptail', {'*': ('', '1')}, Pihole)
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
''')
|
||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
||||
'Deprecated PHP may be in use.')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
remi_package = Pihole.package('remi-release')
|
||||
assert not remi_package.is_installed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tag", [('centos'), ])
|
||||
def test_php_version_lt_7_detected_upgrade_user_optin_centos(Pihole):
|
||||
'''
|
||||
confirms installer behavior when user opt-in to upgrade to PHP7 via REMI
|
||||
'''
|
||||
# first we will install the default php version to test installer behavior
|
||||
php_install = Pihole.run('yum install -y php')
|
||||
assert php_install.rc == 0
|
||||
php_package = Pihole.package('php')
|
||||
default_centos_php_version = php_package.version.split('.')[0]
|
||||
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
||||
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
||||
# Whiptail dialog returns Continue for user prompt
|
||||
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
||||
distro_check = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
install_dependent_packages PIHOLE_WEB_DEPS[@]
|
||||
''')
|
||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
||||
'Deprecated PHP may be in use.')
|
||||
assert expected_stdout not in distro_check.stdout
|
||||
expected_stdout = info_box + (' Enabling Remi\'s RPM repository '
|
||||
'(https://rpms.remirepo.net)')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
expected_stdout = tick_box + (' Remi\'s RPM repository has '
|
||||
'been enabled for PHP7')
|
||||
assert expected_stdout in distro_check.stdout
|
||||
remi_package = Pihole.package('remi-release')
|
||||
assert remi_package.is_installed
|
||||
updated_php_package = Pihole.package('php')
|
||||
updated_php_version = updated_php_package.version.split('.')[0]
|
||||
assert int(updated_php_version) == 7
|
@ -1,13 +1,18 @@
|
||||
import pytest
|
||||
import testinfra
|
||||
|
||||
run_local = testinfra.get_backend(
|
||||
"local://"
|
||||
).get_module("Command").run
|
||||
|
||||
|
||||
def test_scripts_pass_shellcheck():
|
||||
''' Make sure shellcheck does not find anything wrong with our shell scripts '''
|
||||
shellcheck = "find . -type f -name 'update.sh' | while read file; do shellcheck -x \"$file\" -e SC1090,SC1091; done;"
|
||||
'''
|
||||
Make sure shellcheck does not find anything wrong with our shell scripts
|
||||
'''
|
||||
shellcheck = ("find . -type f -name 'update.sh' "
|
||||
"| while read file; do "
|
||||
"shellcheck -x \"$file\" -e SC1090,SC1091; "
|
||||
"done;")
|
||||
results = run_local(shellcheck)
|
||||
print results.stdout
|
||||
assert '' == results.stdout
|
||||
|
@ -0,0 +1,10 @@
|
||||
[tox]
|
||||
envlist = py27
|
||||
|
||||
[testenv]
|
||||
whitelist_externals = docker
|
||||
deps = -rrequirements.txt
|
||||
commands = docker build -f test/debian.Dockerfile -t pytest_pihole:debian .
|
||||
docker build -f test/centos.Dockerfile -t pytest_pihole:centos .
|
||||
docker build -f test/fedora.Dockerfile -t pytest_pihole:fedora .
|
||||
pytest {posargs:-vv -n auto} -m "not build_stage" ./test/
|
Loading…
Reference in new issue