From 8a0d793a556a4df9bd6a2023843db4bec42ea0a1 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 22 May 2023 18:07:04 -0400 Subject: improvements --- push-btrfs.service | 9 ++++++++- push-btrfs.timer | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/push-btrfs.service b/push-btrfs.service index ec9d3cd..7d32080 100644 --- a/push-btrfs.service +++ b/push-btrfs.service @@ -1,10 +1,17 @@ [Unit] Description = Btrfs Backup over SSH ConditionUser = root +ConditionPathExistsGlob = /etc/btrfs-backup/remotes/*.json [Service] WorkingDirectory = /etc/btrfs-backup/remotes -ExecStart = bash -c 'shopt -s nullglob; for f in *.json; do (set -x; systemctl enable push-btrfs@$$f.timer); done' +ExecStart = bash -e -c 'shopt -s failglob; \ + units=(*.json); \ + units=($${units[@]/.json/.timer}); \ + units=($${units[@]/#/%p@}); \ + systemctl enable "$${units[@]}"; \ + entr -pnd -- true <<< . || true; \ + ' [Install] WantedBy=default.target diff --git a/push-btrfs.timer b/push-btrfs.timer index 982df5c..4bfb418 100644 --- a/push-btrfs.timer +++ b/push-btrfs.timer @@ -1,3 +1,7 @@ +[Unit] +Description = Btrfs Backup over SSH +ConditionPathExistsGlob = /etc/btrfs-backup/remotes/*.json + [Timer] OnUnitInactiveSec=5 -- cgit v1.2.3