systemd sync service
This commit is contained in:
parent
964a5be64c
commit
dd69b17a01
2 changed files with 35 additions and 6 deletions
|
@ -4,6 +4,14 @@
|
|||
sync_user_remote = "Grimmauld";
|
||||
sync_server = "cloud.grimmauld.de";
|
||||
# cloud_cmd = "${pkgs.nextcloud-client}/bin/nextcloudcmd -u ${sync_user_remote} -p -h -n --path";
|
||||
sync_script = let
|
||||
cloud_cmd = ''${pkgs.nextcloud-client}/bin/nextcloudcmd -u ${sync_user_remote} -p "$(cat ${config.age.secrets.nextcloud_pass.path})" -h -n --path'';
|
||||
in ''
|
||||
${cloud_cmd} /3d /home/${sync_user}/3d https://${sync_server}
|
||||
${cloud_cmd} /Pictures /home/${sync_user}/Pictures https://${sync_server}
|
||||
${cloud_cmd} /Documents /home/${sync_user}/Documents https://${sync_server}
|
||||
${cloud_cmd} /Videos /home/${sync_user}/Videos https://${sync_server}
|
||||
'';
|
||||
in {
|
||||
age.secrets.nextcloud_pass = {
|
||||
file = ../secrets/nextcloud_pass.age;
|
||||
|
@ -15,11 +23,31 @@ in {
|
|||
cloud_cmd = ''${pkgs.nextcloud-client}/bin/nextcloudcmd -u ${sync_user_remote} -p "$(cat ${config.age.secrets.nextcloud_pass.path})" -h -n --path'';
|
||||
in with pkgs; [
|
||||
nextcloud-client
|
||||
(writeShellScriptBin "cloudsync" ''
|
||||
${cloud_cmd} /3d /home/${sync_user}/3d https://${sync_server}
|
||||
${cloud_cmd} /Pictures /home/${sync_user}/Pictures https://${sync_server}
|
||||
${cloud_cmd} /Documents /home/${sync_user}/Documents https://${sync_server}
|
||||
${cloud_cmd} /Videos /home/${sync_user}/Videos https://${sync_server}
|
||||
'')
|
||||
(writeShellScriptBin "cloudsync" sync_script)
|
||||
];
|
||||
|
||||
systemd = {
|
||||
services.nextcloud-autosync = {
|
||||
description = "Auto sync Nextcloud";
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
serviceConfig.Type = "simple";
|
||||
serviceConfig.User = sync_user;
|
||||
# serviceConfig.UID = 1000;
|
||||
serviceConfig.Group= "users";
|
||||
script= sync_script;
|
||||
# TimeoutStopSec = "180";
|
||||
# KillMode = "process";
|
||||
# KillSignal = "SIGINT";
|
||||
wantedBy = ["multi-user.target"];
|
||||
enable=true;
|
||||
};
|
||||
timers.nextcloud-autosync = {
|
||||
description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes";
|
||||
timerConfig.OnBootSec = "5min";
|
||||
timerConfig.OnUnitActiveSec = "60min";
|
||||
wantedBy = ["multi-user.target" "timers.target"];
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ in {
|
|||
pass
|
||||
libsecret
|
||||
tea
|
||||
acpi
|
||||
(writeShellScriptBin "passw" "pass $@")
|
||||
# nodejs_21 # ugh.... somehow nvim needs node now?!?
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue