From 4022b335508dd2a268c9e05b4aa9ffa6a3f06c54 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Tue, 24 Dec 2024 09:22:05 +0100 Subject: [PATCH] Pi-hole and Prowlarr: adjust module options to match changes --- tools/json/config.software.json | 58 +++++++++---- tools/modules/software/module_netdata.sh | 2 +- tools/modules/software/module_nextcloud.sh | 2 +- tools/modules/software/module_owncloud.sh | 2 +- tools/modules/software/module_phpmyadmin.sh | 2 +- .../{install_pi-hole.sh => module_pi-hole.sh} | 86 ++++++++++--------- ...install_prowlarr.sh => module_prowlarr.sh} | 22 +++-- 7 files changed, 105 insertions(+), 69 deletions(-) rename tools/modules/software/{install_pi-hole.sh => module_pi-hole.sh} (50%) rename tools/modules/software/{install_prowlarr.sh => module_prowlarr.sh} (80%) diff --git a/tools/json/config.software.json b/tools/json/config.software.json index 41a8c1b7e..c123bdb35 100644 --- a/tools/json/config.software.json +++ b/tools/json/config.software.json @@ -6,7 +6,7 @@ "sub": [ { "id": "WebHosting", - "description": "Web hosting", + "description": "Web server, LEMP, reverse proxy, Let's Encrypt SSL", "status": "Stable", "sub": [ { @@ -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", @@ -707,7 +707,7 @@ }, { "id": "RDR001", - "description": "Install Readarr", + "description": "Readarr ebook collection manager install", "command": [ "module_readarr install" ], @@ -717,7 +717,7 @@ }, { "id": "RDR002", - "description": "Remove Readarr", + "description": "Readarr ebook collection manager remove", "command": [ "module_readarr remove" ], @@ -727,7 +727,7 @@ }, { "id": "RDR003", - "description": "Remove Readarr", + "description": "Readarr ebook collection manager purge", "command": [ "module_readarr purge" ], @@ -737,7 +737,7 @@ }, { "id": "DOW025", - "description": "Install Prowlarr", + "description": "Prowlarr index manager install ", "command": [ "module_prowlarr install" ], @@ -747,7 +747,7 @@ }, { "id": "DOW026", - "description": "Remove Prowlarr", + "description": "Prowlarr index manager remove", "command": [ "module_prowlarr remove" ], @@ -755,6 +755,16 @@ "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", @@ -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" } ] }, @@ -919,7 +939,7 @@ }, { "id": "HomeAutomation", - "description": "Home Automation", + "description": "Home Automation for monitoring and/or control home appliances", "sub": [ { "id": "HA001", @@ -985,7 +1005,7 @@ }, { "id": "Containers", - "description": "Containerlization and Virtual Machines", + "description": "Docker containerization and KVM virtual machines", "sub": [ { "id": "CON001", diff --git a/tools/modules/software/module_netdata.sh b/tools/modules/software/module_netdata.sh index 29bb802ff..fe83d4bce 100644 --- a/tools/modules/software/module_netdata.sh +++ b/tools/modules/software/module_netdata.sh @@ -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 \ diff --git a/tools/modules/software/module_nextcloud.sh b/tools/modules/software/module_nextcloud.sh index 2fc8920eb..028ef8a57 100644 --- a/tools/modules/software/module_nextcloud.sh +++ b/tools/modules/software/module_nextcloud.sh @@ -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 \ diff --git a/tools/modules/software/module_owncloud.sh b/tools/modules/software/module_owncloud.sh index 496478646..7c2022a8d 100644 --- a/tools/modules/software/module_owncloud.sh +++ b/tools/modules/software/module_owncloud.sh @@ -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 \ diff --git a/tools/modules/software/module_phpmyadmin.sh b/tools/modules/software/module_phpmyadmin.sh index 3b048035f..6b6062c32 100644 --- a/tools/modules/software/module_phpmyadmin.sh +++ b/tools/modules/software/module_phpmyadmin.sh @@ -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 \ diff --git a/tools/modules/software/install_pi-hole.sh b/tools/modules/software/module_pi-hole.sh similarity index 50% rename from tools/modules/software/install_pi-hole.sh rename to tools/modules/software/module_pi-hole.sh index 99a66bbac..ce0fe74a5 100644 --- a/tools/modules/software/install_pi-hole.sh +++ b/tools/modules/software/module_pi-hole.sh @@ -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"]} " - 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 @@ -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)" \ @@ -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"]} " + 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 diff --git a/tools/modules/software/install_prowlarr.sh b/tools/modules/software/module_prowlarr.sh similarity index 80% rename from tools/modules/software/install_prowlarr.sh rename to tools/modules/software/module_prowlarr.sh index 5721d9bf9..b13c77dc7 100644 --- a/tools/modules/software/install_prowlarr.sh +++ b/tools/modules/software/module_prowlarr.sh @@ -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" ) # @@ -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)" \ @@ -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"]} " 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 }