Skip to content

Commit aada00c

Browse files
authored
refactor navidrome (#4120)
1 parent a2fdb4e commit aada00c

File tree

2 files changed

+47
-76
lines changed

2 files changed

+47
-76
lines changed

ct/navidrome.sh

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3-
# Copyright (c) 2021-2025 tteck
4-
# Author: tteck (tteckster)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: MickLesk (CanbiZ)
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6-
# Source: https://www.navidrome.org/
6+
# Source: https://github.com/navidrome/navidrome
77

88
APP="Navidrome"
99
var_tags="${var_tags:-music}"
@@ -23,27 +23,35 @@ function update_script() {
2323
header_info
2424
check_container_storage
2525
check_container_resources
26-
if [[ ! -d /opt/navidrome ]]; then
26+
if [[ ! -d /var/lib/navidrome ]]; then
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
RELEASE=$(curl -fsSL https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31-
msg_info "Stopping ${APP}"
32-
systemctl stop navidrome
33-
msg_ok "Stopped Navidrome"
34-
35-
msg_info "Updating to v${RELEASE}"
36-
cd /opt
37-
curl -fsSL "https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_linux_amd64.tar.gz" -o "Navidrome.tar.gz"
38-
$STD tar -xvzf Navidrome.tar.gz -C /opt/navidrome/
39-
chmod +x /opt/navidrome/navidrome
40-
msg_ok "Updated ${APP}"
41-
rm -rf /opt/Navidrome.tar.gz
42-
43-
msg_info "Starting ${APP}"
44-
systemctl start navidrome.service
45-
msg_ok "Started ${APP}"
46-
msg_ok "Updated Successfully"
30+
RELEASE=$(curl -fsSL https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk -F '"' '{print $4}')
31+
if [[ ! -f /opt/${APP}_version.txt ]]; then touch /opt/${APP}_version.txt; fi
32+
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
33+
msg_info "Stopping Services"
34+
systemctl stop navidrome
35+
msg_ok "Services Stopped"
36+
37+
msg_info "Updating ${APP} to ${RELEASE}"
38+
TMP_DEB=$(mktemp --suffix=.deb)
39+
curl -fsSL -o "${TMP_DEB}" "https://github.com/navidrome/navidrome/releases/download/${RELEASE}/navidrome_${RELEASE#v}_linux_amd64.deb"
40+
$STD apt-get install -y "${TMP_DEB}"
41+
echo "${RELEASE}" >/opt/"${APP}_version.txt"
42+
msg_ok "Updated Navidrome"
43+
44+
msg_info "Starting Services"
45+
systemctl start navidrome
46+
msg_ok "Started Services"
47+
48+
msg_info "Cleaning Up"
49+
rm -f "${TMP_DEB}"
50+
msg_ok "Cleaned"
51+
msg_ok "Updated Successfully"
52+
else
53+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
54+
fi
4755
exit
4856
}
4957

@@ -54,4 +62,4 @@ description
5462
msg_ok "Completed Successfully!\n"
5563
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
5664
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
57-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4533${CL}"
65+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4533${CL}"

install/navidrome-install.sh

Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22

3-
# Copyright (c) 2021-2025 tteck
4-
# Author: tteck (tteckster)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: MickLesk (CanbiZ)
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6-
# Source: https://www.navidrome.org/
6+
# Source: https://github.com/navidrome/navidrome
77

88
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
99
color
@@ -13,67 +13,30 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Dependencies (patience)"
17-
$STD apt-get install -y ffmpeg
16+
msg_info "Installing Dependencies (Patience)"
17+
$STD apt-get install -y \
18+
ffmpeg
1819
msg_ok "Installed Dependencies"
1920

2021
msg_info "Installing Navidrome"
21-
RELEASE=$(curl -fsSL https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
22-
install -d -o root -g root /opt/navidrome
23-
install -d -o root -g root /var/lib/navidrome
24-
curl -fsSL "https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_linux_amd64.tar.gz" -o "Navidrome.tar.gz"
25-
$STD tar -xvzf Navidrome.tar.gz -C /opt/navidrome/
26-
chown -R root:root /opt/navidrome
27-
chmod +x /opt/navidrome/navidrome
28-
mkdir -p /music
29-
cat <<EOF >/var/lib/navidrome/navidrome.toml
30-
MusicFolder = '/music'
31-
EOF
32-
msg_ok "Installed Navidrome"
33-
34-
msg_info "Creating Service"
35-
service_path="/etc/systemd/system/navidrome.service"
36-
37-
echo "[Unit]
38-
Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic
39-
After=remote-fs.target network.target
40-
AssertPathExists=/var/lib/navidrome
41-
42-
[Service]
43-
User=root
44-
Group=root
45-
Type=simple
46-
ExecStart=/opt/navidrome/navidrome --configfile '/var/lib/navidrome/navidrome.toml'
47-
WorkingDirectory=/var/lib/navidrome
48-
TimeoutStopSec=20
49-
KillMode=process
50-
Restart=on-failure
51-
DevicePolicy=closed
52-
NoNewPrivileges=yes
53-
PrivateTmp=yes
54-
PrivateUsers=yes
55-
ProtectControlGroups=yes
56-
ProtectKernelModules=yes
57-
ProtectKernelTunables=yes
58-
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
59-
RestrictNamespaces=yes
60-
RestrictRealtime=yes
61-
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
62-
ReadWritePaths=/var/lib/navidrome
63-
ProtectSystem=full
64-
65-
[Install]
66-
WantedBy=multi-user.target" >$service_path
67-
systemctl daemon-reload
22+
RELEASE=$(curl -fsSL https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk -F '"' '{print $4}')
23+
TMP_DEB=$(mktemp --suffix=.deb)
24+
curl -fsSL -o "${TMP_DEB}" "https://github.com/navidrome/navidrome/releases/download/${RELEASE}/navidrome_${RELEASE#v}_linux_amd64.deb"
25+
$STD apt-get install -y "${TMP_DEB}"
6826
systemctl enable -q --now navidrome
27+
echo "${RELEASE}" >/opt/Navidrome_version.txt
28+
msg_ok "Installed Navidrome"
6929

70-
msg_ok "Created Service"
30+
read -p "Do you want to install filebrowser addon? (y/n) " -n 1 -r
31+
if [[ $REPLY =~ ^[Yy]$ ]]; then
32+
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/filebrowser.sh)"
33+
fi
7134

7235
motd_ssh
7336
customize
7437

7538
msg_info "Cleaning up"
39+
rm -f "${TMP_DEB}"
7640
$STD apt-get -y autoremove
7741
$STD apt-get -y autoclean
78-
rm -rf /root/Navidrome.tar.gz
7942
msg_ok "Cleaned"

0 commit comments

Comments
 (0)