refactor rclone, use same serviceConfig for all mounts
This commit is contained in:
parent
8ffe43a441
commit
c67622ba36
1 changed files with 28 additions and 38 deletions
|
@ -4,41 +4,11 @@
|
|||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
systemd.services.immich-mount = {
|
||||
enable = true;
|
||||
description = "Mount the immich data remote";
|
||||
requires = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
requiredBy = [ "podman-immich-server.service" ];
|
||||
before = [ "podman-immich-server.service" ];
|
||||
serviceConfig = {
|
||||
let
|
||||
mkServiceConfig = remote: mount: {
|
||||
Type = "notify";
|
||||
ExecStartPre = "/usr/bin/env mkdir -p /mnt/photos";
|
||||
ExecStart = ''
|
||||
${lib.getExe pkgs.rclone} mount \
|
||||
--config ${config.sops.secrets."rclone/config".path} \
|
||||
--cache-dir /var/cache/rclone \
|
||||
--transfers=32 \
|
||||
--dir-cache-time 30d \
|
||||
--vfs-cache-mode writes \
|
||||
--vfs-cache-max-size 2G \
|
||||
photos: /mnt/photos
|
||||
'';
|
||||
ExecStop = "${lib.getExe' pkgs.fuse "fusermount"} -u /mnt/photos";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.garage-mount = {
|
||||
enable = true;
|
||||
description = "Mount the garage data remote";
|
||||
requires = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
requiredBy = [ "garage.service" ];
|
||||
before = [ "garage.service" ];
|
||||
serviceConfig = {
|
||||
Type = "notify";
|
||||
ExecStartPre = "/usr/bin/env mkdir -p /mnt/garage";
|
||||
TimeoutSec = "5min 20s";
|
||||
ExecStartPre = "/usr/bin/env mkdir -p ${mount}";
|
||||
ExecStart = ''
|
||||
${lib.getExe pkgs.rclone} mount \
|
||||
--config ${config.sops.secrets."rclone/config".path} \
|
||||
|
@ -52,12 +22,32 @@
|
|||
--no-modtime \
|
||||
--vfs-fast-fingerprint \
|
||||
--vfs-read-chunk-size 4M \
|
||||
--vfs-read-chunk-streams 64 \
|
||||
--vfs-read-chunk-streams 32 \
|
||||
--sftp-concurrency 128 \
|
||||
--sftp-chunk-size 255k \
|
||||
rsyncnet:garage /mnt/garage
|
||||
${remote} ${mount}
|
||||
'';
|
||||
ExecStop = "${lib.getExe' pkgs.fuse "fusermount"} -u /mnt/garage";
|
||||
ExecStop = "${lib.getExe' pkgs.fuse "fusermount"} -zu ${mount}";
|
||||
};
|
||||
in
|
||||
{
|
||||
systemd.services.immich-mount = {
|
||||
enable = true;
|
||||
description = "Mount the immich data remote";
|
||||
requires = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
requiredBy = [ "podman-immich-server.service" ];
|
||||
before = [ "podman-immich-server.service" ];
|
||||
serviceConfig = mkServiceConfig "photos:" "/mnt/photos";
|
||||
};
|
||||
|
||||
systemd.services.garage-mount = {
|
||||
enable = true;
|
||||
description = "Mount the garage data remote";
|
||||
requires = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
requiredBy = [ "garage.service" ];
|
||||
before = [ "garage.service" ];
|
||||
serviceConfig = mkServiceConfig "rsyncnet:garage" "/mnt/garage";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue