Skip to content

Commit

Permalink
Pi-hole and Prowlarr: adjust module options to match changes
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Dec 24, 2024
1 parent 97e4c34 commit 4022b33
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 69 deletions.
58 changes: 39 additions & 19 deletions tools/json/config.software.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"sub": [
{
"id": "WebHosting",
"description": "Web hosting",
"description": "Web server, LEMP, reverse proxy, Let's Encrypt SSL",
"status": "Stable",
"sub": [
{
Expand Down Expand Up @@ -406,7 +406,7 @@
},
{
"id": "Downloaders",
"description": "Download tools",
"description": "P2P download tools and managers for movies, TV shows, music and subtitles",
"sub": [
{
"id": "DOW001",
Expand Down Expand Up @@ -707,7 +707,7 @@
},
{
"id": "RDR001",
"description": "Install Readarr",
"description": "Readarr ebook collection manager install",
"command": [
"module_readarr install"
],
Expand All @@ -717,7 +717,7 @@
},
{
"id": "RDR002",
"description": "Remove Readarr",
"description": "Readarr ebook collection manager remove",
"command": [
"module_readarr remove"
],
Expand All @@ -727,7 +727,7 @@
},
{
"id": "RDR003",
"description": "Remove Readarr",
"description": "Readarr ebook collection manager purge",
"command": [
"module_readarr purge"
],
Expand All @@ -737,7 +737,7 @@
},
{
"id": "DOW025",
"description": "Install Prowlarr",
"description": "Prowlarr index manager install ",
"command": [
"module_prowlarr install"
],
Expand All @@ -747,14 +747,24 @@
},
{
"id": "DOW026",
"description": "Remove Prowlarr",
"description": "Prowlarr index manager remove",
"command": [
"module_prowlarr remove"
],
"status": "Stable",
"author": "@armbian",
"condition": "module_prowlarr status"
},
{
"id": "DOW027",
"description": "Prowlarr index manager purge",
"command": [
"module_prowlarr purge"
],
"status": "Stable",
"author": "@armbian",
"condition": "module_prowlarr status"
},
{
"id": "JEL001",
"description": "Jellyseerr Jellyfin/Emby/Plex integration install",
Expand Down Expand Up @@ -855,37 +865,47 @@
},
{
"id": "DNS",
"description": "DNS blockers",
"description": "DNS ad blockers",
"sub": [
{
"id": "DNS001",
"description": "Install Pi-hole DNS ad blocker",
"description": "Pi-hole DNS ad blocker install",
"command": [
"pi_hole install"
"module_pi_hole install"
],
"status": "Stable",
"author": "@armbian",
"condition": "! pi_hole status"
"condition": "! module_pi_hole status"
},
{
"id": "DNS002",
"description": "Set Pi-hole web admin password",
"description": "Pi-hole web admin password",
"command": [
"pi_hole password"
"module_pi_hole password"
],
"status": "Stable",
"author": "@armbian",
"condition": "pi_hole status"
"condition": "module_pi_hole status"
},
{
"id": "DNS003",
"description": "Remove Pi-hole DNS ad blocker",
"description": "Pi-hole DNS ad blocker remove",
"command": [
"module_pi_hole remove"
],
"status": "Stable",
"author": "@armbian",
"condition": "module_pi_hole status"
},
{
"id": "DNS004",
"description": "Pi-hole DNS ad blocker purge",
"command": [
"pi_hole uninstall"
"module_pi_hole remove"
],
"status": "Stable",
"author": "@armbian",
"condition": "pi_hole status"
"condition": "module_pi_hole status"
}
]
},
Expand Down Expand Up @@ -919,7 +939,7 @@
},
{
"id": "HomeAutomation",
"description": "Home Automation",
"description": "Home Automation for monitoring and/or control home appliances",
"sub": [
{
"id": "HA001",
Expand Down Expand Up @@ -985,7 +1005,7 @@
},
{
"id": "Containers",
"description": "Containerlization and Virtual Machines",
"description": "Docker containerization and KVM virtual machines",
"sub": [
{
"id": "CON001",
Expand Down
2 changes: 1 addition & 1 deletion tools/modules/software/module_netdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function module_netdata () {

case "$1" in
"${commands[0]}")
pkg_installed docker-ce || install_docker
pkg_installed docker-ce || module_docker install
[[ -d "$NETDATA_BASE" ]] || mkdir -p "$NETDATA_BASE" || { echo "Couldn't create storage directory: $NETDATA_BASE"; exit 1; }
docker run -d \
--name=netdata \
Expand Down
2 changes: 1 addition & 1 deletion tools/modules/software/module_nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function module_nextcloud () {

case "$1" in
"${commands[0]}")
pkg_installed docker-ce || install_docker
pkg_installed docker-ce || module_docker install
[[ -d "$NEXTCLOUD_BASE" ]] || mkdir -p "$NEXTCLOUD_BASE" || { echo "Couldn't create storage directory: $NEXTCLOUD_BASE"; exit 1; }
docker run -d \
--name=nextcloud \
Expand Down
2 changes: 1 addition & 1 deletion tools/modules/software/module_owncloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function module_owncloud () {

case "$1" in
"${commands[0]}")
pkg_installed docker-ce || install_docker
pkg_installed docker-ce || module_docker install
[[ -d "$OWNCLOUD_BASE" ]] || mkdir -p "$OWNCLOUD_BASE" || { echo "Couldn't create storage directory: $OWNCLOUD_BASE"; exit 1; }
docker run -d \
--name=owncloud \
Expand Down
2 changes: 1 addition & 1 deletion tools/modules/software/module_phpmyadmin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function module_phpmyadmin () {

case "$1" in
"${commands[0]}")
pkg_installed docker-ce || install_docker
pkg_installed docker-ce || module_docker install
[[ -d "$PHPMYADMIN_BASE" ]] || mkdir -p "$PHPMYADMIN_BASE" || { echo "Couldn't create storage directory: $PHPMYADMIN_BASE"; exit 1; }
docker run -d \
--name=phpmyadmin \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@

module_options+=(
["pi_hole,author"]="@armbian"
["pi_hole,ref_link"]=""
["pi_hole,feature"]="pi_hole"
["pi_hole,desc"]="Install/uninstall/check status of pi-hole container"
["pi_hole,example"]="help install uninstall status password"
["pi_hole,status"]="Active"
["module_pi_hole,author"]="@armbian"
["module_pi_hole,maintainer"]="@igorpecovnik"
["module_pi_hole,feature"]="module_pi_hole"
["module_pi_hole,example"]="install remove purge password status help"
["module_pi_hole,desc"]="Install Pi-hole container"
["module_pi_hole,status"]="Active"
["module_pi_hole,doc_link"]="https://docs.pi-hole.net/"
["module_pi_hole,group"]="DNS"
["module_pi_hole,port"]="80"
["module_pi_hole,arch"]="x86-64 arm64"
)
#
# Install Pi-Hole DNS blocking
# Module Pi-Hole
#
function pi_hole () {
function module_pi_hole () {
local title="pihole"
local condition=$(which "$title" 2>/dev/null)

if pkg_installed docker-ce; then
local container=$(docker container ls -a | mawk '/pihole?( |$)/{print $1}')
local image=$(docker image ls -a | mawk '/pihole?( |$)/{print $3}')
fi
local commands
IFS=' ' read -r -a commands <<< "${module_options["pi_hole,example"]}"
IFS=' ' read -r -a commands <<< "${module_options["module_pi_hole,example"]}"

PIHOLE_BASE=/opt/pihole-storage
PIHOLE_BASE="${PIHOLE_BASE:-$(pwd)}"
[[ -d "$PIHOLE_BASE" ]] || mkdir -p "$PIHOLE_BASE" || { echo "Couldn't create storage directory: $PIHOLE_BASE"; exit 1; }
PIHOLE_BASE="${SOFTWARE_FOLDER}/pihole"

case "$1" in
"${commands[0]}")
## help/menu options for the module
echo -e "\nUsage: ${module_options["pi_hole,feature"]} <command>"
echo -e "Commands: ${module_options["pi_hole,example"]}"
echo "Available commands:"
if [[ "${container}" ]] || [[ "${image}" ]]; then
echo -e "\tstatus\t- Show the status of the $title service."
echo -e "\tremove\t- Remove $title."
else
echo -e " install\t- Install $title."
fi
echo
;;
install)

pkg_installed docker-ce || install_docker

pkg_installed docker-ce || module_docker install
[[ -d "$PIHOLE_BASE" ]] || mkdir -p "$PIHOLE_BASE" || { echo "Couldn't create storage directory: $PIHOLE_BASE"; exit 1; }
# disable dns within systemd-resolved
if systemctl is-active --quiet systemd-resolved.service && ! grep -q "^DNSStubListener=no" /etc/systemd/resolved.conf; then
sed -i "s/^#\?DNSStubListener=.*/DNSStubListener=no/" /etc/systemd/resolved.conf
Expand All @@ -53,9 +42,9 @@ function pi_hole () {
systemctl restart NetworkManager
sleep 3
fi

docker run -d \
--name pihole \
--net=lsio \
-p 53:53/tcp -p 53:53/udp \
-p 80:80 \
-e TZ="$(cat /etc/timezone)" \
Expand All @@ -68,34 +57,53 @@ function pi_hole () {
-e PROXY_LOCATION="pi.hole" \
-e FTLCONF_LOCAL_IPV4="${LOCALIPADD}" \
pihole/pihole:latest

for i in $(seq 1 20); do
if [ "$(docker inspect -f "{{.State.Health.Status}}" pihole)" == "healthy" ] ; then
if docker inspect -f '{{ index .Config.Labels "build_version" }}' pihole >/dev/null 2>&1 ; then
break
else
sleep 3
fi
if [ $i -eq 20 ] ; then
echo -e "\nTimed out waiting for Pi-hole start, consult your container logs for more info (\`docker logs pihole\`)"
echo -e "\nTimed out waiting for ${title} to start, consult your container logs for more info (\`docker logs pihole\`)"
exit 1
fi
done
;;

uninstall)
"${commands[1]}")
[[ "${container}" ]] && docker container rm -f "$container" >/dev/null
[[ "${image}" ]] && docker image rm "$image" >/dev/null
;;
password)
"${commands[2]}")
${module_options["module_pi_hole,feature"]} ${commands[1]}
[[ -n "${PIHOLE_BASE}" && "${PIHOLE_BASE}" != "/" ]] && rm -rf "${PIHOLE_BASE}"
;;
"${commands[3]}")
SELECTED_PASSWORD=$($DIALOG --title "Enter new password for Pi-hole admin" --passwordbox "" 7 50 3>&1 1>&2 2>&3)
if [[ -n $SELECTED_PASSWORD ]]; then
docker exec -it "${container}" sh -c "sudo pihole -a -p ${SELECTED_PASSWORD}" >/dev/null
fi
;;
status)
[[ "${container}" ]] || [[ "${image}" ]] && return 0
"${commands[4]}")
if [[ "${container}" && "${image}" ]]; then
return 0
else
return 1
fi
;;
"${commands[5]}")
echo -e "\nUsage: ${module_options["module_pi_hole,feature"]} <command>"
echo -e "Commands: ${module_options["module_pi_hole,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Install $title."
echo -e "\tremove\t- Remove $title."
echo -e "\tpurge\t- Purge $title."
echo -e "\tstatus\t- Installation status $title."
echo -e "\tpassword\t- Set webadmin password $title."
echo
;;
*)
${module_options["module_pi_hole,feature"]} ${commands[4]}
;;
esac
}

#pi_hole help
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module_options+=(
["module_prowlarr,author"]="@armbian"
["module_prowlarr,author"]="@Prowlarr"
["module_prowlarr,maintainer"]="@armbian"
["module_prowlarr,feature"]="module_prowlarr"
["module_prowlarr,example"]="install remove purge status help"
["module_prowlarr,desc"]="Install prowlarr container"
["module_prowlarr,example"]="install remove status help"
["module_prowlarr,port"]="9696"
["module_prowlarr,status"]="Active"
["module_prowlarr,doc_link"]="https://prowlarr.com/"
["module_prowlarr,group"]="Database"
["module_prowlarr,port"]="9696"
["module_prowlarr,arch"]="x86-64,arm64"
)
#
Expand All @@ -26,10 +29,11 @@ function module_prowlarr () {

case "$1" in
"${commands[0]}")
pkg_installed docker-ce || install_docker
pkg_installed docker-ce || module_docker install
[[ -d "$PROWLARR_BASE" ]] || mkdir -p "$PROWLARR_BASE" || { echo "Couldn't create storage directory: $PROWLARR_BASE"; exit 1; }
docker run -d \
--name=prowlarr \
--net=lsio \
-e PUID=1000 \
-e PGID=1000 \
-e TZ="$(cat /etc/timezone)" \
Expand All @@ -52,26 +56,30 @@ function module_prowlarr () {
"${commands[1]}")
[[ "${container}" ]] && docker container rm -f "$container" >/dev/null
[[ "${image}" ]] && docker image rm "$image" >/dev/null
[[ -n "${PROWLARR_BASE}" && "${PROWLARR_BASE}" != "/" ]] && rm -rf "${PROWLARR_BASE}"
;;
"${commands[2]}")
${module_options["module_prowlarr,feature"]} ${commands[1]}
[[ -n "${PROWLARR_BASE}" && "${PROWLARR_BASE}" != "/" ]] && rm -rf "${PROWLARR_BASE}"
;;
"${commands[3]}")
if [[ "${container}" && "${image}" ]]; then
return 0
else
return 1
fi
;;
"${commands[3]}")
"${commands[4]}")
echo -e "\nUsage: ${module_options["module_prowlarr,feature"]} <command>"
echo -e "Commands: ${module_options["module_prowlarr,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Install $title."
echo -e "\tstatus\t- Installation status $title."
echo -e "\tremove\t- Remove $title."
echo -e "\tpurge\t- Purge $title."
echo
;;
*)
${module_options["module_prowlarr,feature"]} ${commands[3]}
${module_options["module_prowlarr,feature"]} ${commands[4]}
;;
esac
}

0 comments on commit 4022b33

Please sign in to comment.