Created | Author | GitHub | Contact |
---|---|---|---|
2023/08/31 |
Naty S @eclecticpassions |
On the official Navidrome Linux install guide, they only provided steps on how to create a systemd unit
and how to start the service using sudo systemctl
.
https://www.navidrome.org/docs/installation/linux/
But for those using Linux distros without systemd like AntiX, Devuan, Alpine, Artix, MX Linux etc, you have to convert the provided systemd unit template and place it in another folder instead of /etc/systemd/system/
named navidrome.service
.
Use the following template to create a SysV init script. Change <user>
and <group>
to your appropriate user and group for your server.
#!/bin/sh
### BEGIN INIT INFO
# Provides: navidrome
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop Navidrome Music Server
### END INIT INFO
USER=<user>
GROUP=<group>
DAEMON=/opt/navidrome/navidrome
CONFIGFILE="/var/lib/navidrome/navidrome.toml"
WORKINGDIR=/var/lib/navidrome
PIDFILE=/var/run/navidrome.pid
DAEMON_OPTS="--configfile $CONFIGFILE"
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting Navidrome Music Server"
start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE --chuid $USER:$GROUP --chdir $WORKINGDIR --exec $DAEMON -- $DAEMON_OPTS
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping Navidrome Music Server"
start-stop-daemon --stop --pidfile $PIDFILE --verbose
log_end_msg $?
;;
restart|force-reload)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/navidrome {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
Save the init script in the directory: /etc/init.d/
Call it navidrome
(or whatever you prefer)
Give the script the right permission:
chmod +x /etc/init.d/navidrome
Create the configuration file as per the official guide:
cd /var/lib/navidrome
sudo nano navidrome.toml
Use these commands to start, restart, stop or check status of the Navidrome service:
sudo service navidrome start
sudo service navidrome force-reload
sudo service navidrome stop
sudo service navidrome status
If you have ufw
running, remember to allow Navidrome:
sudo ufw allow 4533/tcp
sudo ufw allow navidrome
sudo ufw reload
To make Navidrome start on boot:
update-rc.d navidrome defaults
To remove Navidrome from startup (-f
forces symlinks to be removed):
update-rc.d -f navidrome remove
You should now have Navidrome installed and running on Linux without systemd.
Please be aware that systemd units have more security features compared to the more simple SysV init system. For example, the following features in the original systemd unit template provided by Navidrome are not available on SysV init:
ProtectSystem
PrivateTmp
PrivateUsers
ProtectControlGroups
ProtectKernelModules
ProtectKernelTunables
RestrictAddressFamilies
RestrictNamespaces
RestrictRealtime
Hope this helps!