#!/bin/sh# It is possible for a user to delete the configuration file in such a way that# the package manager (in particular, deb) thinks that the file exists, while it is# no longer on disk. Specifically, doing a `rm /etc/navidrome/navidrome.toml`# without something like `apt purge navidrome` will result in the system believing that# the file still exists. In this case, during install it will NOT extract the configuration# file (as to not override it). Since `navidrome service install` depends on this file existing,# we will create it with the defaults anyway.if [ ! -f /etc/navidrome/navidrome.toml ]; thenprintf "No navidrome.toml detected, creating in postinstall\n"printf "DataFolder = \"/var/lib/navidrome\"\n" > /etc/navidrome/navidrome.tomlprintf "MusicFolder = \"/opt/navidrome/music\"\n" >> /etc/navidrome/navidrome.tomlfi# Older versions created these folders as root when this script ran `navidrome`. They were created empty,# so no -R. Real dirs only, never following links: navidrome owns /var/lib/navidrome and could plant symlinks.find /var/lib/navidrome/cache /var/lib/navidrome/artwork /var/lib/navidrome/plugins -maxdepth 0 -type d -user root -exec chown -h navidrome:navidrome {} + 2>/dev/nullpostinstall_flag="/var/lib/navidrome/.installed"if [ ! -f "$postinstall_flag" ]; then# The primary reason why this would fail is if the service was already installed AND# someone manually removed the .installed flag. In this case, ignore the errornavidrome service install --user navidrome --working-directory /var/lib/navidrome --configfile /etc/navidrome/navidrome.toml || :touch "$postinstall_flag"elsenavidrome service stop --configfile /etc/navidrome/navidrome.toml && navidrome service start --configfile /etc/navidrome/navidrome.tomlfi