From 39ab88cf0c221ad37501142d9a3a3f159752a700 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 15 Dec 2022 12:09:31 +0000 Subject: [PATCH] rclone sync music to hetzner-vm as webdav 404s on some songs --- hosts/buildbox/buildbox.nix | 2 +- hosts/hetzner-vm/profiles/mpd.nix | 39 ++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/hosts/buildbox/buildbox.nix b/hosts/buildbox/buildbox.nix index 6b29655..d94c192 100644 --- a/hosts/buildbox/buildbox.nix +++ b/hosts/buildbox/buildbox.nix @@ -91,7 +91,7 @@ in { }; }; - systemd.services.mdadm-monitor = { + systemd.services.mdmonitor = { requires = ["network.target"]; wantedBy = ["multi-user.target"]; path = with pkgs; [mdadm msmtp]; diff --git a/hosts/hetzner-vm/profiles/mpd.nix b/hosts/hetzner-vm/profiles/mpd.nix index 3a65644..effe5cf 100644 --- a/hosts/hetzner-vm/profiles/mpd.nix +++ b/hosts/hetzner-vm/profiles/mpd.nix @@ -8,10 +8,47 @@ in { environment.systemPackages = with pkgs; [mpc_cli]; + systemd.tmpfiles.rules = [ + "d /Music - root root" + ]; + + systemd.services.music-sync = { + wantedBy = ["multi-user.target"]; + after = ["network.target"]; + partOf = ["mpd.service"]; + + path = with pkgs; [bash rclone mount umount]; + script = let + rclone_config = pkgs.writeText "rclone.conf" '' + [Music] + type = webdav + url = https://storage-webdav.owo.monster/music_ro/ + vendor = nextcloud + ''; + in '' + set -e + rclone --config ${rclone_config} sync Music: /Music + ''; + }; + + systemd.timers.music-sync = { + wantedBy = ["timers.target"]; + partOf = ["music-sync.service"]; + timerConfig.OnCalendar = "hourly"; + }; + + systemd.services.mpd = { + after = ["music-copy.service"]; + }; + services.mpd = { enable = true; network.listenAddress = "0.0.0.0"; - musicDirectory = "https://storage-webdav.owo.monster/music_ro/"; + dataDir = "/mpd"; + playlistDirectory = "/mpd/playlists"; + musicDirectory = "/Music"; + user = "root"; + group = "root"; credentials = [ { passwordFile = "${secrets.mpd_control_password.path}";