refactor navidrome (#4120)

This commit is contained in:
CanbiZ 2025-04-29 11:56:49 +02:00 committed by GitHub
parent a2fdb4e236
commit aada00ce61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 74 deletions

View file

@ -1,9 +1,9 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.navidrome.org/
# Source: https://github.com/navidrome/navidrome
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
@ -13,67 +13,30 @@ setting_up_container
network_check
update_os
msg_info "Installing Dependencies (patience)"
$STD apt-get install -y ffmpeg
msg_info "Installing Dependencies (Patience)"
$STD apt-get install -y \
ffmpeg
msg_ok "Installed Dependencies"
msg_info "Installing Navidrome"
RELEASE=$(curl -fsSL https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
install -d -o root -g root /opt/navidrome
install -d -o root -g root /var/lib/navidrome
curl -fsSL "https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_linux_amd64.tar.gz" -o "Navidrome.tar.gz"
$STD tar -xvzf Navidrome.tar.gz -C /opt/navidrome/
chown -R root:root /opt/navidrome
chmod +x /opt/navidrome/navidrome
mkdir -p /music
cat <<EOF >/var/lib/navidrome/navidrome.toml
MusicFolder = '/music'
EOF
RELEASE=$(curl -fsSL https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk -F '"' '{print $4}')
TMP_DEB=$(mktemp --suffix=.deb)
curl -fsSL -o "${TMP_DEB}" "https://github.com/navidrome/navidrome/releases/download/${RELEASE}/navidrome_${RELEASE#v}_linux_amd64.deb"
$STD apt-get install -y "${TMP_DEB}"
systemctl enable -q --now navidrome
echo "${RELEASE}" >/opt/Navidrome_version.txt
msg_ok "Installed Navidrome"
msg_info "Creating Service"
service_path="/etc/systemd/system/navidrome.service"
echo "[Unit]
Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic
After=remote-fs.target network.target
AssertPathExists=/var/lib/navidrome
[Service]
User=root
Group=root
Type=simple
ExecStart=/opt/navidrome/navidrome --configfile '/var/lib/navidrome/navidrome.toml'
WorkingDirectory=/var/lib/navidrome
TimeoutStopSec=20
KillMode=process
Restart=on-failure
DevicePolicy=closed
NoNewPrivileges=yes
PrivateTmp=yes
PrivateUsers=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
ReadWritePaths=/var/lib/navidrome
ProtectSystem=full
[Install]
WantedBy=multi-user.target" >$service_path
systemctl daemon-reload
systemctl enable -q --now navidrome
msg_ok "Created Service"
read -p "Do you want to install filebrowser addon? (y/n) " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/filebrowser.sh)"
fi
motd_ssh
customize
msg_info "Cleaning up"
rm -f "${TMP_DEB}"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
rm -rf /root/Navidrome.tar.gz
msg_ok "Cleaned"