From c433b1edd1d78448f547bf18f9e8ca9fae4b7d9f Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Fri, 10 Jan 2025 16:11:48 +0100 Subject: [PATCH] Software title: Navidrome Music Server and Streamer compatible with Subsonic/Airsonic --- tests/NAV001.conf | 11 +++ tools/json/config.software.json | 36 +++++++++ tools/modules/software/module_navidrome.sh | 85 ++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 tests/NAV001.conf create mode 100644 tools/modules/software/module_navidrome.sh diff --git a/tests/NAV001.conf b/tests/NAV001.conf new file mode 100644 index 000000000..22180852d --- /dev/null +++ b/tests/NAV001.conf @@ -0,0 +1,11 @@ +ENABLED=true +RELEASE="bookworm:noble" + +function testcase { + ./bin/armbian-config --api module_navidrome remove + ./bin/armbian-config --api module_navidrome install + container=$(docker container ls -a | mawk '/navidrome?( |$)/{print $1}') + if [[ -z "${container}" ]]; then + exit 1 + fi +} diff --git a/tools/json/config.software.json b/tools/json/config.software.json index f3f7184cb..0eaef4d36 100644 --- a/tools/json/config.software.json +++ b/tools/json/config.software.json @@ -169,6 +169,42 @@ } ] }, + { + "id": "Music", + "description": "Music servers and streamers", + "sub": [ + { + "id": "NAV001", + "description": "Navidrome music server and streamer compatible with Subsonic/Airsonic", + "command": [ + "module_navidrome install" + ], + "status": "Stable", + "author": "@armbian", + "condition": "! module_navidrome status" + }, + { + "id": "NAV002", + "description": "Navidrome remove", + "command": [ + "module_navidrome install" + ], + "status": "Stable", + "author": "@armbian", + "condition": "module_navidrome status" + }, + { + "id": "NAV003", + "description": "Navidrome purge with data folder", + "command": [ + "module_navidrome purge" + ], + "status": "Stable", + "author": "@armbian", + "condition": "module_navidrome status" + } + ] + }, { "id": "Desktops", "description": "Desktop Environments", diff --git a/tools/modules/software/module_navidrome.sh b/tools/modules/software/module_navidrome.sh new file mode 100644 index 000000000..fe7ee7b1f --- /dev/null +++ b/tools/modules/software/module_navidrome.sh @@ -0,0 +1,85 @@ +module_options+=( + ["module_navidrome,author"]="@armbian" + ["module_navidrome,maintainer"]="@igorpecovnik" + ["module_navidrome,feature"]="module_navidrome" + ["module_navidrome,example"]="install remove purge status help" + ["module_navidrome,desc"]="Install navidrome container" + ["module_navidrome,status"]="Active" + ["module_navidrome,doc_link"]="https://github.com/pynavidrome/navidrome/wiki" + ["module_navidrome,group"]="Downloaders" + ["module_navidrome,port"]="4533" + ["module_navidrome,arch"]="x86-64 arm64" +) +# +# Install Module navidrome +# +function module_navidrome () { + local title="navidrome" + local condition=$(which "$title" 2>/dev/null) + + if pkg_installed docker-ce; then + local container=$(docker container ls -a | mawk '/navidrome?( |$)/{print $1}') + local image=$(docker image ls -a | mawk '/navidrome?( |$)/{print $3}') + fi + + local commands + IFS=' ' read -r -a commands <<< "${module_options["module_navidrome,example"]}" + + NAVIDROME_BASE="${SOFTWARE_FOLDER}/navidrome" + + case "$1" in + "${commands[0]}") + pkg_installed docker-ce || module_docker install + [[ -d "$NAVIDROME_BASE" ]] || mkdir -p "$NAVIDROME_BASE" || { echo "Couldn't create storage directory: $NAVIDROME_BASE"; exit 1; } + docker run -d \ + --name=navidrome \ + --net=lsio \ + --user 1000:1000 \ + -e TZ="$(cat /etc/timezone)" \ + -p 4533:4533 \ + -v "${NAVIDROME_BASE}/music:/music" \ + -v "${NAVIDROME_BASE}/data:/data" \ + --restart unless-stopped \ + deluan/navidrome:latest + for i in $(seq 1 20); do + if docker inspect -f '{{ index .Config.Labels "build_version" }}' navidrome >/dev/null 2>&1 ; then + break + else + sleep 3 + fi + if [ $i -eq 20 ] ; then + echo -e "\nTimed out waiting for ${title} to start, consult your container logs for more info (\`docker logs navidrome\`)" + exit 1 + fi + done + ;; + "${commands[1]}") + [[ "${container}" ]] && docker container rm -f "$container" >/dev/null + [[ "${image}" ]] && docker image rm "$image" >/dev/null + ;; + "${commands[2]}") + ${module_options["module_navidrome,feature"]} ${commands[1]} + [[ -n "${NAVIDROME_BASE}" && "${NAVIDROME_BASE}" != "/" ]] && rm -rf "${NAVIDROME_BASE}" + ;; + "${commands[3]}") + if [[ "${container}" && "${image}" ]]; then + return 0 + else + return 1 + fi + ;; + "${commands[4]}") + echo -e "\nUsage: ${module_options["module_navidrome,feature"]} " + echo -e "Commands: ${module_options["module_navidrome,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_navidrome,feature"]} ${commands[4]} + ;; + esac +}