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,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
let
|
||||||
systemd.services.immich-mount = {
|
mkServiceConfig = remote: 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 = {
|
|
||||||
Type = "notify";
|
Type = "notify";
|
||||||
ExecStartPre = "/usr/bin/env mkdir -p /mnt/photos";
|
TimeoutSec = "5min 20s";
|
||||||
ExecStart = ''
|
ExecStartPre = "/usr/bin/env mkdir -p ${mount}";
|
||||||
${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";
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${lib.getExe pkgs.rclone} mount \
|
${lib.getExe pkgs.rclone} mount \
|
||||||
--config ${config.sops.secrets."rclone/config".path} \
|
--config ${config.sops.secrets."rclone/config".path} \
|
||||||
|
@ -52,12 +22,32 @@
|
||||||
--no-modtime \
|
--no-modtime \
|
||||||
--vfs-fast-fingerprint \
|
--vfs-fast-fingerprint \
|
||||||
--vfs-read-chunk-size 4M \
|
--vfs-read-chunk-size 4M \
|
||||||
--vfs-read-chunk-streams 64 \
|
--vfs-read-chunk-streams 32 \
|
||||||
--sftp-concurrency 128 \
|
--sftp-concurrency 128 \
|
||||||
--sftp-chunk-size 255k \
|
--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