From f002dc11d98bbb6d2f0a6342382dbade4ba4ba83 Mon Sep 17 00:00:00 2001 From: "Will Presley (sonata)" Date: Wed, 4 Jan 2023 09:29:35 -0500 Subject: [PATCH] Added support for Pi-hole API Token. Fix requests. Necessary due to recent planned changes with the Pi-hole web interface that have now gone into effect: https://pi-hole.net/blog/2022/11/17/upcoming-changes-authentication-for-more-api-endpoints-required/ and https://github.com/pi-hole/AdminLTE/pull/2411/. Most API calls, including 'status' and 'summary', now require the Pi-hole API token, which can be obtained through the Settings > API page. Based on the 2nd link above, there may be some further changes in the future here. --- README.md | 36 +++++++++++++++++++----------------- pihello/cli.py | 12 +++++++----- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 3a821ff..66b96a3 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ You frequently work in the terminal or ssh into your pi-hole host? Wouldn't it be nice to have a useful greeting message? -Just install and add the `pihello ` command to your shell's startup script (`.bash_profile`, `.zshenv`, `fish_greeting.fish`, etc.). Next time you open the terminal you'll be greeted by the default _(or your own)_ fancy message! +Just install and add the `pihello ` command to your shell's startup script (`.bash_profile`, `.zshenv`, `fish_greeting.fish`, etc.). Next time you open the terminal you'll be greeted by the default _(or your own)_ fancy message! ## Installation @@ -43,7 +43,7 @@ pip install pihello Run a preconfigured display (as seen above): ``` -pihello +pihello ``` ## Usage @@ -53,35 +53,36 @@ pihello To run from the command line for standard HTTP Pi-hole installs: ``` -pihello +pihello ``` To run from the command line with a custom configuration file: ``` -pihello -f /path/to/config.txt +pihello -f /path/to/config.txt ``` To run from the command line for HTTPS Pi-hole installs: ``` -pihello -p +pihello -p ``` To run from the command line for HTTPS Pi-hole installs w/custom path to pihole (e.g. `/pihole` instead of the default `/admin`) : ``` -pihello -p -u /pihole +pihello -p -u /pihole ``` Full command options: ``` $ pihello -h -usage: pihello [-h] [-v] [-i INDENT] [-f FILE] [-c] [-W WIDTH] [-H HEIGHT] [-ts [TIMESTAMP]] [-p] [-u URI] addr +usage: pihello [-h] [-v] [-i INDENT] [-f FILE] [-c] [-W WIDTH] [-H HEIGHT] [-ts [TIMESTAMP]] [-p] [-u URI] addr token positional arguments: addr the address of your Pi-hole + token your Pi-hole API Token from settings optional arguments: -h, --help show this help message and exit @@ -120,7 +121,7 @@ Blocked [fuchsia]{ads_blocked_today}[] out of [lightgreen]{dns_queries_today}[] Run `pihello` with the `-f` flag pointing to the configuration file: ``` -pihello -f /home/username/path_to/example.txt +pihello -f /home/username/path_to/example.txt ``` ### Variable injection @@ -182,7 +183,7 @@ PiHole API's variables can be easily injected by using curly braces `{ }`. - Text styling is done by inserting style tags `[ ]` - Color prepended by a semicolon `:` indicates a **background color** -- Color prepended by an underline `_` indicates an **underlined color** +- Color prepended by an underline `_` indicates an **underlined color** _AFAIK, only supported in Kitty, VTE, mintty and iTerm2._ **Syntax:** `[