Skip to content

Commit

Permalink
Add PADD installer and patch to the package
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklul committed Mar 5, 2025
1 parent 1411245 commit cc08211
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
"cwd": "${workspaceFolder}"
}
},
{
"label": "Save dev/PADD patch to dev/patch.patch",
"type": "shell",
"command": "git -C dev/PADD diff --cached --abbrev=8 > dev/patch.patch && code dev/patch.patch",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "Patch dev/core",
"type": "shell",
Expand Down
58 changes: 58 additions & 0 deletions files/opt/share/pihole/PADD.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/padd.sh b/padd.sh
index 8fa5ef86..e86332e9 100755
--- a/padd.sh
+++ b/padd.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
# shellcheck disable=SC1091

# Ignore warning about `local` being undefinded in POSIX
@@ -12,6 +12,8 @@
export LC_ALL=C
export LC_NUMERIC=C

+PATH=/opt/bin:/opt/sbin:$PATH
+
############################################ VARIABLES #############################################

# VERSION
@@ -192,8 +194,8 @@ LoginAPI() {
fi

# Try to read the CLI password (if enabled and readable by the current user)
- if [ -r /etc/pihole/cli_pw ]; then
- password=$(cat /etc/pihole/cli_pw)
+ if [ -r /opt/etc/pihole/cli_pw ]; then
+ password=$(cat /opt/etc/pihole/cli_pw)
# If we can read the CLI password, we can skip 2FA even when it's required otherwise
needTOTP=false
fi
@@ -414,6 +416,7 @@ GetSystemInformation() {

# CPU temperature and unit
cpu_temp_raw=$(GetPADDValue sensors.cpu_temp)
+ [ "$cpu_temp_raw" == "null" ] && cpu_temp_raw=0
cpu_temp=$(printf "%.1f" "${cpu_temp_raw}")
temp_unit=$(echo "${padd_data}" | GetPADDValue sensors.unit)

@@ -1279,8 +1282,8 @@ SizeChecker(){
# this reduces "flickering" of GenerateSizeDependendOutput() items
# after a terminal re-size
sleep 0.1
- console_width=$(tput cols)
- console_height=$(tput lines)
+ console_width=$(stty size | cut -d' ' -f2)
+ console_height=$(stty size | cut -d' ' -f1)

# Mega
if [ "$console_width" -ge "80" ] && [ "$console_height" -ge "26" ]; then
@@ -1759,7 +1762,7 @@ NormalPADD() {

Update() {
# source version file to check if $DOCKER_VERSION is set
- . /etc/pihole/versions
+ . /opt/etc/pihole/versions

if [ -n "${DOCKER_VERSION}" ]; then
echo "${check_box_info} Update is not supported for Docker"
14 changes: 14 additions & 0 deletions files/opt/share/pihole/install_PADD.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

[ "$(id -u)" -ne 0 ] && { echo "Admin privileges required!"; exit 1; }
! command -v git >/dev/null 2>&1 && { echo "Command 'git' not found!"; exit 1; }

echo "This script will install and patch PADD."
read -rp "Press Enter to continue..."

set -e
cd /opt/share/pihole
wget -O padd.sh https://install.padd.sh
chmod +x padd.sh
git apply --include=padd.sh PADD.patch
echo "PADD has been installed. Run 'padd.sh' to start PADD."
8 changes: 8 additions & 0 deletions files/opt/share/pihole/polyfill/tput
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# 'tput colors' - used by COL_TABLE
# 'tput civis' - used by piholeDebug.sh
# 'tput cnorm' - used by piholeDebug.sh
# 'tput cols' - used by padd.sh
# 'tput lines' - used by padd.sh

case "$1" in
colors)
Expand All @@ -26,6 +28,12 @@ case "$1" in
cnorm)
echo -e "\e[?25h"
;;
cols)
stty size | cut -d' ' -f2
;;
lines)
stty size | cut -d' ' -f1
;;
*)
echo "'tput $1' - polyfill not implemented" >&2
exit 1
Expand Down
8 changes: 8 additions & 0 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ readonly script_dir="$(dirname "$(readlink -f "$0")")"
readonly repository_core="https://github.com/pi-hole/pi-hole.git"
readonly repository_web="https://github.com/pi-hole/web.git"
readonly repository_ftl="https://github.com/pi-hole/FTL.git"
readonly repository_padd="https://github.com/pi-hole/PADD.git"

shallow=true
[ -f "$script_dir/../dev/noshallow" ] && shallow=false
Expand Down Expand Up @@ -76,16 +77,19 @@ case $branch in
core_branch=master
web_branch=master
ftl_branch=master
padd_branch=master
;;
"dev")
core_branch=development
web_branch=development
ftl_branch=development
padd_branch=development
;;
*)
core_branch=$branch
web_branch=$branch
ftl_branch=$branch
padd_branch=$branch
;;
esac

Expand All @@ -94,6 +98,7 @@ case $repo in
install_or_update_repository "$repository_core" "$script_dir/../dev/core" "$core_branch"
install_or_update_repository "$repository_web" "$script_dir/../dev/web" "$web_branch"
install_or_update_repository "$repository_ftl" "$script_dir/../dev/FTL" "$ftl_branch"
install_or_update_repository "$repository_padd" "$script_dir/../dev/PADD" "master"
;;
core)
install_or_update_repository "$repository_core" "$script_dir/../dev/core" "$core_branch"
Expand All @@ -104,6 +109,9 @@ case $repo in
ftl|FTL)
install_or_update_repository "$repository_ftl" "$script_dir/../dev/FTL" "$ftl_branch"
;;
pad|PADD)
install_or_update_repository "$repository_web" "$script_dir/../dev/PADD" "$padd_branch"
;;
*)
echo "Invalid repo selected, valid values: all, core, web, FTL"
exit 1
Expand Down

0 comments on commit cc08211

Please # to comment.