Compare commits
2 Commits
v6.2.2
...
fix/declar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3183dc95f | ||
|
|
18d4aef37c |
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
@@ -8,10 +8,6 @@ updates:
|
|||||||
time: "10:00"
|
time: "10:00"
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
target-branch: development
|
target-branch: development
|
||||||
groups:
|
|
||||||
github-actions-dependencies:
|
|
||||||
patterns:
|
|
||||||
- "*"
|
|
||||||
- package-ecosystem: pip
|
- package-ecosystem: pip
|
||||||
directory: "/test"
|
directory: "/test"
|
||||||
schedule:
|
schedule:
|
||||||
@@ -20,7 +16,3 @@ updates:
|
|||||||
time: "10:00"
|
time: "10:00"
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
target-branch: development
|
target-branch: development
|
||||||
groups:
|
|
||||||
python-dependencies:
|
|
||||||
patterns:
|
|
||||||
- "*"
|
|
||||||
|
|||||||
1
.github/release.yml
vendored
1
.github/release.yml
vendored
@@ -2,7 +2,6 @@ changelog:
|
|||||||
exclude:
|
exclude:
|
||||||
labels:
|
labels:
|
||||||
- internal
|
- internal
|
||||||
- dependencies
|
|
||||||
authors:
|
authors:
|
||||||
- dependabot
|
- dependabot
|
||||||
- github-actions
|
- github-actions
|
||||||
|
|||||||
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -25,16 +25,16 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout repository
|
name: Checkout repository
|
||||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
-
|
-
|
||||||
name: Initialize CodeQL
|
name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
|
uses: github/codeql-action/init@v3
|
||||||
with:
|
with:
|
||||||
languages: 'python'
|
languages: 'python'
|
||||||
-
|
-
|
||||||
name: Autobuild
|
name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
|
uses: github/codeql-action/autobuild@v3
|
||||||
-
|
-
|
||||||
name: Perform CodeQL Analysis
|
name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
|
uses: github/codeql-action/analyze@v3
|
||||||
|
|||||||
2
.github/workflows/merge-conflict.yml
vendored
2
.github/workflows/merge-conflict.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check if PRs are have merge conflicts
|
- name: Check if PRs are have merge conflicts
|
||||||
uses: eps1lon/actions-label-merge-conflict@1df065ebe6e3310545d4f4c4e862e43bdca146f0 #v3.0.3
|
uses: eps1lon/actions-label-merge-conflict@v3.0.3
|
||||||
with:
|
with:
|
||||||
dirtyLabel: "PR: Merge Conflict"
|
dirtyLabel: "PR: Merge Conflict"
|
||||||
repoToken: "${{ secrets.GITHUB_TOKEN }}"
|
repoToken: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|||||||
6
.github/workflows/stale.yml
vendored
6
.github/workflows/stale.yml
vendored
@@ -17,14 +17,14 @@ jobs:
|
|||||||
issues: write
|
issues: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 #v10.1.0
|
- uses: actions/stale@v9.1.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
days-before-stale: 30
|
days-before-stale: 30
|
||||||
days-before-close: 5
|
days-before-close: 5
|
||||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.'
|
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.'
|
||||||
stale-issue-label: '${{ env.stale_label }}'
|
stale-issue-label: '${{ env.stale_label }}'
|
||||||
exempt-issue-labels: 'Internal, Fixed in next release, Bug: Confirmed, Documentation Needed, never-stale'
|
exempt-issue-labels: 'Internal, Fixed in next release, Bug: Confirmed, Documentation Needed'
|
||||||
exempt-all-issue-assignees: true
|
exempt-all-issue-assignees: true
|
||||||
operations-per-run: 300
|
operations-per-run: 300
|
||||||
close-issue-reason: 'not_planned'
|
close-issue-reason: 'not_planned'
|
||||||
@@ -40,7 +40,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
- name: Remove 'stale' label
|
- name: Remove 'stale' label
|
||||||
run: gh issue edit ${{ github.event.issue.number }} --remove-label ${{ env.stale_label }}
|
run: gh issue edit ${{ github.event.issue.number }} --remove-label ${{ env.stale_label }}
|
||||||
env:
|
env:
|
||||||
|
|||||||
2
.github/workflows/stale_pr.yml
vendored
2
.github/workflows/stale_pr.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 #v10.1.0
|
- uses: actions/stale@v9.1.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# Do not automatically mark PR/issue as stale
|
# Do not automatically mark PR/issue as stale
|
||||||
|
|||||||
2
.github/workflows/sync-back-to-dev.yml
vendored
2
.github/workflows/sync-back-to-dev.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
|||||||
name: Syncing branches
|
name: Syncing branches
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
- name: Opening pull request
|
- name: Opening pull request
|
||||||
run: gh pr create -B development -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal'
|
run: gh pr create -B development -H master --title 'Sync master back into development' --body 'Created by Github action' --label 'internal'
|
||||||
env:
|
env:
|
||||||
|
|||||||
21
.github/workflows/test.yml
vendored
21
.github/workflows/test.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Differential ShellCheck requires full git history
|
fetch-depth: 0 # Differential ShellCheck requires full git history
|
||||||
|
|
||||||
@@ -31,25 +31,25 @@ jobs:
|
|||||||
[[ $FAIL == 1 ]] && exit 1 || echo "Scripts are executable!"
|
[[ $FAIL == 1 ]] && exit 1 || echo "Scripts are executable!"
|
||||||
|
|
||||||
- name: Differential ShellCheck
|
- name: Differential ShellCheck
|
||||||
uses: redhat-plumbers-in-action/differential-shellcheck@0d9e5b29625f871e6a4215380486d6f1a7cb6cdd #v5.5.5
|
uses: redhat-plumbers-in-action/differential-shellcheck@v5
|
||||||
with:
|
with:
|
||||||
severity: warning
|
severity: warning
|
||||||
display-engine: sarif-fmt
|
display-engine: sarif-fmt
|
||||||
|
|
||||||
|
|
||||||
- name: Spell-Checking
|
- name: Spell-Checking
|
||||||
uses: codespell-project/actions-codespell@406322ec52dd7b488e48c1c4b82e2a8b3a1bf630 #v2.1
|
uses: codespell-project/actions-codespell@master
|
||||||
with:
|
with:
|
||||||
ignore_words_file: .codespellignore
|
ignore_words_file: .codespellignore
|
||||||
|
|
||||||
- name: Get editorconfig-checker
|
- name: Get editorconfig-checker
|
||||||
uses: editorconfig-checker/action-editorconfig-checker@4b6cd6190d435e7e084fb35e36a096e98506f7b9 #v2.1.0
|
uses: editorconfig-checker/action-editorconfig-checker@main # tag v1.0.0 is really out of date
|
||||||
|
|
||||||
- name: Run editorconfig-checker
|
- name: Run editorconfig-checker
|
||||||
run: editorconfig-checker
|
run: editorconfig-checker
|
||||||
|
|
||||||
- name: Check python code formatting with black
|
- name: Check python code formatting with black
|
||||||
uses: psf/black@af0ba72a73598c76189d6dd1b21d8532255d5942 #25.9.0
|
uses: psf/black@stable
|
||||||
with:
|
with:
|
||||||
src: "./test"
|
src: "./test"
|
||||||
options: "--check --diff --color"
|
options: "--check --diff --color"
|
||||||
@@ -65,7 +65,6 @@ jobs:
|
|||||||
[
|
[
|
||||||
debian_11,
|
debian_11,
|
||||||
debian_12,
|
debian_12,
|
||||||
debian_13,
|
|
||||||
ubuntu_20,
|
ubuntu_20,
|
||||||
ubuntu_22,
|
ubuntu_22,
|
||||||
ubuntu_24,
|
ubuntu_24,
|
||||||
@@ -74,19 +73,17 @@ jobs:
|
|||||||
fedora_40,
|
fedora_40,
|
||||||
fedora_41,
|
fedora_41,
|
||||||
fedora_42,
|
fedora_42,
|
||||||
alpine_3_21,
|
|
||||||
alpine_3_22,
|
|
||||||
]
|
]
|
||||||
env:
|
env:
|
||||||
DISTRO: ${{matrix.distro}}
|
DISTRO: ${{matrix.distro}}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c #v6.0.0
|
uses: actions/setup-python@v5.6.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.13"
|
python-version: "3.10"
|
||||||
|
|
||||||
- name: Install wheel
|
- name: Install wheel
|
||||||
run: pip install wheel
|
run: pip install wheel
|
||||||
|
|||||||
@@ -1,6 +1,2 @@
|
|||||||
external-sources=true # allow shellcheck to read external sources
|
external-sources=true # allow shellcheck to read external sources
|
||||||
disable=SC3043 #disable SC3043: In POSIX sh, local is undefined.
|
disable=SC3043 #disable SC3043: In POSIX sh, local is undefined.
|
||||||
enable=useless-use-of-cat # disabled by default as of shellcheck 0.11.0
|
|
||||||
enable=avoid-negated-conditions # avoid-negated-conditions is optional as of shellcheck 0.11.0
|
|
||||||
enable=require-variable-braces
|
|
||||||
enable=deprecate-which
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# shellcheck disable=SC2034 # Disable warning about unused variables
|
|
||||||
|
|
||||||
# Determine if terminal is capable of showing colors
|
# Determine if terminal is capable of showing colors
|
||||||
# When COL_TABLE is sourced via gravity invoked by FTL, FORCE_COLOR is set to true
|
if [ -t 1 ] && [ "$(tput colors)" -ge 8 ]; then
|
||||||
if { [ -t 1 ] && [ "$(tput colors)" -ge 8 ]; } || [ "${FORCE_COLOR}" ]; then
|
|
||||||
# Bold and underline may not show up on all clients
|
# Bold and underline may not show up on all clients
|
||||||
# If something MUST be emphasized, use both
|
# If something MUST be emphasized, use both
|
||||||
COL_BOLD='[1m'
|
COL_BOLD='[1m'
|
||||||
|
COL_ULINE='[4m'
|
||||||
|
|
||||||
COL_NC='[0m'
|
COL_NC='[0m'
|
||||||
COL_GRAY='[90m'
|
COL_GRAY='[90m'
|
||||||
COL_RED='[91m'
|
COL_RED='[91m'
|
||||||
@@ -18,6 +17,8 @@ if { [ -t 1 ] && [ "$(tput colors)" -ge 8 ]; } || [ "${FORCE_COLOR}" ]; then
|
|||||||
else
|
else
|
||||||
# Provide empty variables for `set -u`
|
# Provide empty variables for `set -u`
|
||||||
COL_BOLD=""
|
COL_BOLD=""
|
||||||
|
COL_ULINE=""
|
||||||
|
|
||||||
COL_NC=""
|
COL_NC=""
|
||||||
COL_GRAY=""
|
COL_GRAY=""
|
||||||
COL_RED=""
|
COL_RED=""
|
||||||
@@ -28,8 +29,22 @@ else
|
|||||||
COL_CYAN=""
|
COL_CYAN=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Deprecated variables
|
||||||
|
COL_WHITE="${COL_BOLD}"
|
||||||
|
COL_BLACK="${COL_NC}"
|
||||||
|
COL_LIGHT_BLUE="${COL_BLUE}"
|
||||||
|
COL_LIGHT_GREEN="${COL_GREEN}"
|
||||||
|
COL_LIGHT_CYAN="${COL_CYAN}"
|
||||||
|
COL_LIGHT_RED="${COL_RED}"
|
||||||
|
COL_URG_RED="${COL_RED}${COL_BOLD}${COL_ULINE}"
|
||||||
|
COL_LIGHT_PURPLE="${COL_PURPLE}"
|
||||||
|
COL_BROWN="${COL_YELLOW}"
|
||||||
|
COL_LIGHT_GRAY="${COL_GRAY}"
|
||||||
|
COL_DARK_GRAY="${COL_GRAY}"
|
||||||
|
|
||||||
TICK="[${COL_GREEN}✓${COL_NC}]"
|
TICK="[${COL_GREEN}✓${COL_NC}]"
|
||||||
CROSS="[${COL_RED}✗${COL_NC}]"
|
CROSS="[${COL_RED}✗${COL_NC}]"
|
||||||
INFO="[i]"
|
INFO="[i]"
|
||||||
QST="[?]"
|
QST="[?]"
|
||||||
|
DONE="${COL_GREEN} done!${COL_NC}"
|
||||||
OVER="\\r[K"
|
OVER="\\r[K"
|
||||||
|
|||||||
@@ -22,10 +22,8 @@ TestAPIAvailability() {
|
|||||||
local chaos_api_list authResponse authStatus authData apiAvailable DNSport
|
local chaos_api_list authResponse authStatus authData apiAvailable DNSport
|
||||||
|
|
||||||
# as we are running locally, we can get the port value from FTL directly
|
# as we are running locally, we can get the port value from FTL directly
|
||||||
PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
|
||||||
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
|
||||||
# shellcheck source=./advanced/Scripts/utils.sh
|
# shellcheck source=./advanced/Scripts/utils.sh
|
||||||
. "${utilsfile}"
|
. "/opt/pihole/utils.sh"
|
||||||
|
|
||||||
DNSport=$(getFTLConfigValue dns.port)
|
DNSport=$(getFTLConfigValue dns.port)
|
||||||
|
|
||||||
@@ -150,6 +148,7 @@ LoginAPI() {
|
|||||||
|
|
||||||
# Try to login again until the session is valid
|
# Try to login again until the session is valid
|
||||||
while [ ! "${validSession}" = true ] ; do
|
while [ ! "${validSession}" = true ] ; do
|
||||||
|
echo "Authentication failed. Please enter your Pi-hole password"
|
||||||
|
|
||||||
# Print the error message if there is one
|
# Print the error message if there is one
|
||||||
if [ ! "${sessionError}" = "null" ] && [ "${1}" = "verbose" ]; then
|
if [ ! "${sessionError}" = "null" ] && [ "${1}" = "verbose" ]; then
|
||||||
@@ -160,14 +159,6 @@ LoginAPI() {
|
|||||||
echo "Error: ${sessionMessage}"
|
echo "Error: ${sessionMessage}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1}" = "verbose" ]; then
|
|
||||||
# If we are not in verbose mode, no need to print the error message again
|
|
||||||
echo "Please enter your Pi-hole password"
|
|
||||||
else
|
|
||||||
|
|
||||||
echo "Authentication failed. Please enter your Pi-hole password"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# secretly read the password
|
# secretly read the password
|
||||||
secretRead; printf '\n'
|
secretRead; printf '\n'
|
||||||
|
|
||||||
@@ -190,20 +181,13 @@ Authentication() {
|
|||||||
echo "No response from FTL server. Please check connectivity"
|
echo "No response from FTL server. Please check connectivity"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
# obtain validity, session ID and sessionMessage from session response
|
||||||
|
validSession=$(echo "${sessionResponse}"| jq .session.valid 2>/dev/null)
|
||||||
|
SID=$(echo "${sessionResponse}"| jq --raw-output .session.sid 2>/dev/null)
|
||||||
|
sessionMessage=$(echo "${sessionResponse}"| jq --raw-output .session.message 2>/dev/null)
|
||||||
|
|
||||||
# obtain validity, session ID, sessionMessage and error message from
|
# obtain the error message from the session response
|
||||||
# session response, apply default values if none returned
|
sessionError=$(echo "${sessionResponse}"| jq --raw-output .error.message 2>/dev/null)
|
||||||
result=$(echo "${sessionResponse}" | jq -r '
|
|
||||||
(.session.valid // false),
|
|
||||||
(.session.sid // null),
|
|
||||||
(.session.message // null),
|
|
||||||
(.error.message // null)
|
|
||||||
' 2>/dev/null)
|
|
||||||
|
|
||||||
validSession=$(echo "${result}" | sed -n '1p')
|
|
||||||
SID=$(echo "${result}" | sed -n '2p')
|
|
||||||
sessionMessage=$(echo "${result}" | sed -n '3p')
|
|
||||||
sessionError=$(echo "${result}" | sed -n '4p')
|
|
||||||
|
|
||||||
if [ "${1}" = "verbose" ]; then
|
if [ "${1}" = "verbose" ]; then
|
||||||
if [ "${validSession}" = true ]; then
|
if [ "${validSession}" = true ]; then
|
||||||
@@ -367,9 +351,12 @@ apiFunc() {
|
|||||||
if [ "${verbosity}" = "verbose" ]; then
|
if [ "${verbosity}" = "verbose" ]; then
|
||||||
echo "Data:"
|
echo "Data:"
|
||||||
fi
|
fi
|
||||||
# Attempt to print the data with jq, if it is not valid JSON, or not installed
|
|
||||||
# then print the plain text.
|
if command -v jq >/dev/null && echo "${data}" | jq . >/dev/null 2>&1; then
|
||||||
echo "${data}" | jq . 2>/dev/null || echo "${data}"
|
echo "${data}" | jq .
|
||||||
|
else
|
||||||
|
echo "${data}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Delete the session
|
# Delete the session
|
||||||
LogoutAPI "${verbosity}"
|
LogoutAPI "${verbosity}"
|
||||||
|
|||||||
@@ -150,10 +150,4 @@ upgrade_gravityDB(){
|
|||||||
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/18_to_19.sql"
|
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/18_to_19.sql"
|
||||||
version=19
|
version=19
|
||||||
fi
|
fi
|
||||||
if [[ "$version" == "19" ]]; then
|
|
||||||
# Update views to use new allowlist/denylist names
|
|
||||||
echo -e " ${INFO} Upgrading gravity database from version 19 to 20"
|
|
||||||
pihole-FTL sqlite3 -ni "${database}" < "${scriptPath}/19_to_20.sql"
|
|
||||||
version=20
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
.timeout 30000
|
|
||||||
|
|
||||||
BEGIN TRANSACTION;
|
|
||||||
|
|
||||||
DROP VIEW vw_whitelist;
|
|
||||||
CREATE VIEW vw_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
|
||||||
FROM domainlist
|
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
|
||||||
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
|
||||||
AND domainlist.type = 0
|
|
||||||
ORDER BY domainlist.id;
|
|
||||||
|
|
||||||
DROP VIEW vw_blacklist;
|
|
||||||
CREATE VIEW vw_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
|
||||||
FROM domainlist
|
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
|
||||||
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
|
||||||
AND domainlist.type = 1
|
|
||||||
ORDER BY domainlist.id;
|
|
||||||
|
|
||||||
DROP VIEW vw_regex_whitelist;
|
|
||||||
CREATE VIEW vw_regex_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
|
||||||
FROM domainlist
|
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
|
||||||
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
|
||||||
AND domainlist.type = 2
|
|
||||||
ORDER BY domainlist.id;
|
|
||||||
|
|
||||||
DROP VIEW vw_regex_blacklist;
|
|
||||||
CREATE VIEW vw_regex_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
|
||||||
FROM domainlist
|
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
|
||||||
WHERE domainlist.enabled = 1 AND (domainlist_by_group.group_id IS NULL OR "group".enabled = 1)
|
|
||||||
AND domainlist.type = 3
|
|
||||||
ORDER BY domainlist.id;
|
|
||||||
|
|
||||||
UPDATE info SET value = 20 WHERE property = 'version';
|
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
@@ -9,12 +9,12 @@
|
|||||||
# This file is copyright under the latest version of the EUPL.
|
# This file is copyright under the latest version of the EUPL.
|
||||||
# Please see LICENSE file for your rights under this license.
|
# Please see LICENSE file for your rights under this license.
|
||||||
|
|
||||||
PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||||
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
readonly utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
||||||
# shellcheck source="./advanced/Scripts/utils.sh"
|
# shellcheck source="./advanced/Scripts/utils.sh"
|
||||||
source "${utilsfile}"
|
source "${utilsfile}"
|
||||||
|
|
||||||
apifile="${PI_HOLE_SCRIPT_DIR}/api.sh"
|
readonly apifile="${PI_HOLE_SCRIPT_DIR}/api.sh"
|
||||||
# shellcheck source="./advanced/Scripts/api.sh"
|
# shellcheck source="./advanced/Scripts/api.sh"
|
||||||
source "${apifile}"
|
source "${apifile}"
|
||||||
|
|
||||||
|
|||||||
87
advanced/Scripts/piholeARPTable.sh
Executable file
87
advanced/Scripts/piholeARPTable.sh
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
|
# (c) 2019 Pi-hole, LLC (https://pi-hole.net)
|
||||||
|
# Network-wide ad blocking via your own hardware.
|
||||||
|
#
|
||||||
|
# ARP table interaction
|
||||||
|
#
|
||||||
|
# This file is copyright under the latest version of the EUPL.
|
||||||
|
# Please see LICENSE file for your rights under this license.
|
||||||
|
|
||||||
|
coltable="/opt/pihole/COL_TABLE"
|
||||||
|
if [[ -f ${coltable} ]]; then
|
||||||
|
# shellcheck source="./advanced/Scripts/COL_TABLE"
|
||||||
|
source ${coltable}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shellcheck source=./advanced/Scripts/utils.sh
|
||||||
|
source "/opt/pihole/utils.sh"
|
||||||
|
|
||||||
|
SKIP_INSTALL="true"
|
||||||
|
# shellcheck source="./automated install/basic-install.sh"
|
||||||
|
source "/etc/.pihole/automated install/basic-install.sh"
|
||||||
|
# stop_service() is defined in basic-install.sh
|
||||||
|
# restart_service() is defined in basic-install.sh
|
||||||
|
|
||||||
|
# Determine database location
|
||||||
|
DBFILE=$(getFTLConfigValue "files.database")
|
||||||
|
if [ -z "$DBFILE" ]; then
|
||||||
|
DBFILE="/etc/pihole/pihole-FTL.db"
|
||||||
|
fi
|
||||||
|
|
||||||
|
flushARP(){
|
||||||
|
local output
|
||||||
|
if [[ "${args[1]}" != "quiet" ]]; then
|
||||||
|
echo -ne " ${INFO} Flushing network table ..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Stop FTL to prevent database access
|
||||||
|
if ! output=$(stop_service pihole-FTL 2>&1); then
|
||||||
|
echo -e "${OVER} ${CROSS} Failed to stop FTL"
|
||||||
|
echo " Output: ${output}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Truncate network_addresses table in pihole-FTL.db
|
||||||
|
# This needs to be done before we can truncate the network table due to
|
||||||
|
# foreign key constraints
|
||||||
|
if ! output=$(pihole-FTL sqlite3 -ni "${DBFILE}" "DELETE FROM network_addresses" 2>&1); then
|
||||||
|
echo -e "${OVER} ${CROSS} Failed to truncate network_addresses table"
|
||||||
|
echo " Database location: ${DBFILE}"
|
||||||
|
echo " Output: ${output}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Truncate network table in pihole-FTL.db
|
||||||
|
if ! output=$(pihole-FTL sqlite3 -ni "${DBFILE}" "DELETE FROM network" 2>&1); then
|
||||||
|
echo -e "${OVER} ${CROSS} Failed to truncate network table"
|
||||||
|
echo " Database location: ${DBFILE}"
|
||||||
|
echo " Output: ${output}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Flush ARP cache of the host
|
||||||
|
if ! output=$(ip -s -s neigh flush all 2>&1); then
|
||||||
|
echo -e "${OVER} ${CROSS} Failed to flush ARP cache"
|
||||||
|
echo " Output: ${output}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start FTL again
|
||||||
|
if ! output=$(restart_service pihole-FTL 2>&1); then
|
||||||
|
echo -e "${OVER} ${CROSS} Failed to restart FTL"
|
||||||
|
echo " Output: ${output}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${args[1]}" != "quiet" ]]; then
|
||||||
|
echo -e "${OVER} ${TICK} Flushed network table"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
args=("$@")
|
||||||
|
|
||||||
|
case "${args[0]}" in
|
||||||
|
"arpflush" ) flushARP;;
|
||||||
|
esac
|
||||||
@@ -26,7 +26,7 @@ source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
|||||||
warning1() {
|
warning1() {
|
||||||
echo " Please note that changing branches severely alters your Pi-hole subsystems"
|
echo " Please note that changing branches severely alters your Pi-hole subsystems"
|
||||||
echo " Features that work on the master branch, may not on a development branch"
|
echo " Features that work on the master branch, may not on a development branch"
|
||||||
echo -e " ${COL_RED}This feature is NOT supported unless a Pi-hole developer explicitly asks!${COL_NC}"
|
echo -e " ${COL_LIGHT_RED}This feature is NOT supported unless a Pi-hole developer explicitly asks!${COL_NC}"
|
||||||
read -r -p " Have you read and understood this? [y/N] " response
|
read -r -p " Have you read and understood this? [y/N] " response
|
||||||
case "${response}" in
|
case "${response}" in
|
||||||
[yY][eE][sS]|[yY])
|
[yY][eE][sS]|[yY])
|
||||||
@@ -55,19 +55,19 @@ checkout() {
|
|||||||
|
|
||||||
# This is unlikely
|
# This is unlikely
|
||||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||||
echo -e " ${COL_RED}Error: Core Pi-hole repo is missing from system!"
|
echo -e " ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!"
|
||||||
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! is_repo "${webInterfaceDir}" ; then
|
if ! is_repo "${webInterfaceDir}" ; then
|
||||||
echo -e " ${COL_RED}Error: Web Admin repo is missing from system!"
|
echo -e " ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!"
|
||||||
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${1}" ]]; then
|
if [[ -z "${1}" ]]; then
|
||||||
echo -e " ${COL_RED}Invalid option${COL_NC}"
|
echo -e " ${COL_LIGHT_RED}Invalid option${COL_NC}"
|
||||||
echo -e " Try 'pihole checkout --help' for more information."
|
echo -e " Try 'pihole checkout --help' for more information."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -238,7 +238,7 @@ checkout() {
|
|||||||
if "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" --unattended; then
|
if "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" --unattended; then
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo -e " ${COL_RED} Error: Unable to complete update, please contact support${COL_NC}"
|
echo -e " ${COL_LIGHT_RED} Error: Unable to complete update, please contact support${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ check_firewalld() {
|
|||||||
# test common required service ports
|
# test common required service ports
|
||||||
local firewalld_enabled_services
|
local firewalld_enabled_services
|
||||||
firewalld_enabled_services=$(firewall-cmd --list-services)
|
firewalld_enabled_services=$(firewall-cmd --list-services)
|
||||||
local firewalld_expected_services=("http" "https" "dns" "dhcp" "dhcpv6" "ntp")
|
local firewalld_expected_services=("http" "dns" "dhcp" "dhcpv6")
|
||||||
for i in "${firewalld_expected_services[@]}"; do
|
for i in "${firewalld_expected_services[@]}"; do
|
||||||
if [[ "${firewalld_enabled_services}" =~ ${i} ]]; then
|
if [[ "${firewalld_enabled_services}" =~ ${i} ]]; then
|
||||||
log_write "${TICK} ${COL_GREEN} Allow Service: ${i}${COL_NC}";
|
log_write "${TICK} ${COL_GREEN} Allow Service: ${i}${COL_NC}";
|
||||||
@@ -388,6 +388,14 @@ check_firewalld() {
|
|||||||
else
|
else
|
||||||
log_write "${CROSS} ${COL_RED} Local Interface Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
|
log_write "${CROSS} ${COL_RED} Local Interface Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
|
||||||
fi
|
fi
|
||||||
|
# check FTL custom zone port: 4711
|
||||||
|
local firewalld_ftl_zone_ports
|
||||||
|
firewalld_ftl_zone_ports=$(firewall-cmd --zone=ftl --list-ports)
|
||||||
|
if [[ "${firewalld_ftl_zone_ports}" =~ "4711/tcp" ]]; then
|
||||||
|
log_write "${TICK} ${COL_GREEN} FTL Port 4711/tcp Detected${COL_NC}";
|
||||||
|
else
|
||||||
|
log_write "${CROSS} ${COL_RED} FTL Port 4711/tcp Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log_write "${CROSS} ${COL_RED}FTL Custom Zone Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
|
log_write "${CROSS} ${COL_RED}FTL Custom Zone Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
|
||||||
fi
|
fi
|
||||||
@@ -489,25 +497,16 @@ ping_gateway() {
|
|||||||
ping_ipv4_or_ipv6 "${protocol}"
|
ping_ipv4_or_ipv6 "${protocol}"
|
||||||
# Check if we are using IPv4 or IPv6
|
# Check if we are using IPv4 or IPv6
|
||||||
# Find the default gateways using IPv4 or IPv6
|
# Find the default gateways using IPv4 or IPv6
|
||||||
local gateway gateway_addr gateway_iface default_route
|
local gateway gateway_addr gateway_iface
|
||||||
|
|
||||||
log_write "${INFO} Default IPv${protocol} gateway(s):"
|
log_write "${INFO} Default IPv${protocol} gateway(s):"
|
||||||
|
|
||||||
while IFS= read -r default_route; do
|
while IFS= read -r gateway; do
|
||||||
gateway_addr=$(jq -r '.gateway' <<< "${default_route}")
|
log_write " $(cut -d ' ' -f 3 <<< "${gateway}")%$(cut -d ' ' -f 5 <<< "${gateway}")"
|
||||||
gateway_iface=$(jq -r '.dev' <<< "${default_route}")
|
done < <(ip -"${protocol}" route | grep default)
|
||||||
log_write " ${gateway_addr}%${gateway_iface}"
|
|
||||||
done < <(ip -j -"${protocol}" route | jq -c '.[] | select(.dst == "default")')
|
|
||||||
|
|
||||||
# Find the first default route
|
|
||||||
default_route=$(ip -j -"${protocol}" route show default)
|
|
||||||
if echo "$default_route" | grep 'gateway' | grep -q 'dev'; then
|
|
||||||
gateway_addr=$(echo "$default_route" | jq -r -c '.[0].gateway')
|
|
||||||
gateway_iface=$(echo "$default_route" | jq -r -c '.[0].dev')
|
|
||||||
else
|
|
||||||
log_write " Unable to determine gateway address for IPv${protocol}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
gateway_addr=$(ip -"${protocol}" route | grep default | cut -d ' ' -f 3 | head -n 1)
|
||||||
|
gateway_iface=$(ip -"${protocol}" route | grep default | cut -d ' ' -f 5 | head -n 1)
|
||||||
# If there was at least one gateway
|
# If there was at least one gateway
|
||||||
if [ -n "${gateway_addr}" ]; then
|
if [ -n "${gateway_addr}" ]; then
|
||||||
# Append the interface to the gateway address if it is a link-local address
|
# Append the interface to the gateway address if it is a link-local address
|
||||||
@@ -672,7 +671,7 @@ dig_at() {
|
|||||||
local record_type="A"
|
local record_type="A"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find a random blocked url that has not been allowlisted and is not ABP style.
|
# Find a random blocked url that has not been whitelisted and is not ABP style.
|
||||||
# This helps emulate queries to different domains that a user might query
|
# This helps emulate queries to different domains that a user might query
|
||||||
# It will also give extra assurance that Pi-hole is correctly resolving and blocking domains
|
# It will also give extra assurance that Pi-hole is correctly resolving and blocking domains
|
||||||
local random_url
|
local random_url
|
||||||
@@ -778,7 +777,7 @@ process_status(){
|
|||||||
:
|
:
|
||||||
else
|
else
|
||||||
# non-Docker system
|
# non-Docker system
|
||||||
if service "${i}" status | grep -q -E 'is\srunning|started'; then
|
if service "${i}" status | grep -E 'is\srunning' &> /dev/null; then
|
||||||
status_of_process="active"
|
status_of_process="active"
|
||||||
else
|
else
|
||||||
status_of_process="inactive"
|
status_of_process="inactive"
|
||||||
@@ -1088,7 +1087,7 @@ show_adlists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_domainlist() {
|
show_domainlist() {
|
||||||
show_db_entries "Domainlist (0/1 = exact allow-/denylist, 2/3 = regex allow-/denylist)" "SELECT id,CASE type WHEN '0' THEN '0 ' WHEN '1' THEN ' 1 ' WHEN '2' THEN ' 2 ' WHEN '3' THEN ' 3' ELSE type END type,CASE enabled WHEN '0' THEN ' 0' WHEN '1' THEN ' 1' ELSE enabled END enabled,GROUP_CONCAT(domainlist_by_group.group_id) group_ids,domain,datetime(date_added,'unixepoch','localtime') date_added,datetime(date_modified,'unixepoch','localtime') date_modified,comment FROM domainlist LEFT JOIN domainlist_by_group ON domainlist.id = domainlist_by_group.domainlist_id GROUP BY id;" "5 4 7 12 100 19 19 50"
|
show_db_entries "Domainlist (0/1 = exact white-/blacklist, 2/3 = regex white-/blacklist)" "SELECT id,CASE type WHEN '0' THEN '0 ' WHEN '1' THEN ' 1 ' WHEN '2' THEN ' 2 ' WHEN '3' THEN ' 3' ELSE type END type,CASE enabled WHEN '0' THEN ' 0' WHEN '1' THEN ' 1' ELSE enabled END enabled,GROUP_CONCAT(domainlist_by_group.group_id) group_ids,domain,datetime(date_added,'unixepoch','localtime') date_added,datetime(date_modified,'unixepoch','localtime') date_modified,comment FROM domainlist LEFT JOIN domainlist_by_group ON domainlist.id = domainlist_by_group.domainlist_id GROUP BY id;" "5 4 7 12 100 19 19 50"
|
||||||
}
|
}
|
||||||
|
|
||||||
show_clients() {
|
show_clients() {
|
||||||
|
|||||||
@@ -12,10 +12,14 @@ colfile="/opt/pihole/COL_TABLE"
|
|||||||
# shellcheck source="./advanced/Scripts/COL_TABLE"
|
# shellcheck source="./advanced/Scripts/COL_TABLE"
|
||||||
source ${colfile}
|
source ${colfile}
|
||||||
|
|
||||||
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
|
||||||
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
|
||||||
# shellcheck source="./advanced/Scripts/utils.sh"
|
# shellcheck source="./advanced/Scripts/utils.sh"
|
||||||
source "${utilsfile}"
|
source "/opt/pihole/utils.sh"
|
||||||
|
|
||||||
|
SKIP_INSTALL="true"
|
||||||
|
# shellcheck source="./automated install/basic-install.sh"
|
||||||
|
source "/etc/.pihole/automated install/basic-install.sh"
|
||||||
|
# stop_service() is defined in basic-install.sh
|
||||||
|
# restart_service() is defined in basic-install.sh
|
||||||
|
|
||||||
# In case we're running at the same time as a system logrotate, use a
|
# In case we're running at the same time as a system logrotate, use a
|
||||||
# separate logrotate state file to prevent stepping on each other's
|
# separate logrotate state file to prevent stepping on each other's
|
||||||
@@ -86,7 +90,6 @@ if [[ "$*" == *"once"* ]]; then
|
|||||||
if [[ "$*" != *"quiet"* ]]; then
|
if [[ "$*" != *"quiet"* ]]; then
|
||||||
echo -ne " ${INFO} Running logrotate ..."
|
echo -ne " ${INFO} Running logrotate ..."
|
||||||
fi
|
fi
|
||||||
mkdir -p "${STATEFILE%/*}"
|
|
||||||
/usr/sbin/logrotate --force --state "${STATEFILE}" /etc/pihole/logrotate
|
/usr/sbin/logrotate --force --state "${STATEFILE}" /etc/pihole/logrotate
|
||||||
else
|
else
|
||||||
# Handle rotation for each log file
|
# Handle rotation for each log file
|
||||||
@@ -105,14 +108,16 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Stop FTL to make sure it doesn't write to the database while we're deleting data
|
# Stop FTL to make sure it doesn't write to the database while we're deleting data
|
||||||
service pihole-FTL stop
|
stop_service pihole-FTL >/dev/null
|
||||||
|
|
||||||
|
|
||||||
# Delete most recent 24 hours from FTL's database, leave even older data intact (don't wipe out all history)
|
# Delete most recent 24 hours from FTL's database, leave even older data intact (don't wipe out all history)
|
||||||
deleted=$(pihole-FTL sqlite3 -ni "${DBFILE}" "DELETE FROM query_storage WHERE timestamp >= strftime('%s','now')-86400; select changes() from query_storage limit 1")
|
deleted=$(pihole-FTL sqlite3 -ni "${DBFILE}" "DELETE FROM query_storage WHERE timestamp >= strftime('%s','now')-86400; select changes() from query_storage limit 1")
|
||||||
|
|
||||||
# Restart FTL
|
# Restart FTL
|
||||||
service pihole-FTL restart
|
restart_service pihole-FTL >/dev/null
|
||||||
if [[ "$*" != *"quiet"* ]]; then
|
if [[ "$*" != *"quiet"* ]]; then
|
||||||
echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database"
|
echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
|
||||||
# (c) 2019 Pi-hole, LLC (https://pi-hole.net)
|
|
||||||
# Network-wide ad blocking via your own hardware.
|
|
||||||
#
|
|
||||||
# Network table flush
|
|
||||||
#
|
|
||||||
# This file is copyright under the latest version of the EUPL.
|
|
||||||
# Please see LICENSE file for your rights under this license.
|
|
||||||
|
|
||||||
coltable="/opt/pihole/COL_TABLE"
|
|
||||||
if [[ -f ${coltable} ]]; then
|
|
||||||
# shellcheck source="./advanced/Scripts/COL_TABLE"
|
|
||||||
source ${coltable}
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
|
||||||
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
|
||||||
# shellcheck source=./advanced/Scripts/utils.sh
|
|
||||||
source "${utilsfile}"
|
|
||||||
|
|
||||||
# Source api functions
|
|
||||||
# shellcheck source="./advanced/Scripts/api.sh"
|
|
||||||
. "${PI_HOLE_SCRIPT_DIR}/api.sh"
|
|
||||||
|
|
||||||
flushNetwork(){
|
|
||||||
local output
|
|
||||||
|
|
||||||
echo -ne " ${INFO} Flushing network table ..."
|
|
||||||
|
|
||||||
local data status error
|
|
||||||
# Authenticate with FTL
|
|
||||||
LoginAPI
|
|
||||||
|
|
||||||
# send query again
|
|
||||||
data=$(PostFTLData "action/flush/network" "" "status")
|
|
||||||
|
|
||||||
# Separate the status from the data
|
|
||||||
status=$(printf %s "${data#"${data%???}"}")
|
|
||||||
data=$(printf %s "${data%???}")
|
|
||||||
|
|
||||||
# If there is an .error object in the returned data, display it
|
|
||||||
local error
|
|
||||||
error=$(jq --compact-output <<< "${data}" '.error')
|
|
||||||
if [[ $error != "null" && $error != "" ]]; then
|
|
||||||
echo -e "${OVER} ${CROSS} Failed to flush the network table:"
|
|
||||||
echo -e " $(jq <<< "${data}" '.error')"
|
|
||||||
LogoutAPI
|
|
||||||
exit 1
|
|
||||||
elif [[ "${status}" == "200" ]]; then
|
|
||||||
echo -e "${OVER} ${TICK} Flushed network table"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Delete session
|
|
||||||
LogoutAPI
|
|
||||||
}
|
|
||||||
|
|
||||||
flushArp(){
|
|
||||||
# Flush ARP cache of the host
|
|
||||||
if ! output=$(ip -s -s neigh flush all 2>&1); then
|
|
||||||
echo -e "${OVER} ${CROSS} Failed to flush ARP cache"
|
|
||||||
echo " Output: ${output}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Process all options (if present)
|
|
||||||
while [ "$#" -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
"--arp" ) doARP=true ;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
flushNetwork
|
|
||||||
|
|
||||||
if [[ "${doARP}" == true ]]; then
|
|
||||||
echo -ne " ${INFO} Flushing ARP cache"
|
|
||||||
if flushArp; then
|
|
||||||
echo -e "${OVER} ${TICK} Flushed ARP cache"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
@@ -37,16 +37,19 @@ Options:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GenerateOutput() {
|
GenerateOutput() {
|
||||||
local counts data num_gravity num_lists search_type_str
|
local data gravity_data lists_data num_gravity num_lists search_type_str
|
||||||
local gravity_data_csv lists_data_csv line url type color
|
local gravity_data_csv lists_data_csv line current_domain url type color
|
||||||
data="${1}"
|
data="${1}"
|
||||||
|
|
||||||
# Get count of list and gravity matches
|
# construct a new json for the list results where each object contains the domain and the related type
|
||||||
# Use JQ to count number of entries in lists and gravity
|
lists_data=$(printf %s "${data}" | jq '.search.domains | [.[] | {domain: .domain, type: .type}]')
|
||||||
# (output is number of list matches then number of gravity matches)
|
|
||||||
counts=$(printf %s "${data}" | jq --raw-output '(.search.domains | length), (.search.gravity | group_by(.address,.type) | length)')
|
# construct a new json for the gravity results where each object contains the adlist URL and the related domains
|
||||||
num_lists=$(echo "$counts" | sed -n '1p')
|
gravity_data=$(printf %s "${data}" | jq '.search.gravity | group_by(.address,.type) | map({ address: (.[0].address), type: (.[0].type), domains: [.[] | .domain] })')
|
||||||
num_gravity=$(echo "$counts" | sed -n '2p')
|
|
||||||
|
# number of objects in each json
|
||||||
|
num_gravity=$(printf %s "${gravity_data}" | jq length)
|
||||||
|
num_lists=$(printf %s "${lists_data}" | jq length)
|
||||||
|
|
||||||
if [ "${partial}" = true ]; then
|
if [ "${partial}" = true ]; then
|
||||||
search_type_str="partially"
|
search_type_str="partially"
|
||||||
@@ -59,7 +62,7 @@ GenerateOutput() {
|
|||||||
if [ "${num_lists}" -gt 0 ]; then
|
if [ "${num_lists}" -gt 0 ]; then
|
||||||
# Convert the data to a csv, each line is a "domain,type" string
|
# Convert the data to a csv, each line is a "domain,type" string
|
||||||
# not using jq's @csv here as it quotes each value individually
|
# not using jq's @csv here as it quotes each value individually
|
||||||
lists_data_csv=$(printf %s "${data}" | jq --raw-output '.search.domains | map([.domain, .type] | join(",")) | join("\n")')
|
lists_data_csv=$(printf %s "${lists_data}" | jq --raw-output '.[] | [.domain, .type] | join(",")')
|
||||||
|
|
||||||
# Generate output for each csv line, separating line in a domain and type substring at the ','
|
# Generate output for each csv line, separating line in a domain and type substring at the ','
|
||||||
echo "${lists_data_csv}" | while read -r line; do
|
echo "${lists_data_csv}" | while read -r line; do
|
||||||
@@ -68,11 +71,11 @@ GenerateOutput() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Results from gravity
|
# Results from gravity
|
||||||
printf "%s\n\n" "Found ${num_gravity} lists ${search_type_str} matching '${COL_BLUE}${domain}${COL_NC}'."
|
printf "%s\n\n" "Found ${num_gravity} adlists ${search_type_str} matching '${COL_BLUE}${domain}${COL_NC}'."
|
||||||
if [ "${num_gravity}" -gt 0 ]; then
|
if [ "${num_gravity}" -gt 0 ]; then
|
||||||
# Convert the data to a csv, each line is a "URL,type,domain,domain,...." string
|
# Convert the data to a csv, each line is a "URL,domain,domain,...." string
|
||||||
# not using jq's @csv here as it quotes each value individually
|
# not using jq's @csv here as it quotes each value individually
|
||||||
gravity_data_csv=$(printf %s "${data}" | jq --raw-output '.search.gravity | group_by(.address,.type) | map([.[0].address, .[0].type, (.[] | .domain)] | join(",")) | join("\n")')
|
gravity_data_csv=$(printf %s "${gravity_data}" | jq --raw-output '.[] | [.address, .type, .domains[]] | join(",")')
|
||||||
|
|
||||||
# Generate line-by-line output for each csv line
|
# Generate line-by-line output for each csv line
|
||||||
echo "${gravity_data_csv}" | while read -r line; do
|
echo "${gravity_data_csv}" | while read -r line; do
|
||||||
@@ -94,8 +97,15 @@ GenerateOutput() {
|
|||||||
|
|
||||||
# cut off type, leaving "domain,domain,...."
|
# cut off type, leaving "domain,domain,...."
|
||||||
line=${line#*,}
|
line=${line#*,}
|
||||||
# Replace commas with newlines and format output
|
# print each domain and remove it from the string until nothing is left
|
||||||
echo "${line}" | sed 's/,/\n/g' | sed "s/^/ - ${COL_GREEN}/" | sed "s/$/${COL_NC}/"
|
while [ ${#line} -gt 0 ]; do
|
||||||
|
current_domain=${line%%,*}
|
||||||
|
printf ' - %s\n' "${COL_GREEN}${current_domain}${COL_NC}"
|
||||||
|
# we need to remove the current_domain and the comma in two steps because
|
||||||
|
# the last domain won't have a trailing comma and the while loop wouldn't exit
|
||||||
|
line=${line#"${current_domain}"}
|
||||||
|
line=${line#,}
|
||||||
|
done
|
||||||
printf "\n\n"
|
printf "\n\n"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ GitCheckUpdateAvail() {
|
|||||||
|
|
||||||
# Fetch latest changes in this repo
|
# Fetch latest changes in this repo
|
||||||
if ! git fetch --quiet origin ; then
|
if ! git fetch --quiet origin ; then
|
||||||
echo -e "\\n ${COL_RED}Error: Unable to update local repository. Contact Pi-hole Support.${COL_NC}"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Unable to update local repository. Contact Pi-hole Support.${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -76,13 +76,13 @@ GitCheckUpdateAvail() {
|
|||||||
|
|
||||||
|
|
||||||
if [[ "${#LOCAL}" == 0 ]]; then
|
if [[ "${#LOCAL}" == 0 ]]; then
|
||||||
echo -e "\\n ${COL_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"
|
||||||
echo -e " Additional debugging output:${COL_NC}"
|
echo -e " Additional debugging output:${COL_NC}"
|
||||||
git status
|
git status
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ "${#REMOTE}" == 0 ]]; then
|
if [[ "${#REMOTE}" == 0 ]]; then
|
||||||
echo -e "\\n ${COL_RED}Error: Remote revision could not be obtained, please contact Pi-hole Support"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Remote revision could not be obtained, please contact Pi-hole Support"
|
||||||
echo -e " Additional debugging output:${COL_NC}"
|
echo -e " Additional debugging output:${COL_NC}"
|
||||||
git status
|
git status
|
||||||
exit 1
|
exit 1
|
||||||
@@ -103,7 +103,7 @@ GitCheckUpdateAvail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local basicError="\\n ${COL_RED}Unable to complete update, please contact Pi-hole Support${COL_NC}"
|
local basicError="\\n ${COL_LIGHT_RED}Unable to complete update, please contact Pi-hole Support${COL_NC}"
|
||||||
local core_update
|
local core_update
|
||||||
local web_update
|
local web_update
|
||||||
local FTL_update
|
local FTL_update
|
||||||
@@ -120,7 +120,7 @@ main() {
|
|||||||
|
|
||||||
# This is unlikely
|
# This is unlikely
|
||||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||||
echo -e "\\n ${COL_RED}Error: Core Pi-hole repo is missing from system!"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!"
|
||||||
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
|
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
@@ -132,11 +132,11 @@ main() {
|
|||||||
echo -e " ${INFO} Pi-hole Core:\\t${COL_YELLOW}update available${COL_NC}"
|
echo -e " ${INFO} Pi-hole Core:\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
else
|
else
|
||||||
core_update=false
|
core_update=false
|
||||||
echo -e " ${INFO} Pi-hole Core:\\t${COL_GREEN}up to date${COL_NC}"
|
echo -e " ${INFO} Pi-hole Core:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
||||||
echo -e "\\n ${COL_RED}Error: Web Admin repo is missing from system!"
|
echo -e "\\n ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!"
|
||||||
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
|
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
@@ -146,7 +146,7 @@ main() {
|
|||||||
echo -e " ${INFO} Web Interface:\\t${COL_YELLOW}update available${COL_NC}"
|
echo -e " ${INFO} Web Interface:\\t${COL_YELLOW}update available${COL_NC}"
|
||||||
else
|
else
|
||||||
web_update=false
|
web_update=false
|
||||||
echo -e " ${INFO} Web Interface:\\t${COL_GREEN}up to date${COL_NC}"
|
echo -e " ${INFO} Web Interface:\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local funcOutput
|
local funcOutput
|
||||||
@@ -160,18 +160,17 @@ main() {
|
|||||||
else
|
else
|
||||||
case $? in
|
case $? in
|
||||||
1)
|
1)
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_GREEN}up to date${COL_NC}"
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_GREEN}up to date${COL_NC}"
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_RED}Branch is not available.${COL_NC}\\n\\t\\t\\tUse ${COL_GREEN}pihole checkout ftl [branchname]${COL_NC} to switch to a valid branch."
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Branch is not available.${COL_NC}\\n\\t\\t\\tUse ${COL_LIGHT_GREEN}pihole checkout ftl [branchname]${COL_NC} to switch to a valid branch."
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_RED}Something has gone wrong, cannot reach download server${COL_NC}"
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Something has gone wrong, cannot reach download server${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e " ${INFO} FTL:\\t\\t${COL_RED}Something has gone wrong, contact support${COL_NC}"
|
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Something has gone wrong, contact support${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
FTL_update=false
|
FTL_update=false
|
||||||
@@ -188,7 +187,7 @@ main() {
|
|||||||
if [[ ! "${ftlBranch}" == "master" && ! "${ftlBranch}" == "development" ]]; then
|
if [[ ! "${ftlBranch}" == "master" && ! "${ftlBranch}" == "development" ]]; then
|
||||||
# Notify user that they are on a custom branch which might mean they they are lost
|
# Notify user that they are on a custom branch which might mean they they are lost
|
||||||
# behind if a branch was merged to development and got abandoned
|
# behind if a branch was merged to development and got abandoned
|
||||||
printf " %b %bWarning:%b You are using FTL from a custom branch (%s) and might be missing future releases.\\n" "${INFO}" "${COL_RED}" "${COL_NC}" "${ftlBranch}"
|
printf " %b %bWarning:%b You are using FTL from a custom branch (%s) and might be missing future releases.\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}" "${ftlBranch}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${core_update}" == false && "${web_update}" == false && "${FTL_update}" == false ]]; then
|
if [[ "${core_update}" == false && "${web_update}" == false && "${FTL_update}" == false ]]; then
|
||||||
|
|||||||
@@ -73,9 +73,7 @@ getFTLPID() {
|
|||||||
# Example getFTLConfigValue dns.piholePTR
|
# Example getFTLConfigValue dns.piholePTR
|
||||||
#######################
|
#######################
|
||||||
getFTLConfigValue(){
|
getFTLConfigValue(){
|
||||||
# Pipe to cat to avoid pihole-FTL assuming this is an interactive command
|
pihole-FTL --config -q "${1}"
|
||||||
# returning colored output.
|
|
||||||
pihole-FTL --config -q "${1}" | cat
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
@@ -88,17 +86,9 @@ getFTLConfigValue(){
|
|||||||
# setFTLConfigValue dns.upstreams '[ "8.8.8.8" , "8.8.4.4" ]'
|
# setFTLConfigValue dns.upstreams '[ "8.8.8.8" , "8.8.4.4" ]'
|
||||||
#######################
|
#######################
|
||||||
setFTLConfigValue(){
|
setFTLConfigValue(){
|
||||||
local err
|
pihole-FTL --config "${1}" "${2}" >/dev/null
|
||||||
{ pihole-FTL --config "${1}" "${2}" >/dev/null; err="$?"; } || true
|
if [ $? -eq 5 ]; then
|
||||||
|
printf " %s %s set by environment variable. Please unset it to use this function\n" "${CROSS}" "${1}"
|
||||||
case $err in
|
exit 5
|
||||||
0) ;;
|
fi
|
||||||
5)
|
|
||||||
# FTL returns 5 if the value was set by an environment variable and is therefore read-only
|
|
||||||
printf " %s %s set by environment variable. Please unset it to use this function\n" "${CROSS}" "${1}";
|
|
||||||
exit 5;;
|
|
||||||
*)
|
|
||||||
printf " %s Failed to set %s. Try with sudo power\n" "${CROSS}" "${1}"
|
|
||||||
exit 1
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ CREATE TABLE info
|
|||||||
value TEXT NOT NULL
|
value TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "info" VALUES('version','20');
|
INSERT INTO "info" VALUES('version','19');
|
||||||
/* This is a flag to indicate if gravity was restored from a backup
|
/* This is a flag to indicate if gravity was restored from a backup
|
||||||
false = not restored,
|
false = not restored,
|
||||||
failed = restoration failed due to no backup
|
failed = restoration failed due to no backup
|
||||||
@@ -111,7 +111,7 @@ CREATE TRIGGER tr_domainlist_update AFTER UPDATE ON domainlist
|
|||||||
UPDATE domainlist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
UPDATE domainlist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE VIEW vw_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_whitelist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
@@ -119,7 +119,7 @@ CREATE VIEW vw_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_gr
|
|||||||
AND domainlist.type = 0
|
AND domainlist.type = 0
|
||||||
ORDER BY domainlist.id;
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
CREATE VIEW vw_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_blacklist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
@@ -127,7 +127,7 @@ CREATE VIEW vw_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_gro
|
|||||||
AND domainlist.type = 1
|
AND domainlist.type = 1
|
||||||
ORDER BY domainlist.id;
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
CREATE VIEW vw_regex_allowlist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_regex_whitelist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
@@ -135,7 +135,7 @@ CREATE VIEW vw_regex_allowlist AS SELECT domain, domainlist.id AS id, domainlist
|
|||||||
AND domainlist.type = 2
|
AND domainlist.type = 2
|
||||||
ORDER BY domainlist.id;
|
ORDER BY domainlist.id;
|
||||||
|
|
||||||
CREATE VIEW vw_regex_denylist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
CREATE VIEW vw_regex_blacklist AS SELECT domain, domainlist.id AS id, domainlist_by_group.group_id AS group_id
|
||||||
FROM domainlist
|
FROM domainlist
|
||||||
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
LEFT JOIN domainlist_by_group ON domainlist_by_group.domainlist_id = domainlist.id
|
||||||
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
LEFT JOIN "group" ON "group".id = domainlist_by_group.group_id
|
||||||
|
|||||||
@@ -8,20 +8,12 @@ utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
|||||||
|
|
||||||
# Get file paths
|
# Get file paths
|
||||||
FTL_PID_FILE="$(getFTLConfigValue files.pid)"
|
FTL_PID_FILE="$(getFTLConfigValue files.pid)"
|
||||||
FTL_LOG_FILE="$(getFTLConfigValue files.log.ftl)"
|
|
||||||
PIHOLE_LOG_FILE="$(getFTLConfigValue files.log.dnsmasq)"
|
|
||||||
WEBSERVER_LOG_FILE="$(getFTLConfigValue files.log.webserver)"
|
|
||||||
FTL_PID_FILE="${FTL_PID_FILE:-/run/pihole-FTL.pid}"
|
|
||||||
FTL_LOG_FILE="${FTL_LOG_FILE:-/var/log/pihole/FTL.log}"
|
|
||||||
PIHOLE_LOG_FILE="${PIHOLE_LOG_FILE:-/var/log/pihole/pihole.log}"
|
|
||||||
WEBSERVER_LOG_FILE="${WEBSERVER_LOG_FILE:-/var/log/pihole/webserver.log}"
|
|
||||||
|
|
||||||
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
|
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
|
||||||
mkdir -p /var/log/pihole
|
mkdir -p /var/log/pihole
|
||||||
chown -R pihole:pihole /etc/pihole/ /var/log/pihole/
|
chown -R pihole:pihole /etc/pihole/ /var/log/pihole/
|
||||||
|
|
||||||
# allow all users read version file (and use pihole -v)
|
# allow all users read version file (and use pihole -v)
|
||||||
touch /etc/pihole/versions
|
|
||||||
chmod 0644 /etc/pihole/versions
|
chmod 0644 /etc/pihole/versions
|
||||||
|
|
||||||
# allow pihole to access subdirs in /etc/pihole (sets execution bit on dirs)
|
# allow pihole to access subdirs in /etc/pihole (sets execution bit on dirs)
|
||||||
@@ -36,7 +28,7 @@ chown root:root /etc/pihole/logrotate
|
|||||||
|
|
||||||
# Touch files to ensure they exist (create if non-existing, preserve if existing)
|
# Touch files to ensure they exist (create if non-existing, preserve if existing)
|
||||||
[ -f "${FTL_PID_FILE}" ] || install -D -m 644 -o pihole -g pihole /dev/null "${FTL_PID_FILE}"
|
[ -f "${FTL_PID_FILE}" ] || install -D -m 644 -o pihole -g pihole /dev/null "${FTL_PID_FILE}"
|
||||||
[ -f "${FTL_LOG_FILE}" ] || install -m 640 -o pihole -g pihole /dev/null "${FTL_LOG_FILE}"
|
[ -f /var/log/pihole/FTL.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/FTL.log
|
||||||
[ -f "${PIHOLE_LOG_FILE}" ] || install -m 640 -o pihole -g pihole /dev/null "${PIHOLE_LOG_FILE}"
|
[ -f /var/log/pihole/pihole.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/pihole.log
|
||||||
[ -f "${WEBSERVER_LOG_FILE}" ] || install -m 640 -o pihole -g pihole /dev/null "${WEBSERVER_LOG_FILE}"
|
[ -f /var/log/pihole/webserver.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/webserver.log
|
||||||
[ -f /etc/pihole/dhcp.leases ] || install -m 644 -o pihole -g pihole /dev/null /etc/pihole/dhcp.leases
|
[ -f /etc/pihole/dhcp.leases ] || install -m 644 -o pihole -g pihole /dev/null /etc/pihole/dhcp.leases
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
#!/sbin/openrc-run
|
|
||||||
# shellcheck shell=sh disable=SC2034
|
|
||||||
|
|
||||||
: "${PI_HOLE_SCRIPT_DIR:=/opt/pihole}"
|
|
||||||
|
|
||||||
command="/usr/bin/pihole-FTL"
|
|
||||||
command_user="pihole:pihole"
|
|
||||||
supervisor=supervise-daemon
|
|
||||||
command_args_foreground="-f"
|
|
||||||
command_background=true
|
|
||||||
pidfile="/run/${RC_SVCNAME}_openrc.pid"
|
|
||||||
extra_started_commands="reload"
|
|
||||||
|
|
||||||
respawn_max=5
|
|
||||||
respawn_period=60
|
|
||||||
capabilities="^CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_IPC_LOCK,CAP_CHOWN,CAP_SYS_TIME"
|
|
||||||
|
|
||||||
depend() {
|
|
||||||
want net
|
|
||||||
provide dns
|
|
||||||
}
|
|
||||||
|
|
||||||
checkconfig() {
|
|
||||||
$command -f test
|
|
||||||
}
|
|
||||||
|
|
||||||
start_pre() {
|
|
||||||
sh "${PI_HOLE_SCRIPT_DIR}/pihole-FTL-prestart.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_post() {
|
|
||||||
sh "${PI_HOLE_SCRIPT_DIR}/pihole-FTL-poststop.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
reload() {
|
|
||||||
checkconfig || return $?
|
|
||||||
ebegin "Reloading ${RC_SVCNAME}"
|
|
||||||
start-stop-daemon --signal HUP --pidfile "${pidfile}"
|
|
||||||
eend $?
|
|
||||||
}
|
|
||||||
51
advanced/bash-completion/pihole
Normal file
51
advanced/bash-completion/pihole
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
_pihole() {
|
||||||
|
local cur prev opts opts_checkout opts_debug opts_logging opts_query opts_update opts_version
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
prev2="${COMP_WORDS[COMP_CWORD-2]}"
|
||||||
|
|
||||||
|
case "${prev}" in
|
||||||
|
"pihole")
|
||||||
|
opts="allow allow-regex allow-wild deny checkout debug disable enable flush help logging query repair regex reloaddns reloadlists status tail uninstall updateGravity updatePihole version wildcard arpflush api"
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
"allow"|"deny"|"wildcard"|"regex"|"allow-regex"|"allow-wild")
|
||||||
|
opts_lists="\not \--delmode \--quiet \--list \--help"
|
||||||
|
COMPREPLY=( $(compgen -W "${opts_lists}" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
"checkout")
|
||||||
|
opts_checkout="core ftl web master dev"
|
||||||
|
COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${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="--partial --all"
|
||||||
|
COMPREPLY=( $(compgen -W "${opts_query}" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
"updatePihole"|"-up")
|
||||||
|
opts_update="--check-only"
|
||||||
|
COMPREPLY=( $(compgen -W "${opts_update}" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
"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
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Bash completion script for pihole-FTL
|
|
||||||
#
|
|
||||||
# This completion script provides tab completion for pihole-FTL CLI flags and commands.
|
|
||||||
# It uses the `pihole-FTL --complete` command to generate the completion options.
|
|
||||||
_complete_FTL() { mapfile -t COMPREPLY < <(pihole-FTL --complete "${COMP_WORDS[@]}"); }
|
|
||||||
|
|
||||||
complete -F _complete_FTL pihole-FTL
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Bash completion script for pihole
|
|
||||||
#
|
|
||||||
_pihole() {
|
|
||||||
local cur prev prev2 opts opts_lists opts_checkout opts_debug opts_logging opts_query opts_update opts_networkflush
|
|
||||||
COMPREPLY=()
|
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
||||||
prev2="${COMP_WORDS[COMP_CWORD-2]}"
|
|
||||||
|
|
||||||
case "${prev}" in
|
|
||||||
"pihole")
|
|
||||||
opts="allow allow-regex allow-wild deny checkout debug disable enable flush help logging query repair regex reloaddns reloadlists setpassword status tail uninstall updateGravity updatePihole version wildcard networkflush api"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"allow"|"deny"|"wildcard"|"regex"|"allow-regex"|"allow-wild")
|
|
||||||
opts_lists="\not \--delmode \--quiet \--list \--help"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_lists}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"checkout")
|
|
||||||
opts_checkout="core ftl web master dev"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_checkout}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"debug")
|
|
||||||
opts_debug="-a"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_debug}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"logging")
|
|
||||||
opts_logging="on off 'off noflush'"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_logging}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"query")
|
|
||||||
opts_query="--partial --all"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_query}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"updatePihole"|"-up")
|
|
||||||
opts_update="--check-only"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_update}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"networkflush")
|
|
||||||
opts_networkflush="--arp"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_networkflush}" -- "${cur}")
|
|
||||||
;;
|
|
||||||
"core"|"web"|"ftl")
|
|
||||||
if [[ "$prev2" == "checkout" ]]; then
|
|
||||||
opts_checkout="master development"
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "${opts_checkout}" -- "${cur}")
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
complete -F _pihole pihole
|
|
||||||
@@ -94,8 +94,8 @@ fresh_install=true
|
|||||||
|
|
||||||
adlistFile="/etc/pihole/adlists.list"
|
adlistFile="/etc/pihole/adlists.list"
|
||||||
# Pi-hole needs an IP address; to begin, these variables are empty since we don't know what the IP is until this script can run
|
# Pi-hole needs an IP address; to begin, these variables are empty since we don't know what the IP is until this script can run
|
||||||
IPV4_ADDRESS=
|
IPV4_ADDRESS=${IPV4_ADDRESS}
|
||||||
IPV6_ADDRESS=
|
IPV6_ADDRESS=${IPV6_ADDRESS}
|
||||||
# Give settings their default values. These may be changed by prompts later in the script.
|
# Give settings their default values. These may be changed by prompts later in the script.
|
||||||
QUERY_LOGGING=
|
QUERY_LOGGING=
|
||||||
PRIVACY_LEVEL=
|
PRIVACY_LEVEL=
|
||||||
@@ -116,11 +116,11 @@ c=70
|
|||||||
PIHOLE_META_PACKAGE_CONTROL_APT=$(
|
PIHOLE_META_PACKAGE_CONTROL_APT=$(
|
||||||
cat <<EOM
|
cat <<EOM
|
||||||
Package: pihole-meta
|
Package: pihole-meta
|
||||||
Version: 0.6
|
Version: 0.4
|
||||||
Maintainer: Pi-hole team <adblock@pi-hole.net>
|
Maintainer: Pi-hole team <adblock@pi-hole.net>
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Description: Pi-hole dependency meta package
|
Description: Pi-hole dependency meta package
|
||||||
Depends: awk,bash-completion,binutils,ca-certificates,cron|cron-daemon,curl,dialog,bind9-dnsutils|dnsutils,dns-root-data,git,grep,iproute2,iputils-ping,jq,libcap2,libcap2-bin,lshw,procps,psmisc,sudo,unzip
|
Depends: awk,bash-completion,binutils,ca-certificates,cron|cron-daemon,curl,dialog,dnsutils,dns-root-data,git,grep,iproute2,iputils-ping,jq,libcap2,libcap2-bin,lshw,netcat-openbsd,procps,psmisc,sudo,unzip
|
||||||
Section: contrib/metapackages
|
Section: contrib/metapackages
|
||||||
Priority: optional
|
Priority: optional
|
||||||
EOM
|
EOM
|
||||||
@@ -130,12 +130,12 @@ EOM
|
|||||||
PIHOLE_META_PACKAGE_CONTROL_RPM=$(
|
PIHOLE_META_PACKAGE_CONTROL_RPM=$(
|
||||||
cat <<EOM
|
cat <<EOM
|
||||||
Name: pihole-meta
|
Name: pihole-meta
|
||||||
Version: 0.3
|
Version: 0.2
|
||||||
Release: 1
|
Release: 1
|
||||||
License: EUPL
|
License: EUPL
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
Summary: Pi-hole dependency meta package
|
Summary: Pi-hole dependency meta package
|
||||||
Requires: bash-completion,bind-utils,binutils,ca-certificates,chkconfig,cronie,curl,dialog,findutils,gawk,git,grep,iproute,jq,libcap,lshw,procps-ng,psmisc,sudo,unzip
|
Requires: bash-completion,bind-utils,binutils,ca-certificates,chkconfig,cronie,curl,dialog,findutils,gawk,git,grep,iproute,jq,libcap,lshw,nmap-ncat,procps-ng,psmisc,sudo,unzip
|
||||||
%description
|
%description
|
||||||
Pi-hole dependency meta package
|
Pi-hole dependency meta package
|
||||||
%prep
|
%prep
|
||||||
@@ -143,9 +143,6 @@ Pi-hole dependency meta package
|
|||||||
%files
|
%files
|
||||||
%install
|
%install
|
||||||
%changelog
|
%changelog
|
||||||
* Mon Jul 14 2025 Pi-hole Team - 0.3
|
|
||||||
- Remove nmap-ncat from the list of dependencies
|
|
||||||
|
|
||||||
* Wed May 28 2025 Pi-hole Team - 0.2
|
* Wed May 28 2025 Pi-hole Team - 0.2
|
||||||
- Add gawk to the list of dependencies
|
- Add gawk to the list of dependencies
|
||||||
|
|
||||||
@@ -154,36 +151,6 @@ Pi-hole dependency meta package
|
|||||||
EOM
|
EOM
|
||||||
)
|
)
|
||||||
|
|
||||||
# List of required packages on APK based systems
|
|
||||||
PIHOLE_META_VERSION_APK=0.1
|
|
||||||
PIHOLE_META_DEPS_APK=(
|
|
||||||
bash
|
|
||||||
bash-completion
|
|
||||||
bind-tools
|
|
||||||
binutils
|
|
||||||
coreutils
|
|
||||||
cronie
|
|
||||||
curl
|
|
||||||
dialog
|
|
||||||
git
|
|
||||||
grep
|
|
||||||
iproute2-minimal # piholeARPTable.sh
|
|
||||||
iproute2-ss # piholeDebug.sh
|
|
||||||
jq
|
|
||||||
libcap
|
|
||||||
logrotate
|
|
||||||
lscpu # piholeDebug.sh
|
|
||||||
lshw # piholeDebug.sh
|
|
||||||
ncurses
|
|
||||||
procps-ng
|
|
||||||
psmisc
|
|
||||||
shadow
|
|
||||||
sudo
|
|
||||||
tzdata
|
|
||||||
unzip
|
|
||||||
wget
|
|
||||||
)
|
|
||||||
|
|
||||||
######## Undocumented Flags. Shhh ########
|
######## Undocumented Flags. Shhh ########
|
||||||
# These are undocumented flags; some of which we can use when repairing an installation
|
# These are undocumented flags; some of which we can use when repairing an installation
|
||||||
# The runUnattended flag is one example of this
|
# The runUnattended flag is one example of this
|
||||||
@@ -191,7 +158,7 @@ repair=false
|
|||||||
runUnattended=false
|
runUnattended=false
|
||||||
# Check arguments for the undocumented flags
|
# Check arguments for the undocumented flags
|
||||||
for var in "$@"; do
|
for var in "$@"; do
|
||||||
case "${var}" in
|
case "$var" in
|
||||||
"--repair") repair=true ;;
|
"--repair") repair=true ;;
|
||||||
"--unattended") runUnattended=true ;;
|
"--unattended") runUnattended=true ;;
|
||||||
esac
|
esac
|
||||||
@@ -206,11 +173,13 @@ if [[ -f "${coltable}" ]]; then
|
|||||||
else
|
else
|
||||||
# Set these values so the installer can still run in color
|
# Set these values so the installer can still run in color
|
||||||
COL_NC='\e[0m' # No Color
|
COL_NC='\e[0m' # No Color
|
||||||
COL_GREEN='\e[1;32m'
|
COL_LIGHT_GREEN='\e[1;32m'
|
||||||
COL_RED='\e[1;31m'
|
COL_LIGHT_RED='\e[1;31m'
|
||||||
TICK="[${COL_GREEN}✓${COL_NC}]"
|
TICK="[${COL_LIGHT_GREEN}✓${COL_NC}]"
|
||||||
CROSS="[${COL_RED}✗${COL_NC}]"
|
CROSS="[${COL_LIGHT_RED}✗${COL_NC}]"
|
||||||
INFO="[i]"
|
INFO="[i]"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
DONE="${COL_LIGHT_GREEN} done!${COL_NC}"
|
||||||
OVER="\\r\\033[K"
|
OVER="\\r\\033[K"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -218,13 +187,13 @@ fi
|
|||||||
# This lets users know that it is a Pi-hole, LLC product
|
# This lets users know that it is a Pi-hole, LLC product
|
||||||
show_ascii_berry() {
|
show_ascii_berry() {
|
||||||
echo -e "
|
echo -e "
|
||||||
${COL_GREEN}.;;,.
|
${COL_LIGHT_GREEN}.;;,.
|
||||||
.ccccc:,.
|
.ccccc:,.
|
||||||
:cccclll:. ..,,
|
:cccclll:. ..,,
|
||||||
:ccccclll. ;ooodc
|
:ccccclll. ;ooodc
|
||||||
'ccll:;ll .oooodc
|
'ccll:;ll .oooodc
|
||||||
.;cll.;;looo:.
|
.;cll.;;looo:.
|
||||||
${COL_RED}.. ','.
|
${COL_LIGHT_RED}.. ','.
|
||||||
.',,,,,,'.
|
.',,,,,,'.
|
||||||
.',,,,,,,,,,.
|
.',,,,,,,,,,.
|
||||||
.',,,,,,,,,,,,....
|
.',,,,,,,,,,,,....
|
||||||
@@ -246,7 +215,7 @@ abort() {
|
|||||||
# remove any leftover build directory that may exist
|
# remove any leftover build directory that may exist
|
||||||
rm -rf /tmp/pihole-meta_*
|
rm -rf /tmp/pihole-meta_*
|
||||||
|
|
||||||
echo -e "\\n\\n ${COL_RED}Installation was interrupted${COL_NC}\\n"
|
echo -e "\\n\\n ${COL_LIGHT_RED}Installation was interrupted${COL_NC}\\n"
|
||||||
echo -e "Pi-hole's dependencies might be already installed. If you want to remove them you can try to\\n"
|
echo -e "Pi-hole's dependencies might be already installed. If you want to remove them you can try to\\n"
|
||||||
echo -e "a) run 'pihole uninstall' \\n"
|
echo -e "a) run 'pihole uninstall' \\n"
|
||||||
echo -e "b) Remove the meta-package 'pihole-meta' manually \\n"
|
echo -e "b) Remove the meta-package 'pihole-meta' manually \\n"
|
||||||
@@ -262,11 +231,13 @@ is_command() {
|
|||||||
command -v "${check_command}" >/dev/null 2>&1
|
command -v "${check_command}" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
check_fresh_install() {
|
is_pid1() {
|
||||||
# in case of an update (can be a v5 -> v6 or v6 -> v6 update) or repair
|
# Checks to see if the given command runs as PID 1
|
||||||
if [[ -f "${PI_HOLE_V6_CONFIG}" ]] || [[ -f "/etc/pihole/setupVars.conf" ]]; then
|
local is_pid1="$1"
|
||||||
fresh_install=false
|
|
||||||
fi
|
# select PID 1, format output to show only CMD column without header
|
||||||
|
# quietly grep for a match on the function passed parameter
|
||||||
|
ps --pid 1 --format comm= | grep -q "${is_pid1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Compatibility
|
# Compatibility
|
||||||
@@ -285,6 +256,8 @@ package_manager_detect() {
|
|||||||
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
||||||
# The command we will use to remove packages (used in the uninstaller)
|
# The command we will use to remove packages (used in the uninstaller)
|
||||||
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
||||||
|
# Update package cache
|
||||||
|
update_package_cache || exit 1
|
||||||
|
|
||||||
# If apt-get is not found, check for rpm.
|
# If apt-get is not found, check for rpm.
|
||||||
elif is_command rpm; then
|
elif is_command rpm; then
|
||||||
@@ -301,15 +274,7 @@ package_manager_detect() {
|
|||||||
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
||||||
# The command we will use to remove packages (used in the uninstaller)
|
# The command we will use to remove packages (used in the uninstaller)
|
||||||
PKG_REMOVE="${PKG_MANAGER} remove -y"
|
PKG_REMOVE="${PKG_MANAGER} remove -y"
|
||||||
|
# If neither apt-get or yum/dnf package managers were found
|
||||||
# If neither apt-get or yum/dnf package managers were found, check for apk.
|
|
||||||
elif is_command apk; then
|
|
||||||
PKG_MANAGER="apk"
|
|
||||||
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
|
||||||
PKG_INSTALL="${PKG_MANAGER} add"
|
|
||||||
PKG_COUNT="${PKG_MANAGER} list --upgradable -q | wc -l"
|
|
||||||
PKG_REMOVE="${PKG_MANAGER} del"
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# we cannot install required packages
|
# we cannot install required packages
|
||||||
printf " %b No supported package manager found\\n" "${CROSS}"
|
printf " %b No supported package manager found\\n" "${CROSS}"
|
||||||
@@ -320,20 +285,13 @@ package_manager_detect() {
|
|||||||
|
|
||||||
build_dependency_package(){
|
build_dependency_package(){
|
||||||
# This function will build a package that contains all the dependencies needed for Pi-hole
|
# This function will build a package that contains all the dependencies needed for Pi-hole
|
||||||
if is_command apk ; then
|
|
||||||
local str="APK based system detected. Dependencies will be installed using a virtual package named pihole-meta"
|
|
||||||
printf " %b %s...\\n" "${INFO}" "${str}"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove any leftover build directory that may exist
|
# remove any leftover build directory that may exist
|
||||||
rm -rf /tmp/pihole-meta_*
|
rm -rf /tmp/pihole-meta_*
|
||||||
|
|
||||||
# Create a fresh build directory with random name
|
# Create a fresh build directory with random name
|
||||||
# Busybox Compat: `mktemp` long flags unsupported
|
|
||||||
# -d flag is short form of --directory
|
|
||||||
local tempdir
|
local tempdir
|
||||||
tempdir="$(mktemp -d /tmp/pihole-meta_XXXXX)"
|
tempdir="$(mktemp --directory /tmp/pihole-meta_XXXXX)"
|
||||||
chmod 0755 "${tempdir}"
|
chmod 0755 "${tempdir}"
|
||||||
|
|
||||||
if is_command apt-get; then
|
if is_command apt-get; then
|
||||||
@@ -359,7 +317,7 @@ build_dependency_package(){
|
|||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
else
|
else
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf "%b Error: Building pihole-meta.deb failed. %b\\n" "${COL_RED}" "${COL_NC}"
|
printf "%b Error: Building pihole-meta.deb failed. %b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -392,7 +350,7 @@ build_dependency_package(){
|
|||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
else
|
else
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf "%b Error: Building pihole-meta.rpm failed. %b\\n" "${COL_RED}" "${COL_NC}"
|
printf "%b Error: Building pihole-meta.rpm failed. %b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -534,7 +492,7 @@ getGitFiles() {
|
|||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
# Update the repo, returning an error message on failure
|
# Update the repo, returning an error message on failure
|
||||||
update_repo "${directory}" || {
|
update_repo "${directory}" || {
|
||||||
printf "\\n %b: Could not update local repository. Contact support.%b\\n" "${COL_RED}" "${COL_NC}"
|
printf "\\n %b: Could not update local repository. Contact support.%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
# If it's not a .git repo,
|
# If it's not a .git repo,
|
||||||
@@ -543,7 +501,7 @@ getGitFiles() {
|
|||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
# Attempt to make the repository, showing an error on failure
|
# Attempt to make the repository, showing an error on failure
|
||||||
make_repo "${directory}" "${remoteRepo}" || {
|
make_repo "${directory}" "${remoteRepo}" || {
|
||||||
printf "\\n %bError: Could not update local repository. Contact support.%b\\n" "${COL_RED}" "${COL_NC}"
|
printf "\\n %bError: Could not update local repository. Contact support.%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
@@ -621,17 +579,14 @@ Do you wish to continue with an IPv6-only installation?\\n\\n" \
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
DNS_SERVERS="${DNS_SERVERS_IPV6_ONLY}"
|
DNS_SERVERS="$DNS_SERVERS_IPV6_ONLY"
|
||||||
printf " %b Proceeding with IPv6 only installation.\\n" "${INFO}"
|
printf " %b Proceeding with IPv6 only installation.\\n" "${INFO}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get available interfaces that are UP
|
# Get available interfaces that are UP
|
||||||
get_available_interfaces() {
|
get_available_interfaces() {
|
||||||
# There may be more than one so it's all stored in a variable
|
# There may be more than one so it's all stored in a variable
|
||||||
# The ip command list all interfaces that are in the up state
|
availableInterfaces=$(ip --oneline link show up | awk '{print $2}' | grep -v "^lo" | cut -d':' -f1 | cut -d'@' -f1)
|
||||||
# The awk command filters out any interfaces that have the LOOPBACK flag set
|
|
||||||
# while using the characters ": " or "@" as a field separator for awk
|
|
||||||
availableInterfaces=$(ip --oneline link show up | awk -F ': |@' '!/<.*LOOPBACK.*>/ {print $2}')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# A function for displaying the dialogs the user sees when first running the installer
|
# A function for displaying the dialogs the user sees when first running the installer
|
||||||
@@ -694,7 +649,6 @@ chooseInterface() {
|
|||||||
status="OFF"
|
status="OFF"
|
||||||
done
|
done
|
||||||
# Disable check for double quote here as we are passing a string with spaces
|
# Disable check for double quote here as we are passing a string with spaces
|
||||||
# shellcheck disable=SC2086
|
|
||||||
PIHOLE_INTERFACE=$(dialog --no-shadow --keep-tite --output-fd 1 \
|
PIHOLE_INTERFACE=$(dialog --no-shadow --keep-tite --output-fd 1 \
|
||||||
--cancel-label "Exit" --ok-label "Select" \
|
--cancel-label "Exit" --ok-label "Select" \
|
||||||
--radiolist "Choose An Interface (press space to toggle selection)" \
|
--radiolist "Choose An Interface (press space to toggle selection)" \
|
||||||
@@ -720,9 +674,9 @@ testIPv6() {
|
|||||||
# first will contain fda2 (ULA)
|
# first will contain fda2 (ULA)
|
||||||
printf -v first "%s" "${1%%:*}"
|
printf -v first "%s" "${1%%:*}"
|
||||||
# value1 will contain 253 which is the decimal value corresponding to 0xFD
|
# value1 will contain 253 which is the decimal value corresponding to 0xFD
|
||||||
value1=$(((0x${first}) / 256))
|
value1=$(((0x$first) / 256))
|
||||||
# value2 will contain 162 which is the decimal value corresponding to 0xA2
|
# value2 will contain 162 which is the decimal value corresponding to 0xA2
|
||||||
value2=$(((0x${first}) % 256))
|
value2=$(((0x$first) % 256))
|
||||||
# the ULA test is testing for fc00::/7 according to RFC 4193
|
# the ULA test is testing for fc00::/7 according to RFC 4193
|
||||||
if (((value1 & 254) == 252)); then
|
if (((value1 & 254) == 252)); then
|
||||||
# echoing result to calling function as return value
|
# echoing result to calling function as return value
|
||||||
@@ -747,7 +701,7 @@ find_IPv6_information() {
|
|||||||
# For each address in the array above, determine the type of IPv6 address it is
|
# For each address in the array above, determine the type of IPv6 address it is
|
||||||
for i in "${IPV6_ADDRESSES[@]}"; do
|
for i in "${IPV6_ADDRESSES[@]}"; do
|
||||||
# Check if it's ULA, GUA, or LL by using the function created earlier
|
# Check if it's ULA, GUA, or LL by using the function created earlier
|
||||||
result=$(testIPv6 "${i}")
|
result=$(testIPv6 "$i")
|
||||||
# If it's a ULA address, use it and store it as a global variable
|
# If it's a ULA address, use it and store it as a global variable
|
||||||
[[ "${result}" == "ULA" ]] && ULA_ADDRESS="${i%/*}"
|
[[ "${result}" == "ULA" ]] && ULA_ADDRESS="${i%/*}"
|
||||||
# If it's a GUA address, use it and store it as a global variable
|
# If it's a GUA address, use it and store it as a global variable
|
||||||
@@ -782,7 +736,7 @@ collect_v4andv6_information() {
|
|||||||
printf " %b IPv4 address: %s\\n" "${INFO}" "${IPV4_ADDRESS}"
|
printf " %b IPv4 address: %s\\n" "${INFO}" "${IPV4_ADDRESS}"
|
||||||
find_IPv6_information
|
find_IPv6_information
|
||||||
printf " %b IPv6 address: %s\\n" "${INFO}" "${IPV6_ADDRESS}"
|
printf " %b IPv6 address: %s\\n" "${INFO}" "${IPV6_ADDRESS}"
|
||||||
if [ "${IPV4_ADDRESS}" == "" ] && [ "${IPV6_ADDRESS}" != "" ]; then
|
if [ "$IPV4_ADDRESS" == "" ] && [ "$IPV6_ADDRESS" != "" ]; then
|
||||||
confirm_ipv6_only
|
confirm_ipv6_only
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -802,7 +756,7 @@ valid_ip() {
|
|||||||
local regex="^${ipv4elem}\\.${ipv4elem}\\.${ipv4elem}\\.${ipv4elem}${portelem}$"
|
local regex="^${ipv4elem}\\.${ipv4elem}\\.${ipv4elem}\\.${ipv4elem}${portelem}$"
|
||||||
|
|
||||||
# Evaluate the regex, and return the result
|
# Evaluate the regex, and return the result
|
||||||
[[ ${ip} =~ ${regex} ]]
|
[[ $ip =~ ${regex} ]]
|
||||||
|
|
||||||
stat=$?
|
stat=$?
|
||||||
return "${stat}"
|
return "${stat}"
|
||||||
@@ -837,7 +791,7 @@ setDNS() {
|
|||||||
DNSChooseOptions=()
|
DNSChooseOptions=()
|
||||||
local DNSServerCount=0
|
local DNSServerCount=0
|
||||||
# Save the old Internal Field Separator in a variable,
|
# Save the old Internal Field Separator in a variable,
|
||||||
OIFS=${IFS}
|
OIFS=$IFS
|
||||||
# and set the new one to newline
|
# and set the new one to newline
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
# Put the DNS Servers into an array
|
# Put the DNS Servers into an array
|
||||||
@@ -862,7 +816,7 @@ setDNS() {
|
|||||||
result=$?
|
result=$?
|
||||||
case ${result} in
|
case ${result} in
|
||||||
"${DIALOG_CANCEL}" | "${DIALOG_ESC}")
|
"${DIALOG_CANCEL}" | "${DIALOG_ESC}")
|
||||||
printf " %b Cancel was selected, exiting installer%b\\n" "${COL_RED}" "${COL_NC}"
|
printf " %b Cancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -899,13 +853,13 @@ If you want to specify a port other than 53, separate it with a hash.\
|
|||||||
result=$?
|
result=$?
|
||||||
case ${result} in
|
case ${result} in
|
||||||
"${DIALOG_CANCEL}" | "${DIALOG_ESC}")
|
"${DIALOG_CANCEL}" | "${DIALOG_ESC}")
|
||||||
printf " %b Cancel was selected, exiting installer%b\\n" "${COL_RED}" "${COL_NC}"
|
printf " %b Cancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Clean user input and replace whitespace with comma.
|
# Clean user input and replace whitespace with comma.
|
||||||
piholeDNS="${piholeDNS//[[:blank:]]/,}"
|
piholeDNS=$(sed 's/[, \t]\+/,/g' <<<"${piholeDNS}")
|
||||||
|
|
||||||
# Separate the user input into the two DNS values (separated by a comma)
|
# Separate the user input into the two DNS values (separated by a comma)
|
||||||
printf -v PIHOLE_DNS_1 "%s" "${piholeDNS%%,*}"
|
printf -v PIHOLE_DNS_1 "%s" "${piholeDNS%%,*}"
|
||||||
@@ -953,7 +907,7 @@ If you want to specify a port other than 53, separate it with a hash.\
|
|||||||
DNSSettingsCorrect=False
|
DNSSettingsCorrect=False
|
||||||
;;
|
;;
|
||||||
"${DIALOG_ESC}")
|
"${DIALOG_ESC}")
|
||||||
printf " %b Escape pressed, exiting installer at DNS Settings%b\\n" "${COL_RED}" "${COL_NC}"
|
printf " %b Escape pressed, exiting installer at DNS Settings%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -961,7 +915,7 @@ If you want to specify a port other than 53, separate it with a hash.\
|
|||||||
done
|
done
|
||||||
else
|
else
|
||||||
# Save the old Internal Field Separator in a variable,
|
# Save the old Internal Field Separator in a variable,
|
||||||
OIFS=${IFS}
|
OIFS=$IFS
|
||||||
# and set the new one to newline
|
# and set the new one to newline
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for DNSServer in ${DNS_SERVERS}; do
|
for DNSServer in ${DNS_SERVERS}; do
|
||||||
@@ -1004,7 +958,7 @@ setLogging() {
|
|||||||
;;
|
;;
|
||||||
"${DIALOG_ESC}")
|
"${DIALOG_ESC}")
|
||||||
# User pressed <ESC>
|
# User pressed <ESC>
|
||||||
printf " %b Escape pressed, exiting installer at Query Logging choice.%b\\n" "${COL_RED}" "${COL_NC}"
|
printf " %b Escape pressed, exiting installer at Query Logging choice.%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -1029,7 +983,7 @@ setPrivacyLevel() {
|
|||||||
printf " %b Using privacy level: %s\\n" "${INFO}" "${PRIVACY_LEVEL}"
|
printf " %b Using privacy level: %s\\n" "${INFO}" "${PRIVACY_LEVEL}"
|
||||||
;;
|
;;
|
||||||
"${DIALOG_CANCEL}" | "${DIALOG_ESC}")
|
"${DIALOG_CANCEL}" | "${DIALOG_ESC}")
|
||||||
printf " %b Cancelled privacy level selection.%b\\n" "${COL_RED}" "${COL_NC}"
|
printf " %b Cancelled privacy level selection.%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -1063,7 +1017,7 @@ chooseBlocklists() {
|
|||||||
;;
|
;;
|
||||||
"${DIALOG_ESC}")
|
"${DIALOG_ESC}")
|
||||||
# User pressed <ESC>
|
# User pressed <ESC>
|
||||||
printf " %b Escape pressed, exiting installer at blocklist choice.%b\\n" "${COL_RED}" "${COL_NC}"
|
printf " %b Escape pressed, exiting installer at blocklist choice.%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -1183,14 +1137,13 @@ installScripts() {
|
|||||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./automated\ install/uninstall.sh
|
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./automated\ install/uninstall.sh
|
||||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE
|
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE
|
||||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_BIN_DIR}" pihole
|
install -o "${USER}" -Dm755 -t "${PI_HOLE_BIN_DIR}" pihole
|
||||||
install -Dm644 ./advanced/bash-completion/pihole.bash /etc/bash_completion.d/pihole
|
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||||
install -Dm644 ./advanced/bash-completion/pihole-ftl.bash /etc/bash_completion.d/pihole-FTL
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
|
|
||||||
else
|
else
|
||||||
# Otherwise, show an error and exit
|
# Otherwise, show an error and exit
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf "\\t\\t%bError: Local repo %s not found, exiting installer%b\\n" "${COL_RED}" "${PI_HOLE_LOCAL_REPO}" "${COL_NC}"
|
printf "\\t\\t%bError: Local repo %s not found, exiting installer%b\\n" "${COL_LIGHT_RED}" "${PI_HOLE_LOCAL_REPO}" "${COL_NC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -1205,13 +1158,13 @@ installConfigs() {
|
|||||||
# Install empty custom.list file if it does not exist
|
# Install empty custom.list file if it does not exist
|
||||||
if [[ ! -r "${PI_HOLE_CONFIG_DIR}/hosts/custom.list" ]]; then
|
if [[ ! -r "${PI_HOLE_CONFIG_DIR}/hosts/custom.list" ]]; then
|
||||||
if ! install -D -T -o pihole -g pihole -m 660 /dev/null "${PI_HOLE_CONFIG_DIR}/hosts/custom.list" &>/dev/null; then
|
if ! install -D -T -o pihole -g pihole -m 660 /dev/null "${PI_HOLE_CONFIG_DIR}/hosts/custom.list" &>/dev/null; then
|
||||||
printf " %b Error: Unable to initialize configuration file %s/custom.list\\n" "${COL_RED}" "${PI_HOLE_CONFIG_DIR}/hosts"
|
printf " %b Error: Unable to initialize configuration file %s/custom.list\\n" "${COL_LIGHT_RED}" "${PI_HOLE_CONFIG_DIR}/hosts"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install pihole-FTL systemd or init.d service, based on whether systemd is the init system or not
|
# Install pihole-FTL systemd or init.d service, based on whether systemd is the init system or not
|
||||||
if ps -p 1 -o comm= | grep -q systemd; then
|
if is_pid1 systemd; then
|
||||||
install -T -m 0644 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.systemd" '/etc/systemd/system/pihole-FTL.service'
|
install -T -m 0644 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.systemd" '/etc/systemd/system/pihole-FTL.service'
|
||||||
|
|
||||||
# Remove init.d service if present
|
# Remove init.d service if present
|
||||||
@@ -1223,12 +1176,7 @@ installConfigs() {
|
|||||||
# Load final service
|
# Load final service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
else
|
else
|
||||||
local INIT="service"
|
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.service" '/etc/init.d/pihole-FTL'
|
||||||
if is_command openrc; then
|
|
||||||
INIT="openrc"
|
|
||||||
fi
|
|
||||||
|
|
||||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.${INIT}" '/etc/init.d/pihole-FTL'
|
|
||||||
fi
|
fi
|
||||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL-prestart.sh" "${PI_HOLE_INSTALL_DIR}/pihole-FTL-prestart.sh"
|
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL-prestart.sh" "${PI_HOLE_INSTALL_DIR}/pihole-FTL-prestart.sh"
|
||||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL-poststop.sh" "${PI_HOLE_INSTALL_DIR}/pihole-FTL-poststop.sh"
|
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL-poststop.sh" "${PI_HOLE_INSTALL_DIR}/pihole-FTL-poststop.sh"
|
||||||
@@ -1284,9 +1232,12 @@ stop_service() {
|
|||||||
# Can softfail, as process may not be installed when this is called
|
# Can softfail, as process may not be installed when this is called
|
||||||
local str="Stopping ${1} service"
|
local str="Stopping ${1} service"
|
||||||
printf " %b %s..." "${INFO}" "${str}"
|
printf " %b %s..." "${INFO}" "${str}"
|
||||||
if is_command systemctl; then
|
# If systemd is PID 1,
|
||||||
|
if is_pid1 systemd; then
|
||||||
|
# use that to restart the service
|
||||||
systemctl -q stop "${1}" || true
|
systemctl -q stop "${1}" || true
|
||||||
else
|
else
|
||||||
|
# Otherwise, fall back to the service command
|
||||||
service "${1}" stop >/dev/null || true
|
service "${1}" stop >/dev/null || true
|
||||||
fi
|
fi
|
||||||
printf "%b %b %s...\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s...\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
@@ -1297,8 +1248,8 @@ restart_service() {
|
|||||||
# Local, named variables
|
# Local, named variables
|
||||||
local str="Restarting ${1} service"
|
local str="Restarting ${1} service"
|
||||||
printf " %b %s..." "${INFO}" "${str}"
|
printf " %b %s..." "${INFO}" "${str}"
|
||||||
# If systemctl exists,
|
# If systemd is PID 1,
|
||||||
if is_command systemctl; then
|
if is_pid1 systemd; then
|
||||||
# use that to restart the service
|
# use that to restart the service
|
||||||
systemctl -q restart "${1}"
|
systemctl -q restart "${1}"
|
||||||
else
|
else
|
||||||
@@ -1313,12 +1264,10 @@ enable_service() {
|
|||||||
# Local, named variables
|
# Local, named variables
|
||||||
local str="Enabling ${1} service to start on reboot"
|
local str="Enabling ${1} service to start on reboot"
|
||||||
printf " %b %s..." "${INFO}" "${str}"
|
printf " %b %s..." "${INFO}" "${str}"
|
||||||
# If systemctl exists,
|
# If systemd is PID1,
|
||||||
if is_command systemctl; then
|
if is_pid1 systemd; then
|
||||||
# use that to enable the service
|
# use that to enable the service
|
||||||
systemctl -q enable "${1}"
|
systemctl -q enable "${1}"
|
||||||
elif is_command openrc; then
|
|
||||||
rc-update add "${1}" "${2:-default}" &> /dev/null
|
|
||||||
else
|
else
|
||||||
# Otherwise, use update-rc.d to accomplish this
|
# Otherwise, use update-rc.d to accomplish this
|
||||||
update-rc.d "${1}" defaults >/dev/null
|
update-rc.d "${1}" defaults >/dev/null
|
||||||
@@ -1331,13 +1280,10 @@ disable_service() {
|
|||||||
# Local, named variables
|
# Local, named variables
|
||||||
local str="Disabling ${1} service"
|
local str="Disabling ${1} service"
|
||||||
printf " %b %s..." "${INFO}" "${str}"
|
printf " %b %s..." "${INFO}" "${str}"
|
||||||
# If systemctl exists,
|
# If systemd is PID1,
|
||||||
if is_command systemctl; then
|
if is_pid1 systemd; then
|
||||||
# use that to disable the service
|
# use that to disable the service
|
||||||
systemctl -q disable --now "${1}"
|
systemctl -q disable "${1}"
|
||||||
elif is_command openrc; then
|
|
||||||
rc-update del "${1}" "${2:-default}" &> /dev/null
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# Otherwise, use update-rc.d to accomplish this
|
# Otherwise, use update-rc.d to accomplish this
|
||||||
update-rc.d "${1}" disable >/dev/null
|
update-rc.d "${1}" disable >/dev/null
|
||||||
@@ -1346,12 +1292,10 @@ disable_service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_service_active() {
|
check_service_active() {
|
||||||
# If systemctl exists,
|
# If systemd is PID1,
|
||||||
if is_command systemctl; then
|
if is_pid1 systemd; then
|
||||||
# use that to check the status of the service
|
# use that to check the status of the service
|
||||||
systemctl -q is-enabled "${1}" 2>/dev/null
|
systemctl -q is-enabled "${1}" 2>/dev/null
|
||||||
elif is_command openrc; then
|
|
||||||
rc-status default boot | grep -q "${1}"
|
|
||||||
else
|
else
|
||||||
# Otherwise, fall back to service command
|
# Otherwise, fall back to service command
|
||||||
service "${1}" status &>/dev/null
|
service "${1}" status &>/dev/null
|
||||||
@@ -1396,7 +1340,7 @@ update_package_cache() {
|
|||||||
UPDATE_PKG_CACHE="apt update"
|
UPDATE_PKG_CACHE="apt update"
|
||||||
fi
|
fi
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf " %b Error: Unable to update package cache. Please try \"%s\"%b\\n" "${COL_RED}" "sudo ${UPDATE_PKG_CACHE}" "${COL_NC}"
|
printf " %b Error: Unable to update package cache. Please try \"%s\"%b\\n" "${COL_LIGHT_RED}" "sudo ${UPDATE_PKG_CACHE}" "${COL_NC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -1414,7 +1358,7 @@ notify_package_updates_available() {
|
|||||||
printf "%b %b %s... up to date!\\n\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s... up to date!\\n\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
else
|
else
|
||||||
printf "%b %b %s... %s updates available\\n" "${OVER}" "${TICK}" "${str}" "${updatesToInstall}"
|
printf "%b %b %s... %s updates available\\n" "${OVER}" "${TICK}" "${str}" "${updatesToInstall}"
|
||||||
printf " %b %bIt is recommended to update your OS after installing the Pi-hole!%b\\n\\n" "${INFO}" "${COL_GREEN}" "${COL_NC}"
|
printf " %b %bIt is recommended to update your OS after installing the Pi-hole!%b\\n\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1431,11 +1375,11 @@ install_dependent_packages() {
|
|||||||
rm /tmp/pihole-meta.deb
|
rm /tmp/pihole-meta.deb
|
||||||
else
|
else
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_RED}"
|
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_RED}"
|
printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Install Fedora/CentOS packages
|
# Install Fedora/CentOS packages
|
||||||
@@ -1446,34 +1390,15 @@ install_dependent_packages() {
|
|||||||
rm /tmp/pihole-meta.rpm
|
rm /tmp/pihole-meta.rpm
|
||||||
else
|
else
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_RED}"
|
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_RED}"
|
printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Install Alpine packages
|
|
||||||
elif is_command apk; then
|
|
||||||
local repo_str="Ensuring alpine 'community' repo is enabled."
|
|
||||||
printf "%b %b %s" "${OVER}" "${INFO}" "${repo_str}"
|
|
||||||
|
|
||||||
local pattern='^\s*#(.*/community/?)\s*$'
|
# If neither apt-get or yum/dnf package managers were found
|
||||||
sed -Ei "s:${pattern}:\1:" /etc/apk/repositories
|
|
||||||
if grep -Eq "${pattern}" /etc/apk/repositories; then
|
|
||||||
# Repo still commented out = Failure
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${repo_str}"
|
|
||||||
else
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${repo_str}"
|
|
||||||
fi
|
|
||||||
printf " %b %s..." "${INFO}" "${str}"
|
|
||||||
if { ${PKG_INSTALL} -q -t "pihole-meta=${PIHOLE_META_VERSION_APK}" "${PIHOLE_META_DEPS_APK[@]}" &>/dev/null; }; then
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
|
||||||
else
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
|
||||||
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_RED}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# we cannot install the dependency package
|
# we cannot install the dependency package
|
||||||
printf " %b No supported package manager found\\n" "${CROSS}"
|
printf " %b No supported package manager found\\n" "${CROSS}"
|
||||||
@@ -1498,15 +1423,6 @@ installCron() {
|
|||||||
# Randomize update checker time
|
# Randomize update checker time
|
||||||
sed -i "s/59 17/$((1 + RANDOM % 58)) $((12 + RANDOM % 8))/" /etc/cron.d/pihole
|
sed -i "s/59 17/$((1 + RANDOM % 58)) $((12 + RANDOM % 8))/" /etc/cron.d/pihole
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
|
|
||||||
# Switch off of busybox cron on alpine
|
|
||||||
if is_command openrc; then
|
|
||||||
printf " %b Switching from busybox crond to cronie...\\n" "${INFO}"
|
|
||||||
stop_service crond
|
|
||||||
disable_service crond
|
|
||||||
enable_service cronie
|
|
||||||
restart_service cronie
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Gravity is a very important script as it aggregates all of the domains into a single HOSTS formatted list,
|
# Gravity is a very important script as it aggregates all of the domains into a single HOSTS formatted list,
|
||||||
@@ -1556,7 +1472,7 @@ create_pihole_user() {
|
|||||||
# then create and add her to the pihole group
|
# then create and add her to the pihole group
|
||||||
local str="Creating user 'pihole'"
|
local str="Creating user 'pihole'"
|
||||||
printf "%b %b %s..." "${OVER}" "${INFO}" "${str}"
|
printf "%b %b %s..." "${OVER}" "${INFO}" "${str}"
|
||||||
if useradd -r --no-user-group -g pihole -s "$(command -v nologin)" pihole; then
|
if useradd -r --no-user-group -g pihole -s /usr/sbin/nologin pihole; then
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
else
|
else
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
@@ -1571,7 +1487,7 @@ create_pihole_user() {
|
|||||||
# create and add pihole user to the pihole group
|
# create and add pihole user to the pihole group
|
||||||
local str="Creating user 'pihole'"
|
local str="Creating user 'pihole'"
|
||||||
printf "%b %b %s..." "${OVER}" "${INFO}" "${str}"
|
printf "%b %b %s..." "${OVER}" "${INFO}" "${str}"
|
||||||
if useradd -r --no-user-group -g pihole -s "$(command -v nologin)" pihole; then
|
if useradd -r --no-user-group -g pihole -s /usr/sbin/nologin pihole; then
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
else
|
else
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
@@ -1707,13 +1623,13 @@ checkSelinux() {
|
|||||||
if [[ "${SELINUX_ENFORCING}" -eq 1 ]] && [[ -z "${PIHOLE_SELINUX}" ]]; then
|
if [[ "${SELINUX_ENFORCING}" -eq 1 ]] && [[ -z "${PIHOLE_SELINUX}" ]]; then
|
||||||
printf " Pi-hole does not provide an SELinux policy as the required changes modify the security of your system.\\n"
|
printf " Pi-hole does not provide an SELinux policy as the required changes modify the security of your system.\\n"
|
||||||
printf " Please refer to https://wiki.centos.org/HowTos/SELinux if SELinux is required for your deployment.\\n"
|
printf " Please refer to https://wiki.centos.org/HowTos/SELinux if SELinux is required for your deployment.\\n"
|
||||||
printf " This check can be skipped by setting the environment variable %bPIHOLE_SELINUX%b to %btrue%b\\n" "${COL_RED}" "${COL_NC}" "${COL_RED}" "${COL_NC}"
|
printf " This check can be skipped by setting the environment variable %bPIHOLE_SELINUX%b to %btrue%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
printf " e.g: export PIHOLE_SELINUX=true\\n"
|
printf " e.g: export PIHOLE_SELINUX=true\\n"
|
||||||
printf " By setting this variable to true you acknowledge there may be issues with Pi-hole during or after the install\\n"
|
printf " By setting this variable to true you acknowledge there may be issues with Pi-hole during or after the install\\n"
|
||||||
printf "\\n %bSELinux Enforcing detected, exiting installer%b\\n" "${COL_RED}" "${COL_NC}"
|
printf "\\n %bSELinux Enforcing detected, exiting installer%b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "${SELINUX_ENFORCING}" -eq 1 ]] && [[ -n "${PIHOLE_SELINUX}" ]]; then
|
elif [[ "${SELINUX_ENFORCING}" -eq 1 ]] && [[ -n "${PIHOLE_SELINUX}" ]]; then
|
||||||
printf " %b %bSELinux Enforcing detected%b. PIHOLE_SELINUX env variable set - installer will continue\\n" "${INFO}" "${COL_RED}" "${COL_NC}"
|
printf " %b %bSELinux Enforcing detected%b. PIHOLE_SELINUX env variable set - installer will continue\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1723,9 +1639,9 @@ check_download_exists() {
|
|||||||
status=$(curl --head --silent "https://ftl.pi-hole.net/${1}" | head -n 1)
|
status=$(curl --head --silent "https://ftl.pi-hole.net/${1}" | head -n 1)
|
||||||
|
|
||||||
# Check the status code
|
# Check the status code
|
||||||
if grep -q "200" <<<"${status}"; then
|
if grep -q "200" <<<"$status"; then
|
||||||
return 0
|
return 0
|
||||||
elif grep -q "404" <<<"${status}"; then
|
elif grep -q "404" <<<"$status"; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1758,7 +1674,7 @@ get_available_branches() {
|
|||||||
# Get reachable remote branches, but store STDERR as STDOUT variable
|
# Get reachable remote branches, but store STDERR as STDOUT variable
|
||||||
output=$({ git ls-remote --heads --quiet | cut -d'/' -f3- -; } 2>&1)
|
output=$({ git ls-remote --heads --quiet | cut -d'/' -f3- -; } 2>&1)
|
||||||
# echo status for calling function to capture
|
# echo status for calling function to capture
|
||||||
echo "${output}"
|
echo "$output"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1791,9 +1707,9 @@ checkout_pull_branch() {
|
|||||||
oldbranch="$(git symbolic-ref HEAD)"
|
oldbranch="$(git symbolic-ref HEAD)"
|
||||||
|
|
||||||
str="Switching to branch: '${branch}' from '${oldbranch}'"
|
str="Switching to branch: '${branch}' from '${oldbranch}'"
|
||||||
printf " %b %s" "${INFO}" "${str}"
|
printf " %b %s" "${INFO}" "$str"
|
||||||
git checkout "${branch}" --quiet || return 1
|
git checkout "${branch}" --quiet || return 1
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "$str"
|
||||||
# Data in the repositories is public anyway so we can make it readable by everyone (+r to keep executable permission if already set by git)
|
# Data in the repositories is public anyway so we can make it readable by everyone (+r to keep executable permission if already set by git)
|
||||||
chmod -R a+rX "${directory}"
|
chmod -R a+rX "${directory}"
|
||||||
|
|
||||||
@@ -1811,13 +1727,13 @@ clone_or_reset_repos() {
|
|||||||
# Reset the Core repo
|
# Reset the Core repo
|
||||||
resetRepo ${PI_HOLE_LOCAL_REPO} ||
|
resetRepo ${PI_HOLE_LOCAL_REPO} ||
|
||||||
{
|
{
|
||||||
printf " %b Unable to reset %s, exiting installer%b\\n" "${COL_RED}" "${PI_HOLE_LOCAL_REPO}" "${COL_NC}"
|
printf " %b Unable to reset %s, exiting installer%b\\n" "${COL_LIGHT_RED}" "${PI_HOLE_LOCAL_REPO}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
# Reset the Web repo
|
# Reset the Web repo
|
||||||
resetRepo ${webInterfaceDir} ||
|
resetRepo ${webInterfaceDir} ||
|
||||||
{
|
{
|
||||||
printf " %b Unable to reset %s, exiting installer%b\\n" "${COL_RED}" "${webInterfaceDir}" "${COL_NC}"
|
printf " %b Unable to reset %s, exiting installer%b\\n" "${COL_LIGHT_RED}" "${webInterfaceDir}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
# Otherwise, a fresh installation is happening
|
# Otherwise, a fresh installation is happening
|
||||||
@@ -1825,13 +1741,13 @@ clone_or_reset_repos() {
|
|||||||
# so get git files for Core
|
# so get git files for Core
|
||||||
getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} ||
|
getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} ||
|
||||||
{
|
{
|
||||||
printf " %b Unable to clone %s into %s, unable to continue%b\\n" "${COL_RED}" "${piholeGitUrl}" "${PI_HOLE_LOCAL_REPO}" "${COL_NC}"
|
printf " %b Unable to clone %s into %s, unable to continue%b\\n" "${COL_LIGHT_RED}" "${piholeGitUrl}" "${PI_HOLE_LOCAL_REPO}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
# get the Web git files
|
# get the Web git files
|
||||||
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} ||
|
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl} ||
|
||||||
{
|
{
|
||||||
printf " %b Unable to clone %s into ${webInterfaceDir}, exiting installer%b\\n" "${COL_RED}" "${webInterfaceGitUrl}" "${COL_NC}"
|
printf " %b Unable to clone %s into ${webInterfaceDir}, exiting installer%b\\n" "${COL_LIGHT_RED}" "${webInterfaceGitUrl}" "${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
@@ -1881,12 +1797,8 @@ FTLinstall() {
|
|||||||
# Before stopping FTL, we download the macvendor database
|
# Before stopping FTL, we download the macvendor database
|
||||||
curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFIG_DIR}/macvendor.db" || true
|
curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFIG_DIR}/macvendor.db" || true
|
||||||
|
|
||||||
|
# Stop pihole-FTL service if available
|
||||||
# If the binary already exists in /usr/bin, then we need to stop the service
|
|
||||||
# If the binary does not exist (fresh installs), then we can skip this step.
|
|
||||||
if [[ -f /usr/bin/pihole-FTL ]]; then
|
|
||||||
stop_service pihole-FTL >/dev/null
|
stop_service pihole-FTL >/dev/null
|
||||||
fi
|
|
||||||
|
|
||||||
# Install the new version with the correct permissions
|
# Install the new version with the correct permissions
|
||||||
install -T -m 0755 "${binary}" /usr/bin/pihole-FTL
|
install -T -m 0755 "${binary}" /usr/bin/pihole-FTL
|
||||||
@@ -1911,7 +1823,7 @@ FTLinstall() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf " %b Error: Download of %s/%s failed (checksum error)%b\\n" "${COL_RED}" "${url}" "${binary}" "${COL_NC}"
|
printf " %b Error: Download of %s/%s failed (checksum error)%b\\n" "${COL_LIGHT_RED}" "${url}" "${binary}" "${COL_NC}"
|
||||||
|
|
||||||
# Remove temp dir
|
# Remove temp dir
|
||||||
remove_dir "${tempdir}"
|
remove_dir "${tempdir}"
|
||||||
@@ -1925,7 +1837,7 @@ FTLinstall() {
|
|||||||
}
|
}
|
||||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
# The URL could not be found
|
# The URL could not be found
|
||||||
printf " %b Error: URL %s/%s not found%b\\n" "${COL_RED}" "${url}" "${binary}" "${COL_NC}"
|
printf " %b Error: URL %s/%s not found%b\\n" "${COL_LIGHT_RED}" "${url}" "${binary}" "${COL_NC}"
|
||||||
|
|
||||||
# Remove temp dir
|
# Remove temp dir
|
||||||
remove_dir "${tempdir}"
|
remove_dir "${tempdir}"
|
||||||
@@ -2000,9 +1912,9 @@ get_binary_name() {
|
|||||||
l_binary="pihole-FTL-riscv64"
|
l_binary="pihole-FTL-riscv64"
|
||||||
else
|
else
|
||||||
# Something else - we try to use 32bit executable and warn the user
|
# Something else - we try to use 32bit executable and warn the user
|
||||||
if [[ "${machine}" != "i686" ]]; then
|
if [[ ! "${machine}" == "i686" ]]; then
|
||||||
printf "%b %b %s...\\n" "${OVER}" "${CROSS}" "${str}"
|
printf "%b %b %s...\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
printf " %b %bNot able to detect architecture (unknown: %s), trying x86 (32bit) executable%b\\n" "${INFO}" "${COL_RED}" "${machine}" "${COL_NC}"
|
printf " %b %bNot able to detect architecture (unknown: %s), trying x86 (32bit) executable%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${machine}" "${COL_NC}"
|
||||||
printf " %b Contact Pi-hole Support if you experience issues (e.g: FTL not running)\\n" "${INFO}"
|
printf " %b Contact Pi-hole Support if you experience issues (e.g: FTL not running)\\n" "${INFO}"
|
||||||
else
|
else
|
||||||
printf "%b %b Detected 32bit (i686) architecture\\n" "${OVER}" "${TICK}"
|
printf "%b %b Detected 32bit (i686) architecture\\n" "${OVER}" "${TICK}"
|
||||||
@@ -2034,18 +1946,18 @@ FTLcheckUpdate() {
|
|||||||
local remoteSha1
|
local remoteSha1
|
||||||
local localSha1
|
local localSha1
|
||||||
|
|
||||||
if [[ "${ftlBranch}" != "master" ]]; then
|
if [[ ! "${ftlBranch}" == "master" ]]; then
|
||||||
# This is not the master branch
|
# This is not the master branch
|
||||||
local path
|
local path
|
||||||
path="${ftlBranch}/${binary}"
|
path="${ftlBranch}/${binary}"
|
||||||
|
|
||||||
# Check whether or not the binary for this FTL branch actually exists. If not, then there is no update!
|
# Check whether or not the binary for this FTL branch actually exists. If not, then there is no update!
|
||||||
|
if ! check_download_exists "$path"; then
|
||||||
local status
|
local status
|
||||||
if ! check_download_exists "${path}"; then
|
|
||||||
status=$?
|
status=$?
|
||||||
if [ "${status}" -eq 1 ]; then
|
if [ "${status}" -eq 1 ]; then
|
||||||
printf " %b Branch \"%s\" is not available.\\n" "${INFO}" "${ftlBranch}"
|
printf " %b Branch \"%s\" is not available.\\n" "${INFO}" "${ftlBranch}"
|
||||||
printf " %b Use %bpihole checkout ftl [branchname]%b to switch to a valid branch.\\n" "${INFO}" "${COL_GREEN}" "${COL_NC}"
|
printf " %b Use %bpihole checkout ftl [branchname]%b to switch to a valid branch.\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
||||||
elif [ "${status}" -eq 2 ]; then
|
elif [ "${status}" -eq 2 ]; then
|
||||||
printf " %b Unable to download from ftl.pi-hole.net. Please check your Internet connection and try again later.\\n" "${CROSS}"
|
printf " %b Unable to download from ftl.pi-hole.net. Please check your Internet connection and try again later.\\n" "${CROSS}"
|
||||||
return 3
|
return 3
|
||||||
@@ -2131,11 +2043,6 @@ FTLdetect() {
|
|||||||
|
|
||||||
if FTLcheckUpdate "${1}"; then
|
if FTLcheckUpdate "${1}"; then
|
||||||
FTLinstall "${1}" || return 1
|
FTLinstall "${1}" || return 1
|
||||||
else
|
|
||||||
case $? in
|
|
||||||
1) :;; # FTL is up-to-date
|
|
||||||
*) exit 1;; # 404 (2), other HTTP or curl error (3), unknown (4)
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2144,11 +2051,11 @@ make_temporary_log() {
|
|||||||
TEMPLOG=$(mktemp /tmp/pihole_temp.XXXXXX)
|
TEMPLOG=$(mktemp /tmp/pihole_temp.XXXXXX)
|
||||||
# Open handle 3 for templog
|
# Open handle 3 for templog
|
||||||
# https://stackoverflow.com/questions/18460186/writing-outputs-to-log-file-and-console
|
# https://stackoverflow.com/questions/18460186/writing-outputs-to-log-file-and-console
|
||||||
exec 3>"${TEMPLOG}"
|
exec 3>"$TEMPLOG"
|
||||||
# Delete templog, but allow for addressing via file handle
|
# Delete templog, but allow for addressing via file handle
|
||||||
# This lets us write to the log without having a temporary file on the drive, which
|
# This lets us write to the log without having a temporary file on the drive, which
|
||||||
# is meant to be a security measure so there is not a lingering file on the drive during the install process
|
# is meant to be a security measure so there is not a lingering file on the drive during the install process
|
||||||
rm "${TEMPLOG}"
|
rm "$TEMPLOG"
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_to_install_log() {
|
copy_to_install_log() {
|
||||||
@@ -2263,7 +2170,7 @@ main() {
|
|||||||
else
|
else
|
||||||
# Otherwise, they do not have enough privileges, so let the user know
|
# Otherwise, they do not have enough privileges, so let the user know
|
||||||
printf " %b %s\\n" "${INFO}" "${str}"
|
printf " %b %s\\n" "${INFO}" "${str}"
|
||||||
printf " %b %bScript called with non-root privileges%b\\n" "${INFO}" "${COL_RED}" "${COL_NC}"
|
printf " %b %bScript called with non-root privileges%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
printf " The Pi-hole requires elevated privileges to install and run\\n"
|
printf " The Pi-hole requires elevated privileges to install and run\\n"
|
||||||
printf " Please check the installer for any concerns regarding this requirement\\n"
|
printf " Please check the installer for any concerns regarding this requirement\\n"
|
||||||
printf " Make sure to download this script from a trusted source\\n\\n"
|
printf " Make sure to download this script from a trusted source\\n\\n"
|
||||||
@@ -2287,7 +2194,7 @@ main() {
|
|||||||
# Otherwise, tell the user they need to run the script as root, and bail
|
# Otherwise, tell the user they need to run the script as root, and bail
|
||||||
printf "%b %b Sudo utility check\\n" "${OVER}" "${CROSS}"
|
printf "%b %b Sudo utility check\\n" "${OVER}" "${CROSS}"
|
||||||
printf " %b Sudo is needed for the Web Interface to run pihole commands\\n\\n" "${INFO}"
|
printf " %b Sudo is needed for the Web Interface to run pihole commands\\n\\n" "${INFO}"
|
||||||
printf " %b %bPlease re-run this installer as root${COL_NC}\\n" "${INFO}" "${COL_RED}"
|
printf " %b %bPlease re-run this installer as root${COL_NC}\\n" "${INFO}" "${COL_LIGHT_RED}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -2298,17 +2205,9 @@ main() {
|
|||||||
# Check for availability of either the "service" or "systemctl" commands
|
# Check for availability of either the "service" or "systemctl" commands
|
||||||
check_service_command
|
check_service_command
|
||||||
|
|
||||||
# Check if this is a fresh install or an update/repair
|
|
||||||
check_fresh_install
|
|
||||||
|
|
||||||
# Check for supported package managers so that we may install dependencies
|
# Check for supported package managers so that we may install dependencies
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
|
|
||||||
# Update package cache only on apt based systems
|
|
||||||
if is_command apt-get; then
|
|
||||||
update_package_cache || exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Notify user of package availability
|
# Notify user of package availability
|
||||||
notify_package_updates_available
|
notify_package_updates_available
|
||||||
|
|
||||||
@@ -2329,7 +2228,10 @@ main() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${fresh_install}" == false ]]; then
|
# in case of an update (can be a v5 -> v6 or v6 -> v6 update) or repair
|
||||||
|
if [[ -f "${PI_HOLE_V6_CONFIG}" ]] || [[ -f "/etc/pihole/setupVars.conf" ]]; then
|
||||||
|
# retain settings
|
||||||
|
fresh_install=false
|
||||||
# if it's running unattended,
|
# if it's running unattended,
|
||||||
if [[ "${runUnattended}" == true ]]; then
|
if [[ "${runUnattended}" == true ]]; then
|
||||||
printf " %b Performing unattended setup, no dialogs will be displayed\\n" "${INFO}"
|
printf " %b Performing unattended setup, no dialogs will be displayed\\n" "${INFO}"
|
||||||
@@ -2438,7 +2340,7 @@ main() {
|
|||||||
if [ -n "${PIHOLE_DNS_1}" ]; then
|
if [ -n "${PIHOLE_DNS_1}" ]; then
|
||||||
local string="\"${PIHOLE_DNS_1}\""
|
local string="\"${PIHOLE_DNS_1}\""
|
||||||
[ -n "${PIHOLE_DNS_2}" ] && string+=", \"${PIHOLE_DNS_2}\""
|
[ -n "${PIHOLE_DNS_2}" ] && string+=", \"${PIHOLE_DNS_2}\""
|
||||||
setFTLConfigValue "dns.upstreams" "[ ${string} ]"
|
setFTLConfigValue "dns.upstreams" "[ $string ]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${QUERY_LOGGING}" ]; then
|
if [ -n "${QUERY_LOGGING}" ]; then
|
||||||
@@ -2477,10 +2379,8 @@ main() {
|
|||||||
printf " %b If you have not done so already, the above IP should be set to static.\\n" "${INFO}"
|
printf " %b If you have not done so already, the above IP should be set to static.\\n" "${INFO}"
|
||||||
|
|
||||||
printf " %b View the web interface at http://pi.hole:${WEBPORT}/admin or http://%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}:${WEBPORT}"
|
printf " %b View the web interface at http://pi.hole:${WEBPORT}/admin or http://%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}:${WEBPORT}"
|
||||||
printf " %b Web Interface password: %b%s%b\\n" "${INFO}" "${COL_GREEN}" "${pw}" "${COL_NC}"
|
printf " %b Web Interface password: %b%s%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${pw}" "${COL_NC}"
|
||||||
printf " %b This can be changed using 'pihole setpassword'\\n\\n" "${INFO}"
|
printf " %b This can be changed using 'pihole setpassword'\\n\\n" "${INFO}"
|
||||||
printf " %b To allow your user to use all CLI functions without authentication, refer to\\n" "${INFO}"
|
|
||||||
printf " our documentation at: https://docs.pi-hole.net/main/post-install/\\n\\n"
|
|
||||||
|
|
||||||
# Final dialog message to the user
|
# Final dialog message to the user
|
||||||
dialog --no-shadow --keep-tite \
|
dialog --no-shadow --keep-tite \
|
||||||
@@ -2489,11 +2389,7 @@ main() {
|
|||||||
\\n\\nIPv4: ${IPV4_ADDRESS%/*}\
|
\\n\\nIPv4: ${IPV4_ADDRESS%/*}\
|
||||||
\\nIPv6: ${IPV6_ADDRESS:-"Not Configured"}\
|
\\nIPv6: ${IPV6_ADDRESS:-"Not Configured"}\
|
||||||
\\nIf you have not done so already, the above IP should be set to static.\
|
\\nIf you have not done so already, the above IP should be set to static.\
|
||||||
\\nView the web interface at http://pi.hole:${WEBPORT}/admin or http://${IPV4_ADDRESS%/*}:${WEBPORT}/admin\\n\\nYour Admin Webpage login password is ${pw}\
|
\\nView the web interface at http://pi.hole/admin:${WEBPORT} or http://${IPV4_ADDRESS%/*}:${WEBPORT}/admin\\n\\nYour Admin Webpage login password is ${pw}" "${r}" "${c}"
|
||||||
\\n
|
|
||||||
\\n
|
|
||||||
\\nTo allow your user to use all CLI functions without authentication,\
|
|
||||||
\\nrefer to https://docs.pi-hole.net/main/post-install/" "${r}" "${c}"
|
|
||||||
|
|
||||||
INSTALL_TYPE="Installation"
|
INSTALL_TYPE="Installation"
|
||||||
else
|
else
|
||||||
@@ -2502,7 +2398,7 @@ main() {
|
|||||||
|
|
||||||
# Display where the log file is
|
# Display where the log file is
|
||||||
printf "\\n %b The install log is located at: %s\\n" "${INFO}" "${installLogLoc}"
|
printf "\\n %b The install log is located at: %s\\n" "${INFO}" "${installLogLoc}"
|
||||||
printf " %b %b%s complete! %b\\n" "${TICK}" "${COL_GREEN}" "${INSTALL_TYPE}" "${COL_NC}"
|
printf " %b %b%s complete! %b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${INSTALL_TYPE}" "${COL_NC}"
|
||||||
|
|
||||||
if [[ "${INSTALL_TYPE}" == "Update" ]]; then
|
if [[ "${INSTALL_TYPE}" == "Update" ]]; then
|
||||||
printf "\\n"
|
printf "\\n"
|
||||||
|
|||||||
@@ -12,13 +12,15 @@
|
|||||||
source "/opt/pihole/COL_TABLE"
|
source "/opt/pihole/COL_TABLE"
|
||||||
# shellcheck source="./advanced/Scripts/utils.sh"
|
# shellcheck source="./advanced/Scripts/utils.sh"
|
||||||
source "/opt/pihole/utils.sh"
|
source "/opt/pihole/utils.sh"
|
||||||
# getFTLConfigValue() from utils.sh
|
|
||||||
|
ADMIN_INTERFACE_DIR=$(getFTLConfigValue "webserver.paths.webroot")$(getFTLConfigValue "webserver.paths.webhome")
|
||||||
|
readonly ADMIN_INTERFACE_DIR
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
read -rp " ${QST} Are you sure you would like to remove ${COL_BOLD}Pi-hole${COL_NC}? [y/N] " answer
|
read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " answer
|
||||||
case ${answer} in
|
case ${answer} in
|
||||||
[Yy]* ) break;;
|
[Yy]* ) break;;
|
||||||
* ) echo -e "${OVER} ${COL_GREEN}Uninstall has been canceled${COL_NC}"; exit 0;;
|
* ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been canceled${COL_NC}"; exit 0;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -27,200 +29,130 @@ str="Root user check"
|
|||||||
if [[ ${EUID} -eq 0 ]]; then
|
if [[ ${EUID} -eq 0 ]]; then
|
||||||
echo -e " ${TICK} ${str}"
|
echo -e " ${TICK} ${str}"
|
||||||
else
|
else
|
||||||
|
# Check if sudo is actually installed
|
||||||
|
# If it isn't, exit because the uninstall can not complete
|
||||||
|
if [ -x "$(command -v sudo)" ]; then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
echo -e " ${CROSS} ${str}
|
echo -e " ${CROSS} ${str}
|
||||||
Script called with non-root privileges
|
Script called with non-root privileges
|
||||||
The Pi-hole requires elevated privileges to uninstall"
|
The Pi-hole requires elevated privileges to uninstall"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get paths for admin interface, log files and database files,
|
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||||
# to allow deletion where user has specified a non-default location
|
|
||||||
ADMIN_INTERFACE_DIR=$(getFTLConfigValue "webserver.paths.webroot")$(getFTLConfigValue "webserver.paths.webhome")
|
|
||||||
FTL_LOG=$(getFTLConfigValue "files.log.ftl")
|
|
||||||
DNSMASQ_LOG=$(getFTLConfigValue "files.log.dnsmasq")
|
|
||||||
WEBSERVER_LOG=$(getFTLConfigValue "files.log.webserver")
|
|
||||||
PIHOLE_DB=$(getFTLConfigValue "files.database")
|
|
||||||
GRAVITY_DB=$(getFTLConfigValue "files.gravity")
|
|
||||||
MACVENDOR_DB=$(getFTLConfigValue "files.macvendor")
|
|
||||||
|
|
||||||
PI_HOLE_LOCAL_REPO="/etc/.pihole"
|
|
||||||
# Setting SKIP_INSTALL="true" to source the installer functions without running them
|
|
||||||
SKIP_INSTALL="true"
|
SKIP_INSTALL="true"
|
||||||
# shellcheck source="./automated install/basic-install.sh"
|
# shellcheck source="./automated install/basic-install.sh"
|
||||||
source "${PI_HOLE_LOCAL_REPO}/automated install/basic-install.sh"
|
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
||||||
# Functions and Variables sources from basic-install:
|
# stop_service() is defined in basic-install.sh
|
||||||
# package_manager_detect(), disable_service(), stop_service(),
|
# package_manager_detect() sourced from basic-install.sh
|
||||||
# restart service() and is_command()
|
package_manager_detect
|
||||||
# PI_HOLE_CONFIG_DIR PI_HOLE_INSTALL_DIR PI_HOLE_LOCAL_REPO
|
|
||||||
|
|
||||||
removeMetaPackage() {
|
removeMetaPackage() {
|
||||||
# Purge Pi-hole meta package
|
# Purge Pi-hole meta package
|
||||||
echo ""
|
echo ""
|
||||||
echo -ne " ${INFO} Removing Pi-hole meta package...";
|
echo -ne " ${INFO} Removing Pi-hole meta package...";
|
||||||
eval "${PKG_REMOVE}" "pihole-meta" &> /dev/null;
|
eval "${SUDO}" "${PKG_REMOVE}" "pihole-meta" &> /dev/null;
|
||||||
echo -e "${OVER} ${INFO} Removed Pi-hole meta package";
|
echo -e "${OVER} ${INFO} Removed Pi-hole meta package";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeWebInterface() {
|
removePiholeFiles() {
|
||||||
# Remove the web interface of Pi-hole
|
# Remove the web interface of Pi-hole
|
||||||
echo -ne " ${INFO} Removing Web Interface..."
|
echo -ne " ${INFO} Removing Web Interface..."
|
||||||
rm -rf "${ADMIN_INTERFACE_DIR:-/var/www/html/admin/}" &> /dev/null
|
${SUDO} rm -rf "${ADMIN_INTERFACE_DIR}" &> /dev/null
|
||||||
echo -e "${OVER} ${TICK} Removed Web Interface"
|
echo -e "${OVER} ${TICK} Removed Web Interface"
|
||||||
}
|
|
||||||
|
|
||||||
removeFTL() {
|
|
||||||
# Remove FTL and stop any running FTL service
|
|
||||||
if is_command "pihole-FTL"; then
|
|
||||||
# service stop & disable from basic_install.sh
|
|
||||||
stop_service pihole-FTL
|
|
||||||
disable_service pihole-FTL
|
|
||||||
|
|
||||||
echo -ne " ${INFO} Removing pihole-FTL..."
|
|
||||||
rm -f /etc/systemd/system/pihole-FTL.service &> /dev/null
|
|
||||||
if [[ -d '/etc/systemd/system/pihole-FTL.service.d' ]]; then
|
|
||||||
read -rp " ${QST} FTL service override directory /etc/systemd/system/pihole-FTL.service.d detected. Do you wish to remove this from your system? [y/N] " answer
|
|
||||||
case $answer in
|
|
||||||
[yY]*)
|
|
||||||
echo -ne " ${INFO} Removing /etc/systemd/system/pihole-FTL.service.d..."
|
|
||||||
rm -R /etc/systemd/system/pihole-FTL.service.d &> /dev/null
|
|
||||||
echo -e "${OVER} ${INFO} Removed /etc/systemd/system/pihole-FTL.service.d"
|
|
||||||
;;
|
|
||||||
*) echo -e " ${INFO} Leaving /etc/systemd/system/pihole-FTL.service.d in place.";;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
rm -f /etc/init.d/pihole-FTL &> /dev/null
|
|
||||||
rm -f /usr/bin/pihole-FTL &> /dev/null
|
|
||||||
echo -e "${OVER} ${TICK} Removed pihole-FTL"
|
|
||||||
|
|
||||||
# Force systemd reload after service files are removed
|
|
||||||
if is_command "systemctl"; then
|
|
||||||
echo -ne " ${INFO} Restarting systemd..."
|
|
||||||
systemctl daemon-reload
|
|
||||||
echo -e "${OVER} ${TICK} Restarted systemd..."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
removeCronFiles() {
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
# to guarantee no additional changes were made to /etc/crontab after
|
# to guarantee no additional changes were made to /etc/crontab after
|
||||||
# the installation of pihole, /etc/crontab.pihole should be permanently
|
# the installation of pihole, /etc/crontab.pihole should be permanently
|
||||||
# preserved.
|
# preserved.
|
||||||
if [[ -f /etc/crontab.orig ]]; then
|
if [[ -f /etc/crontab.orig ]]; then
|
||||||
mv /etc/crontab /etc/crontab.pihole
|
${SUDO} mv /etc/crontab /etc/crontab.pihole
|
||||||
mv /etc/crontab.orig /etc/crontab
|
${SUDO} mv /etc/crontab.orig /etc/crontab
|
||||||
restart_service cron
|
${SUDO} service cron restart
|
||||||
echo -e " ${TICK} Restored the default system cron"
|
echo -e " ${TICK} Restored the default system cron"
|
||||||
echo -e " ${INFO} A backup of the most recent crontab is saved at /etc/crontab.pihole"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
if [[ -f /etc/cron.d/pihole ]];then
|
if [[ -f /etc/cron.d/pihole ]];then
|
||||||
rm -f /etc/cron.d/pihole &> /dev/null
|
${SUDO} rm -f /etc/cron.d/pihole &> /dev/null
|
||||||
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
removePiholeFiles() {
|
|
||||||
# Remove databases (including user specified non-default paths)
|
|
||||||
rm -f "${PIHOLE_DB:-/etc/pihole/pihole-FTL.db}" &> /dev/null
|
|
||||||
rm -f "${GRAVITY_DB:-/etc/pihole/gravity.db}" &> /dev/null
|
|
||||||
rm -f "${MACVENDOR_DB:-/etc/pihole/macvendor.db}" &> /dev/null
|
|
||||||
|
|
||||||
# Remove pihole config, repo and local files
|
|
||||||
rm -rf "${PI_HOLE_CONFIG_DIR:-/etc/pihole}" &> /dev/null
|
|
||||||
rm -rf "${PI_HOLE_LOCAL_REPO:-/etc/.pihole}" &> /dev/null
|
|
||||||
rm -rf "${PI_HOLE_INSTALL_DIR:-/opt/pihole}" &> /dev/null
|
|
||||||
|
|
||||||
# Remove log files (including user specified non-default paths)
|
|
||||||
# and rotated logs
|
|
||||||
# Explicitly escape spaces, in case of trailing space in path before wildcard
|
|
||||||
rm -f "$(printf '%q' "${FTL_LOG:-/var/log/pihole/FTL.log}")*" &> /dev/null
|
|
||||||
rm -f "$(printf '%q' "${DNSMASQ_LOG:-/var/log/pihole/pihole.log}")*" &> /dev/null
|
|
||||||
rm -f "$(printf '%q' "${WEBSERVER_LOG:-/var/log/pihole/webserver.log}")*" &> /dev/null
|
|
||||||
|
|
||||||
# remove any remnant log-files from old versions
|
|
||||||
rm -rf /var/log/*pihole* &> /dev/null
|
|
||||||
|
|
||||||
# remove log directory
|
|
||||||
rm -rf /var/log/pihole &> /dev/null
|
|
||||||
|
|
||||||
# remove the pihole command
|
|
||||||
rm -f /usr/local/bin/pihole &> /dev/null
|
|
||||||
|
|
||||||
# remove Pi-hole's bash completion
|
|
||||||
rm -f /etc/bash_completion.d/pihole &> /dev/null
|
|
||||||
rm -f /etc/bash_completion.d/pihole-FTL &> /dev/null
|
|
||||||
|
|
||||||
# Remove pihole from sudoers for compatibility with old versions
|
|
||||||
rm -f /etc/sudoers.d/pihole &> /dev/null
|
|
||||||
|
|
||||||
|
${SUDO} rm -rf /var/log/*pihole* &> /dev/null
|
||||||
|
${SUDO} rm -rf /var/log/pihole/*pihole* &> /dev/null
|
||||||
|
${SUDO} rm -rf /etc/pihole/ &> /dev/null
|
||||||
|
${SUDO} rm -rf /etc/.pihole/ &> /dev/null
|
||||||
|
${SUDO} rm -rf /opt/pihole/ &> /dev/null
|
||||||
|
${SUDO} rm -f /usr/local/bin/pihole &> /dev/null
|
||||||
|
${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null
|
||||||
|
${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null
|
||||||
echo -e " ${TICK} Removed config files"
|
echo -e " ${TICK} Removed config files"
|
||||||
}
|
|
||||||
|
|
||||||
removeManPage() {
|
# Restore Resolved
|
||||||
# If the pihole manpage exists, then delete
|
if [[ -e /etc/systemd/resolved.conf.orig ]] || [[ -e /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf ]]; then
|
||||||
if [[ -f /usr/local/share/man/man8/pihole.8 ]]; then
|
${SUDO} cp -p /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf &> /dev/null || true
|
||||||
rm -f /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5
|
${SUDO} rm -f /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf
|
||||||
# Rebuild man-db if present
|
systemctl reload-or-restart systemd-resolved
|
||||||
if is_command "mandb"; then
|
|
||||||
mandb -q &>/dev/null
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Remove FTL
|
||||||
|
if command -v pihole-FTL &> /dev/null; then
|
||||||
|
echo -ne " ${INFO} Removing pihole-FTL..."
|
||||||
|
stop_service pihole-FTL
|
||||||
|
${SUDO} rm -f /etc/systemd/system/pihole-FTL.service
|
||||||
|
if [[ -d '/etc/systemd/system/pihole-FTL.service.d' ]]; then
|
||||||
|
read -rp " ${QST} FTL service override directory /etc/systemd/system/pihole-FTL.service.d detected. Do you wish to remove this from your system? [y/N] " answer
|
||||||
|
case $answer in
|
||||||
|
[yY]*)
|
||||||
|
echo -ne " ${INFO} Removing /etc/systemd/system/pihole-FTL.service.d..."
|
||||||
|
${SUDO} rm -R /etc/systemd/system/pihole-FTL.service.d
|
||||||
|
echo -e "${OVER} ${INFO} Removed /etc/systemd/system/pihole-FTL.service.d"
|
||||||
|
;;
|
||||||
|
*) echo -e " ${INFO} Leaving /etc/systemd/system/pihole-FTL.service.d in place.";;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
${SUDO} rm -f /etc/init.d/pihole-FTL
|
||||||
|
${SUDO} rm -f /usr/bin/pihole-FTL
|
||||||
|
echo -e "${OVER} ${TICK} Removed pihole-FTL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the pihole manpage exists, then delete and rebuild man-db
|
||||||
|
if [[ -f /usr/local/share/man/man8/pihole.8 ]]; then
|
||||||
|
${SUDO} rm -f /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5
|
||||||
|
${SUDO} mandb -q &>/dev/null
|
||||||
echo -e " ${TICK} Removed pihole man page"
|
echo -e " ${TICK} Removed pihole man page"
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
removeUser() {
|
|
||||||
# If the pihole user exists, then remove
|
# If the pihole user exists, then remove
|
||||||
if id "pihole" &> /dev/null; then
|
if id "pihole" &> /dev/null; then
|
||||||
if userdel -r pihole 2> /dev/null; then
|
if ${SUDO} userdel -r pihole 2> /dev/null; then
|
||||||
echo -e " ${TICK} Removed 'pihole' user"
|
echo -e " ${TICK} Removed 'pihole' user"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} Unable to remove 'pihole' user"
|
echo -e " ${CROSS} Unable to remove 'pihole' user"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the pihole group exists, then remove
|
# If the pihole group exists, then remove
|
||||||
if getent group "pihole" &> /dev/null; then
|
if getent group "pihole" &> /dev/null; then
|
||||||
if groupdel pihole 2> /dev/null; then
|
if ${SUDO} groupdel pihole 2> /dev/null; then
|
||||||
echo -e " ${TICK} Removed 'pihole' group"
|
echo -e " ${TICK} Removed 'pihole' group"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} Unable to remove 'pihole' group"
|
echo -e " ${CROSS} Unable to remove 'pihole' group"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
restoreResolved() {
|
|
||||||
# Restore Resolved from saved configuration, if present
|
|
||||||
if [[ -e /etc/systemd/resolved.conf.orig ]] || [[ -e /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf ]]; then
|
|
||||||
cp -p /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf &> /dev/null || true
|
|
||||||
rm -f /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf &> /dev/null
|
|
||||||
systemctl reload-or-restart systemd-resolved
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
completionMessage() {
|
|
||||||
echo -e "\\n We're sorry to see you go, but thanks for checking out Pi-hole!
|
echo -e "\\n We're sorry to see you go, but thanks for checking out Pi-hole!
|
||||||
If you need help, reach out to us on GitHub, Discourse, Reddit or Twitter
|
If you need help, reach out to us on GitHub, Discourse, Reddit or Twitter
|
||||||
Reinstall at any time: ${COL_BOLD}curl -sSL https://install.pi-hole.net | bash${COL_NC}
|
Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC}
|
||||||
|
|
||||||
${COL_RED}Please reset the DNS on your router/clients to restore internet connectivity${COL_NC}
|
${COL_LIGHT_RED}Please reset the DNS on your router/clients to restore internet connectivity${COL_NC}
|
||||||
${INFO} Pi-hole's meta package has been removed, use the 'autoremove' function from your package manager to remove unused dependencies${COL_NC}
|
${INFO} Pi-hole's meta package has been removed, use the 'autoremove' function from your package manager to remove unused dependencies${COL_NC}
|
||||||
${COL_GREEN}Uninstallation Complete! ${COL_NC}"
|
${COL_LIGHT_GREEN}Uninstallation Complete! ${COL_NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
######### SCRIPT ###########
|
######### SCRIPT ###########
|
||||||
# The ordering here allows clean uninstallation with nothing
|
|
||||||
# removed before anything that depends upon it.
|
|
||||||
# eg removeFTL relies on scripts removed by removePiholeFiles
|
|
||||||
# removeUser relies on commands removed by removeMetaPackage
|
|
||||||
package_manager_detect
|
|
||||||
removeWebInterface
|
|
||||||
removeCronFiles
|
|
||||||
restoreResolved
|
|
||||||
removeManPage
|
|
||||||
removeFTL
|
|
||||||
removeUser
|
|
||||||
removeMetaPackage
|
removeMetaPackage
|
||||||
removePiholeFiles
|
removePiholeFiles
|
||||||
completionMessage
|
|
||||||
|
|||||||
37
gravity.sh
37
gravity.sh
@@ -50,7 +50,7 @@ etag_support=false
|
|||||||
|
|
||||||
# Check gravity temp directory
|
# Check gravity temp directory
|
||||||
if [ ! -d "${GRAVITY_TMPDIR}" ] || [ ! -w "${GRAVITY_TMPDIR}" ]; then
|
if [ ! -d "${GRAVITY_TMPDIR}" ] || [ ! -w "${GRAVITY_TMPDIR}" ]; then
|
||||||
echo -e " ${COL_RED}Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp. ${COL_NC}"
|
echo -e " ${COL_LIGHT_RED}Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp. ${COL_NC}"
|
||||||
GRAVITY_TMPDIR="/tmp"
|
GRAVITY_TMPDIR="/tmp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -118,12 +118,9 @@ gravity_swap_databases() {
|
|||||||
|
|
||||||
# Swap databases and remove or conditionally rename old database
|
# Swap databases and remove or conditionally rename old database
|
||||||
# Number of available blocks on disk
|
# Number of available blocks on disk
|
||||||
# Busybox Compat: `stat` long flags unsupported
|
availableBlocks=$(stat -f --format "%a" "${gravityDIR}")
|
||||||
# -f flag is short form of --file-system.
|
|
||||||
# -c flag is short form of --format.
|
|
||||||
availableBlocks=$(stat -f -c "%a" "${gravityDIR}")
|
|
||||||
# Number of blocks, used by gravity.db
|
# Number of blocks, used by gravity.db
|
||||||
gravityBlocks=$(stat -c "%b" "${gravityDBfile}")
|
gravityBlocks=$(stat --format "%b" "${gravityDBfile}")
|
||||||
# Only keep the old database if available disk space is at least twice the size of the existing gravity.db.
|
# Only keep the old database if available disk space is at least twice the size of the existing gravity.db.
|
||||||
# Better be safe than sorry...
|
# Better be safe than sorry...
|
||||||
oldAvail=false
|
oldAvail=false
|
||||||
@@ -611,10 +608,8 @@ compareLists() {
|
|||||||
# Download specified URL and perform checks on HTTP status and file content
|
# Download specified URL and perform checks on HTTP status and file content
|
||||||
gravity_DownloadBlocklistFromUrl() {
|
gravity_DownloadBlocklistFromUrl() {
|
||||||
local url="${1}" adlistID="${2}" saveLocation="${3}" compression="${4}" gravity_type="${5}" domain="${6}"
|
local url="${1}" adlistID="${2}" saveLocation="${3}" compression="${4}" gravity_type="${5}" domain="${6}"
|
||||||
local listCurlBuffer str httpCode success="" ip customUpstreamResolver=""
|
local modifiedOptions="" listCurlBuffer str httpCode success="" ip cmd_ext
|
||||||
local file_path permissions ip_addr port blocked=false download=true
|
local file_path permissions ip_addr port blocked=false download=true
|
||||||
# modifiedOptions is an array to store all the options used to check if the adlist has been changed upstream
|
|
||||||
local modifiedOptions=()
|
|
||||||
|
|
||||||
# Create temp file to store content on disk instead of RAM
|
# Create temp file to store content on disk instead of RAM
|
||||||
# We don't use '--suffix' here because not all implementations of mktemp support it, e.g. on Alpine
|
# We don't use '--suffix' here because not all implementations of mktemp support it, e.g. on Alpine
|
||||||
@@ -631,14 +626,14 @@ gravity_DownloadBlocklistFromUrl() {
|
|||||||
# Save HTTP ETag to the specified file. An ETag is a caching related header,
|
# Save HTTP ETag to the specified file. An ETag is a caching related header,
|
||||||
# usually returned in a response. If no ETag is sent by the server, an empty
|
# usually returned in a response. If no ETag is sent by the server, an empty
|
||||||
# file is created and can later be used consistently.
|
# file is created and can later be used consistently.
|
||||||
modifiedOptions=("${modifiedOptions[@]}" --etag-save "${saveLocation}".etag)
|
modifiedOptions="--etag-save ${saveLocation}.etag"
|
||||||
|
|
||||||
if [[ -f "${saveLocation}.etag" ]]; then
|
if [[ -f "${saveLocation}.etag" ]]; then
|
||||||
# This option makes a conditional HTTP request for the specific ETag read
|
# This option makes a conditional HTTP request for the specific ETag read
|
||||||
# from the given file by sending a custom If-None-Match header using the
|
# from the given file by sending a custom If-None-Match header using the
|
||||||
# stored ETag. This way, the server will only send the file if it has
|
# stored ETag. This way, the server will only send the file if it has
|
||||||
# changed since the last request.
|
# changed since the last request.
|
||||||
modifiedOptions=("${modifiedOptions[@]}" --etag-compare "${saveLocation}".etag)
|
modifiedOptions="${modifiedOptions} --etag-compare ${saveLocation}.etag"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -651,7 +646,7 @@ gravity_DownloadBlocklistFromUrl() {
|
|||||||
# Interstingly, this option is not supported by raw.githubusercontent.com
|
# Interstingly, this option is not supported by raw.githubusercontent.com
|
||||||
# URLs, however, it is still supported by many older web servers which may
|
# URLs, however, it is still supported by many older web servers which may
|
||||||
# not support the HTTP ETag method so we keep it as a fallback.
|
# not support the HTTP ETag method so we keep it as a fallback.
|
||||||
modifiedOptions=("${modifiedOptions[@]}" -z "${saveLocation}")
|
modifiedOptions="${modifiedOptions} -z ${saveLocation}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -717,7 +712,7 @@ gravity_DownloadBlocklistFromUrl() {
|
|||||||
fi
|
fi
|
||||||
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by one of your lists. Using DNS server ${upstream} instead"
|
echo -e "${OVER} ${CROSS} ${str} ${domain} is blocked by one of your lists. Using DNS server ${upstream} instead"
|
||||||
echo -ne " ${INFO} ${str} Pending..."
|
echo -ne " ${INFO} ${str} Pending..."
|
||||||
customUpstreamResolver="--resolve $domain:$port:$ip"
|
cmd_ext="--resolve $domain:$port:$ip"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -750,12 +745,14 @@ gravity_DownloadBlocklistFromUrl() {
|
|||||||
# Check for allowed protocols
|
# Check for allowed protocols
|
||||||
if [[ $url != "http"* && $url != "https"* && $url != "file"* && $url != "ftp"* && $url != "ftps"* && $url != "sftp"* ]]; then
|
if [[ $url != "http"* && $url != "https"* && $url != "file"* && $url != "ftp"* && $url != "ftps"* && $url != "sftp"* ]]; then
|
||||||
echo -e "${OVER} ${CROSS} ${str} Invalid protocol specified. Ignoring list."
|
echo -e "${OVER} ${CROSS} ${str} Invalid protocol specified. Ignoring list."
|
||||||
echo -e " Ensure your URL starts with a valid protocol like http:// , https:// or file:// ."
|
echo -e "Ensure your URL starts with a valid protocol like http:// , https:// or file:// ."
|
||||||
download=false
|
download=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${download}" == true ]]; then
|
if [[ "${download}" == true ]]; then
|
||||||
httpCode=$(curl --connect-timeout ${curl_connect_timeout} -s -L ${compression:+${compression}} ${customUpstreamResolver:+${customUpstreamResolver}} "${modifiedOptions[@]}" -w "%{http_code}" "${url}" -o "${listCurlBuffer}" 2>/dev/null)
|
# See https://github.com/pi-hole/pi-hole/issues/6159 for justification of the below disable directive
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
httpCode=$(curl --connect-timeout ${curl_connect_timeout} -s -L ${compression} ${cmd_ext} ${modifiedOptions} -w "%{http_code}" "${url}" -o "${listCurlBuffer}" 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $url in
|
case $url in
|
||||||
@@ -824,13 +821,13 @@ gravity_DownloadBlocklistFromUrl() {
|
|||||||
if [[ "${done}" != "true" ]]; then
|
if [[ "${done}" != "true" ]]; then
|
||||||
# Determine if cached list has read permission
|
# Determine if cached list has read permission
|
||||||
if [[ -r "${saveLocation}" ]]; then
|
if [[ -r "${saveLocation}" ]]; then
|
||||||
echo -e " ${CROSS} List download failed: ${COL_GREEN}using previously cached list${COL_NC}"
|
echo -e " ${CROSS} List download failed: ${COL_LIGHT_GREEN}using previously cached list${COL_NC}"
|
||||||
# Set list status to "download-failed/cached"
|
# Set list status to "download-failed/cached"
|
||||||
database_adlist_status "${adlistID}" "3"
|
database_adlist_status "${adlistID}" "3"
|
||||||
# Add domains to database table file
|
# Add domains to database table file
|
||||||
pihole-FTL "${gravity_type}" parseList "${saveLocation}" "${gravityTEMPfile}" "${adlistID}"
|
pihole-FTL "${gravity_type}" parseList "${saveLocation}" "${gravityTEMPfile}" "${adlistID}"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} List download failed: ${COL_RED}no cached list available${COL_NC}"
|
echo -e " ${CROSS} List download failed: ${COL_LIGHT_RED}no cached list available${COL_NC}"
|
||||||
# Manually reset these two numbers because we do not call parseList here
|
# Manually reset these two numbers because we do not call parseList here
|
||||||
database_adlist_number "${adlistID}" 0 0
|
database_adlist_number "${adlistID}" 0 0
|
||||||
database_adlist_status "${adlistID}" "4"
|
database_adlist_status "${adlistID}" "4"
|
||||||
@@ -854,7 +851,7 @@ gravity_Table_Count() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output count of denied and allowed domains and regex filters
|
# Output count of blacklisted domains and regex filters
|
||||||
gravity_ShowCount() {
|
gravity_ShowCount() {
|
||||||
# Here we use the table "gravity" instead of the view "vw_gravity" for speed.
|
# Here we use the table "gravity" instead of the view "vw_gravity" for speed.
|
||||||
# It's safe to replace it here, because right after a gravity run both will show the exactly same number of domains.
|
# It's safe to replace it here, because right after a gravity run both will show the exactly same number of domains.
|
||||||
@@ -867,7 +864,7 @@ gravity_ShowCount() {
|
|||||||
|
|
||||||
# Trap Ctrl-C
|
# Trap Ctrl-C
|
||||||
gravity_Trap() {
|
gravity_Trap() {
|
||||||
trap '{ echo -e "\\n\\n ${INFO} ${COL_RED}User-abort detected${COL_NC}"; gravity_Cleanup "error"; }' INT
|
trap '{ echo -e "\\n\\n ${INFO} ${COL_LIGHT_RED}User-abort detected${COL_NC}"; gravity_Cleanup "error"; }' INT
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean up after Gravity upon exit or cancellation
|
# Clean up after Gravity upon exit or cancellation
|
||||||
@@ -1130,7 +1127,7 @@ fi
|
|||||||
|
|
||||||
if [[ "${forceDelete:-}" == true ]]; then
|
if [[ "${forceDelete:-}" == true ]]; then
|
||||||
str="Deleting existing list cache"
|
str="Deleting existing list cache"
|
||||||
echo -ne " ${INFO} ${str}..."
|
echo -ne "${INFO} ${str}..."
|
||||||
|
|
||||||
rm "${listsCacheDir}/list.*" 2>/dev/null || true
|
rm "${listsCacheDir}/list.*" 2>/dev/null || true
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
|
|||||||
@@ -105,9 +105,9 @@ Available commands and options:
|
|||||||
Flush the Pi-hole log
|
Flush the Pi-hole log
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-r, repair\fR
|
\fB-r, reconfigure\fR
|
||||||
.br
|
.br
|
||||||
Repair Pi-hole subsystems
|
Reconfigure or Repair Pi-hole subsystems
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-t, tail\fR [arg]
|
\fB-t, tail\fR [arg]
|
||||||
@@ -268,7 +268,7 @@ Allow-/denylist manipulation
|
|||||||
|
|
||||||
\fBpihole --regex "ad.*\\.example\\.com$"\fR
|
\fBpihole --regex "ad.*\\.example\\.com$"\fR
|
||||||
.br
|
.br
|
||||||
Adds "ad.*\\.example\\.com$" to the regex denylist.
|
Adds "ad.*\\.example\\.com$" to the regex blacklist.
|
||||||
Would block all subdomains of example.com which start with "ad"
|
Would block all subdomains of example.com which start with "ad"
|
||||||
.br
|
.br
|
||||||
|
|
||||||
@@ -317,10 +317,9 @@ Switching Pi-hole subsystem branches
|
|||||||
Switch to core development branch
|
Switch to core development branch
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBpihole networkflush\fR
|
\fBpihole arpflush\fR
|
||||||
.br
|
.br
|
||||||
Flush information stored in Pi-hole's network table
|
Flush information stored in Pi-hole's network tables
|
||||||
Add '--arp' to additionally flush the ARP table
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBpihole api stats/summary\fR
|
\fBpihole api stats/summary\fR
|
||||||
|
|||||||
104
pihole
104
pihole
@@ -9,7 +9,7 @@
|
|||||||
# This file is copyright under the latest version of the EUPL.
|
# This file is copyright under the latest version of the EUPL.
|
||||||
# Please see LICENSE file for your rights under this license.
|
# Please see LICENSE file for your rights under this license.
|
||||||
|
|
||||||
PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||||
|
|
||||||
# PI_HOLE_BIN_DIR is not readonly here because in some functions (checkout),
|
# PI_HOLE_BIN_DIR is not readonly here because in some functions (checkout),
|
||||||
# they might get set again when the installer is sourced. This causes an
|
# they might get set again when the installer is sourced. This causes an
|
||||||
@@ -20,7 +20,7 @@ readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
|
|||||||
# shellcheck source=./advanced/Scripts/COL_TABLE
|
# shellcheck source=./advanced/Scripts/COL_TABLE
|
||||||
source "${colfile}"
|
source "${colfile}"
|
||||||
|
|
||||||
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
readonly utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
||||||
# shellcheck source=./advanced/Scripts/utils.sh
|
# shellcheck source=./advanced/Scripts/utils.sh
|
||||||
source "${utilsfile}"
|
source "${utilsfile}"
|
||||||
|
|
||||||
@@ -96,18 +96,8 @@ flushFunc() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Deprecated function, should be removed in the future
|
|
||||||
# use networkFlush instead
|
|
||||||
arpFunc() {
|
arpFunc() {
|
||||||
shift
|
"${PI_HOLE_SCRIPT_DIR}"/piholeARPTable.sh "$@"
|
||||||
echo -e " ${INFO} The 'arpflush' command is deprecated, use 'networkflush' instead"
|
|
||||||
"${PI_HOLE_SCRIPT_DIR}"/piholeNetworkFlush.sh "$@"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
networkFlush() {
|
|
||||||
shift
|
|
||||||
"${PI_HOLE_SCRIPT_DIR}"/piholeNetworkFlush.sh "$@"
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,11 +147,10 @@ uninstallFunc() {
|
|||||||
|
|
||||||
versionFunc() {
|
versionFunc() {
|
||||||
exec "${PI_HOLE_SCRIPT_DIR}"/version.sh
|
exec "${PI_HOLE_SCRIPT_DIR}"/version.sh
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadDNS() {
|
reloadDNS() {
|
||||||
local svcOption svc str output status pid icon FTL_PID_FILE sigrtmin
|
local svcOption svc str output status pid icon FTL_PID_FILE
|
||||||
svcOption="${1:-reload}"
|
svcOption="${1:-reload}"
|
||||||
|
|
||||||
# get the current path to the pihole-FTL.pid
|
# get the current path to the pihole-FTL.pid
|
||||||
@@ -180,10 +169,7 @@ reloadDNS() {
|
|||||||
str="FTL is not running"
|
str="FTL is not running"
|
||||||
icon="${INFO}"
|
icon="${INFO}"
|
||||||
else
|
else
|
||||||
sigrtmin="$(pihole-FTL sigrtmin 2>/dev/null)"
|
svc="kill -RTMIN ${pid}"
|
||||||
# Make sure sigrtmin is a number, otherwise fallback to RTMIN
|
|
||||||
[[ "${sigrtmin}" =~ ^[0-9]+$ ]] || unset sigrtmin
|
|
||||||
svc="kill -${sigrtmin:-RTMIN} ${pid}"
|
|
||||||
str="Reloading DNS lists"
|
str="Reloading DNS lists"
|
||||||
icon="${TICK}"
|
icon="${TICK}"
|
||||||
fi
|
fi
|
||||||
@@ -252,7 +238,7 @@ Time:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${error} == true ]];then
|
if [[ ${error} == true ]];then
|
||||||
echo -e " ${COL_RED}Unknown format for blocking timer!${COL_NC}"
|
echo -e " ${COL_LIGHT_RED}Unknown format for blocking timer!${COL_NC}"
|
||||||
echo -e " Try 'pihole disable --help' for more information."
|
echo -e " Try 'pihole disable --help' for more information."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -278,7 +264,6 @@ Time:
|
|||||||
LogoutAPI
|
LogoutAPI
|
||||||
|
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
piholeLogging() {
|
piholeLogging() {
|
||||||
@@ -308,7 +293,7 @@ Options:
|
|||||||
echo -e " ${INFO} Enabling logging..."
|
echo -e " ${INFO} Enabling logging..."
|
||||||
local str="Logging has been enabled!"
|
local str="Logging has been enabled!"
|
||||||
else
|
else
|
||||||
echo -e " ${COL_RED}Invalid option${COL_NC}
|
echo -e " ${COL_LIGHT_RED}Invalid option${COL_NC}
|
||||||
Try 'pihole logging --help' for more information."
|
Try 'pihole logging --help' for more information."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -404,14 +389,14 @@ tailFunc() {
|
|||||||
echo -e " ${INFO} Press Ctrl-C to exit"
|
echo -e " ${INFO} Press Ctrl-C to exit"
|
||||||
|
|
||||||
# Get logfile path
|
# Get logfile path
|
||||||
LOGFILE=$(getFTLConfigValue files.log.dnsmasq)
|
|
||||||
readonly LOGFILE
|
readonly LOGFILE
|
||||||
|
LOGFILE=$(getFTLConfigValue files.log.dnsmasq)
|
||||||
|
|
||||||
# Strip date from each line
|
# Strip date from each line
|
||||||
# Color blocklist/denylist/wildcard entries as red
|
# Color blocklist/denylist/wildcard entries as red
|
||||||
# Color A/AAAA/DHCP strings as white
|
# Color A/AAAA/DHCP strings as white
|
||||||
# Color everything else as gray
|
# Color everything else as gray
|
||||||
tail -f $LOGFILE | grep --line-buffered -- "${1}" | sed -E \
|
tail -f $LOGFILE | grep --line-buffered "${1}" | sed -E \
|
||||||
-e "s,($(date +'%b %d ')| dnsmasq\[[0-9]*\]),,g" \
|
-e "s,($(date +'%b %d ')| dnsmasq\[[0-9]*\]),,g" \
|
||||||
-e "s,(.*(denied |gravity blocked ).*),${COL_RED}&${COL_NC}," \
|
-e "s,(.*(denied |gravity blocked ).*),${COL_RED}&${COL_NC}," \
|
||||||
-e "s,.*(query\\[A|DHCP).*,${COL_NC}&${COL_NC}," \
|
-e "s,.*(query\\[A|DHCP).*,${COL_NC}&${COL_NC}," \
|
||||||
@@ -534,8 +519,7 @@ Options:
|
|||||||
reloadlists Update the lists WITHOUT flushing the cache or restarting the DNS server
|
reloadlists Update the lists WITHOUT flushing the cache or restarting the DNS server
|
||||||
checkout Switch Pi-hole subsystems to a different GitHub branch
|
checkout Switch Pi-hole subsystems to a different GitHub branch
|
||||||
Add '-h' for more info on checkout usage
|
Add '-h' for more info on checkout usage
|
||||||
networkflush Flush information stored in Pi-hole's network tables
|
arpflush Flush information stored in Pi-hole's network tables";
|
||||||
Add '--arp' to additionally flush the ARP table ";
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +528,7 @@ if [[ $# = 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# functions that do not require sudo power
|
# functions that do not require sudo power
|
||||||
need_root=
|
need_root=1
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
"-h" | "help" | "--help" ) helpFunc;;
|
"-h" | "help" | "--help" ) helpFunc;;
|
||||||
"-v" | "version" ) versionFunc;;
|
"-v" | "version" ) versionFunc;;
|
||||||
@@ -552,32 +536,31 @@ case "${1}" in
|
|||||||
"-q" | "query" ) queryFunc "$@";;
|
"-q" | "query" ) queryFunc "$@";;
|
||||||
"status" ) statusFunc "$2";;
|
"status" ) statusFunc "$2";;
|
||||||
"tricorder" ) tricorderFunc;;
|
"tricorder" ) tricorderFunc;;
|
||||||
"allow" | "allowlist" ) listFunc "$@";;
|
|
||||||
"deny" | "denylist" ) listFunc "$@";;
|
|
||||||
"--wild" | "wildcard" ) listFunc "$@";;
|
|
||||||
"--regex" | "regex" ) listFunc "$@";;
|
|
||||||
"--allow-regex" | "allow-regex" ) listFunc "$@";;
|
|
||||||
"--allow-wild" | "allow-wild" ) listFunc "$@";;
|
|
||||||
"enable" ) piholeEnable true "$2";;
|
|
||||||
"disable" ) piholeEnable false "$2";;
|
|
||||||
"api" ) shift; apiFunc "$@"; exit 0;;
|
|
||||||
|
|
||||||
# we need to add all arguments that require sudo power to not trigger the * argument
|
# we need to add all arguments that require sudo power to not trigger the * argument
|
||||||
"-f" | "flush" ) need_root=true;;
|
"allow" | "allowlist" ) need_root=0;;
|
||||||
"-up" | "updatePihole" ) need_root=true;;
|
"deny" | "denylist" ) need_root=0;;
|
||||||
"-r" | "repair" ) need_root=true;;
|
"--wild" | "wildcard" ) need_root=0;;
|
||||||
"-l" | "logging" ) need_root=true;;
|
"--regex" | "regex" ) need_root=0;;
|
||||||
"uninstall" ) need_root=true;;
|
"--allow-regex" | "allow-regex" ) need_root=0;;
|
||||||
"-d" | "debug" ) need_root=true;;
|
"--allow-wild" | "allow-wild" ) need_root=0;;
|
||||||
"-g" | "updateGravity" ) need_root=true;;
|
"-f" | "flush" ) ;;
|
||||||
"reloaddns" ) need_root=true;;
|
"-up" | "updatePihole" ) ;;
|
||||||
"reloadlists" ) need_root=true;;
|
"-r" | "repair" ) ;;
|
||||||
"setpassword" ) need_root=true;;
|
"-l" | "logging" ) ;;
|
||||||
"checkout" ) need_root=true;;
|
"uninstall" ) ;;
|
||||||
"updatechecker" ) need_root=true;;
|
"enable" ) need_root=0;;
|
||||||
"arpflush" ) need_root=true;; # Deprecated, use networkflush instead
|
"disable" ) need_root=0;;
|
||||||
"networkflush" ) need_root=true;;
|
"-d" | "debug" ) ;;
|
||||||
"-t" | "tail" ) need_root=true;;
|
"-g" | "updateGravity" ) ;;
|
||||||
|
"reloaddns" ) ;;
|
||||||
|
"reloadlists" ) ;;
|
||||||
|
"setpassword" ) ;;
|
||||||
|
"checkout" ) ;;
|
||||||
|
"updatechecker" ) ;;
|
||||||
|
"arpflush" ) ;;
|
||||||
|
"-t" | "tail" ) ;;
|
||||||
|
"api" ) need_root=0;;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -587,17 +570,22 @@ if [[ -z ${USER} ]]; then
|
|||||||
USER=$(whoami)
|
USER=$(whoami)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the current user is not root and if the command
|
# Check if the current user is neither root nor pihole and if the command
|
||||||
# requires root. If so, exit with an error message.
|
# requires root. If so, exit with an error message.
|
||||||
# Add an exception for the user "pihole" to allow the webserver running gravity
|
if [[ $EUID -ne 0 && ${USER} != "pihole" && need_root -eq 1 ]];then
|
||||||
if [[ ( $EUID -ne 0 && ${USER} != "pihole" ) && -n "${need_root}" ]]; then
|
echo -e " ${CROSS} The Pi-hole command requires root privileges, try:"
|
||||||
echo -e " ${CROSS} This Pi-hole command requires root privileges, try:"
|
|
||||||
echo -e " ${COL_GREEN}sudo pihole $*${COL_NC}"
|
echo -e " ${COL_GREEN}sudo pihole $*${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle redirecting to specific functions based on arguments
|
# Handle redirecting to specific functions based on arguments
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
|
"allow" | "allowlist" ) listFunc "$@";;
|
||||||
|
"deny" | "denylist" ) listFunc "$@";;
|
||||||
|
"--wild" | "wildcard" ) listFunc "$@";;
|
||||||
|
"--regex" | "regex" ) listFunc "$@";;
|
||||||
|
"--allow-regex" | "allow-regex" ) listFunc "$@";;
|
||||||
|
"--allow-wild" | "allow-wild" ) listFunc "$@";;
|
||||||
"-d" | "debug" ) debugFunc "$@";;
|
"-d" | "debug" ) debugFunc "$@";;
|
||||||
"-f" | "flush" ) flushFunc "$@";;
|
"-f" | "flush" ) flushFunc "$@";;
|
||||||
"-up" | "updatePihole" ) updatePiholeFunc "$@";;
|
"-up" | "updatePihole" ) updatePiholeFunc "$@";;
|
||||||
@@ -605,13 +593,15 @@ case "${1}" in
|
|||||||
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
||||||
"-l" | "logging" ) piholeLogging "$@";;
|
"-l" | "logging" ) piholeLogging "$@";;
|
||||||
"uninstall" ) uninstallFunc;;
|
"uninstall" ) uninstallFunc;;
|
||||||
|
"enable" ) piholeEnable true "$2";;
|
||||||
|
"disable" ) piholeEnable false "$2";;
|
||||||
"reloaddns" ) reloadDNS "reload";;
|
"reloaddns" ) reloadDNS "reload";;
|
||||||
"reloadlists" ) reloadDNS "reload-lists";;
|
"reloadlists" ) reloadDNS "reload-lists";;
|
||||||
"setpassword" ) SetWebPassword "$@";;
|
"setpassword" ) SetWebPassword "$@";;
|
||||||
"checkout" ) piholeCheckoutFunc "$@";;
|
"checkout" ) piholeCheckoutFunc "$@";;
|
||||||
"updatechecker" ) shift; updateCheckFunc "$@";;
|
"updatechecker" ) shift; updateCheckFunc "$@";;
|
||||||
"arpflush" ) arpFunc "$@";; # Deprecated, use networkflush instead
|
"arpflush" ) arpFunc "$@";;
|
||||||
"networkflush" ) networkFlush "$@";;
|
|
||||||
"-t" | "tail" ) tailFunc "$2";;
|
"-t" | "tail" ) tailFunc "$2";;
|
||||||
|
"api" ) shift; apiFunc "$@";;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM alpine:3.21
|
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
|
||||||
RUN sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories
|
|
||||||
RUN apk --no-cache add bash coreutils curl git jq openrc shadow
|
|
||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
|
||||||
ADD . $GITDIR
|
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
|
||||||
|
|
||||||
RUN true && \
|
|
||||||
chmod +x $SCRIPTDIR/*
|
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM alpine:3.22
|
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
|
||||||
RUN sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories
|
|
||||||
RUN apk --no-cache add bash coreutils curl git jq openrc shadow
|
|
||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
|
||||||
ADD . $GITDIR
|
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
|
||||||
|
|
||||||
RUN true && \
|
|
||||||
chmod +x $SCRIPTDIR/*
|
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
FROM quay.io/centos/centos:stream10
|
FROM quay.io/centos/centos:stream10
|
||||||
# Disable SELinux
|
# Disable SELinux
|
||||||
RUN echo "SELINUX=disabled" > /etc/selinux/config
|
RUN echo "SELINUX=disabled" > /etc/selinux/config
|
||||||
RUN yum install -y --allowerasing curl git initscripts
|
RUN yum install -y --allowerasing curl git
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
ENV GITDIR=/etc/.pihole
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
ENV SCRIPTDIR=/opt/pihole
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
FROM quay.io/centos/centos:stream9
|
FROM quay.io/centos/centos:stream9
|
||||||
# Disable SELinux
|
# Disable SELinux
|
||||||
RUN echo "SELINUX=disabled" > /etc/selinux/config
|
RUN echo "SELINUX=disabled" > /etc/selinux/config
|
||||||
RUN yum install -y --allowerasing curl git initscripts
|
RUN yum install -y --allowerasing curl git
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
ENV GITDIR=/etc/.pihole
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
ENV SCRIPTDIR=/opt/pihole
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
FROM buildpack-deps:trixie-scm
|
|
||||||
|
|
||||||
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 $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
|
||||||
|
|
||||||
RUN true && \
|
|
||||||
chmod +x $SCRIPTDIR/*
|
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM fedora:40
|
FROM fedora:40
|
||||||
RUN dnf install -y git initscripts
|
RUN dnf install -y git
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
ENV GITDIR=/etc/.pihole
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
ENV SCRIPTDIR=/opt/pihole
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM fedora:41
|
FROM fedora:41
|
||||||
RUN dnf install -y git initscripts
|
RUN dnf install -y git
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
ENV GITDIR=/etc/.pihole
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
ENV SCRIPTDIR=/opt/pihole
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM fedora:42
|
FROM fedora:42
|
||||||
RUN dnf install -y git initscripts
|
RUN dnf install -y git gawk
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
ENV GITDIR=/etc/.pihole
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
ENV SCRIPTDIR=/opt/pihole
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pyyaml == 6.0.3
|
pyyaml == 6.0.2
|
||||||
pytest == 8.4.2
|
pytest == 8.3.5
|
||||||
pytest-xdist == 3.8.0
|
pytest-xdist == 3.6.1
|
||||||
pytest-testinfra == 10.2.2
|
pytest-testinfra == 10.2.2
|
||||||
tox == 4.32.0
|
tox == 4.26.0
|
||||||
pytest-clarity == 1.0.1
|
pytest-clarity == 1.0.1
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ def test_supported_package_manager(host):
|
|||||||
# break supported package managers
|
# break supported package managers
|
||||||
host.run("rm -rf /usr/bin/apt-get")
|
host.run("rm -rf /usr/bin/apt-get")
|
||||||
host.run("rm -rf /usr/bin/rpm")
|
host.run("rm -rf /usr/bin/rpm")
|
||||||
host.run("rm -rf /sbin/apk")
|
|
||||||
package_manager_detect = host.run(
|
package_manager_detect = host.run(
|
||||||
"""
|
"""
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
@@ -67,6 +66,14 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||||||
mock_command("dialog", {"*": ("", "0")}, host)
|
mock_command("dialog", {"*": ("", "0")}, host)
|
||||||
# mock git pull
|
# mock git pull
|
||||||
mock_command_passthrough("git", {"pull": ("", "0")}, host)
|
mock_command_passthrough("git", {"pull": ("", "0")}, host)
|
||||||
|
# mock PID 1 to pretend to be systemd
|
||||||
|
mock_command_2(
|
||||||
|
"ps",
|
||||||
|
{
|
||||||
|
"--pid 1": ("systemd", "0"),
|
||||||
|
},
|
||||||
|
host,
|
||||||
|
)
|
||||||
# mock systemctl to not start FTL
|
# mock systemctl to not start FTL
|
||||||
mock_command_2(
|
mock_command_2(
|
||||||
"systemctl",
|
"systemctl",
|
||||||
@@ -74,25 +81,15 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||||||
"enable pihole-FTL": ("", "0"),
|
"enable pihole-FTL": ("", "0"),
|
||||||
"restart pihole-FTL": ("", "0"),
|
"restart pihole-FTL": ("", "0"),
|
||||||
"start pihole-FTL": ("", "0"),
|
"start pihole-FTL": ("", "0"),
|
||||||
|
"stop pihole-FTL": ("", "0"),
|
||||||
"*": ('echo "systemctl call with $@"', "0"),
|
"*": ('echo "systemctl call with $@"', "0"),
|
||||||
},
|
},
|
||||||
host,
|
host,
|
||||||
)
|
)
|
||||||
mock_command_2(
|
|
||||||
"rc-service",
|
|
||||||
{
|
|
||||||
"rc-service pihole-FTL enable": ("", "0"),
|
|
||||||
"rc-service pihole-FTL restart": ("", "0"),
|
|
||||||
"rc-service pihole-FTL start": ("", "0"),
|
|
||||||
"*": ('echo "rc-service call with $@"', "0"),
|
|
||||||
},
|
|
||||||
host,
|
|
||||||
)
|
|
||||||
# try to install man
|
# try to install man
|
||||||
host.run("command -v apt-get > /dev/null && apt-get install -qq man")
|
host.run("command -v apt-get > /dev/null && apt-get install -qq man")
|
||||||
host.run("command -v dnf > /dev/null && dnf install -y man")
|
host.run("command -v dnf > /dev/null && dnf install -y man")
|
||||||
host.run("command -v yum > /dev/null && yum install -y man")
|
host.run("command -v yum > /dev/null && yum install -y man")
|
||||||
host.run("command -v apk > /dev/null && apk add mandoc man-pages")
|
|
||||||
# Workaround to get FTLv6 installed until it reaches master branch
|
# Workaround to get FTLv6 installed until it reaches master branch
|
||||||
host.run('echo "' + FTL_BRANCH + '" > /etc/pihole/ftlbranch')
|
host.run('echo "' + FTL_BRANCH + '" > /etc/pihole/ftlbranch')
|
||||||
install = host.run(
|
install = host.run(
|
||||||
@@ -101,8 +98,10 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
umask 0027
|
umask 0027
|
||||||
runUnattended=true
|
runUnattended=true
|
||||||
|
fresh_install=false
|
||||||
source /opt/pihole/basic-install.sh > /dev/null
|
source /opt/pihole/basic-install.sh > /dev/null
|
||||||
runUnattended=true
|
runUnattended=true
|
||||||
|
fresh_install=false
|
||||||
main
|
main
|
||||||
/opt/pihole/pihole-FTL-prestart.sh
|
/opt/pihole/pihole-FTL-prestart.sh
|
||||||
"""
|
"""
|
||||||
@@ -115,7 +114,7 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||||||
maninstalled = False
|
maninstalled = False
|
||||||
piholeuser = "pihole"
|
piholeuser = "pihole"
|
||||||
exit_status_success = 0
|
exit_status_success = 0
|
||||||
test_cmd = 'su -s /bin/bash -c "test -{0} {1}" -p {2}'
|
test_cmd = 'su --shell /bin/bash --command "test -{0} {1}" -p {2}'
|
||||||
# check files in /etc/pihole for read, write and execute permission
|
# check files in /etc/pihole for read, write and execute permission
|
||||||
check_etc = test_cmd.format("r", "/etc/pihole", piholeuser)
|
check_etc = test_cmd.format("r", "/etc/pihole", piholeuser)
|
||||||
actual_rc = host.run(check_etc).rc
|
actual_rc = host.run(check_etc).rc
|
||||||
@@ -141,13 +140,6 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||||||
check_macvendor = test_cmd.format("r", "/etc/pihole/macvendor.db", piholeuser)
|
check_macvendor = test_cmd.format("r", "/etc/pihole/macvendor.db", piholeuser)
|
||||||
actual_rc = host.run(check_macvendor).rc
|
actual_rc = host.run(check_macvendor).rc
|
||||||
assert exit_status_success == actual_rc
|
assert exit_status_success == actual_rc
|
||||||
# check readable and executable /etc/init.d/pihole-FTL
|
|
||||||
check_init = test_cmd.format("x", "/etc/init.d/pihole-FTL", piholeuser)
|
|
||||||
actual_rc = host.run(check_init).rc
|
|
||||||
assert exit_status_success == actual_rc
|
|
||||||
check_init = test_cmd.format("r", "/etc/init.d/pihole-FTL", piholeuser)
|
|
||||||
actual_rc = host.run(check_init).rc
|
|
||||||
assert exit_status_success == actual_rc
|
|
||||||
# check readable and executable manpages
|
# check readable and executable manpages
|
||||||
if maninstalled is True:
|
if maninstalled is True:
|
||||||
check_man = test_cmd.format("x", "/usr/local/share/man", piholeuser)
|
check_man = test_cmd.format("x", "/usr/local/share/man", piholeuser)
|
||||||
@@ -483,7 +475,6 @@ def test_package_manager_has_pihole_deps(host):
|
|||||||
"""
|
"""
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
update_package_cache
|
|
||||||
build_dependency_package
|
build_dependency_package
|
||||||
install_dependent_packages
|
install_dependent_packages
|
||||||
"""
|
"""
|
||||||
@@ -500,7 +491,6 @@ def test_meta_package_uninstall(host):
|
|||||||
"""
|
"""
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
update_package_cache
|
|
||||||
build_dependency_package
|
build_dependency_package
|
||||||
install_dependent_packages
|
install_dependent_packages
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
[tox]
|
|
||||||
envlist = py3
|
|
||||||
|
|
||||||
[testenv:py3]
|
|
||||||
allowlist_externals = docker
|
|
||||||
deps = -rrequirements.txt
|
|
||||||
setenv =
|
|
||||||
COLUMNS=120
|
|
||||||
commands = docker buildx build --load --progress plain -f _alpine_3_21.Dockerfile -t pytest_pihole:test_container ../
|
|
||||||
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
[tox]
|
|
||||||
envlist = py3
|
|
||||||
|
|
||||||
[testenv:py3]
|
|
||||||
allowlist_externals = docker
|
|
||||||
deps = -rrequirements.txt
|
|
||||||
setenv =
|
|
||||||
COLUMNS=120
|
|
||||||
commands = docker buildx build --load --progress plain -f _alpine_3_22.Dockerfile -t pytest_pihole:test_container ../
|
|
||||||
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
[tox]
|
|
||||||
envlist = py3
|
|
||||||
|
|
||||||
[testenv:py3]
|
|
||||||
allowlist_externals = docker
|
|
||||||
deps = -rrequirements.txt
|
|
||||||
setenv =
|
|
||||||
COLUMNS=120
|
|
||||||
commands = docker buildx build --load --progress plain -f _debian_13.Dockerfile -t pytest_pihole:test_container ../
|
|
||||||
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py
|
|
||||||
Reference in New Issue
Block a user