]> git.rmz.io Git - dotfiles.git/commitdiff
mbsync: only execute pre/post scripts if folders exists
authorSamir Benmendil <me@rmz.io>
Wed, 31 Aug 2022 21:36:08 +0000 (22:36 +0100)
committerSamir Benmendil <me@rmz.io>
Wed, 31 Aug 2022 21:42:12 +0000 (22:42 +0100)
Silences a bunch of regular warnings in logs.

mbsync/sync-mail

index e9cf8d9ac773958ca0ec2abacb1ce344c7c6f363..6ea0e426cca7e5aeb2d20e7b1ae8e3eb9a9e7f21 100755 (executable)
@@ -5,15 +5,21 @@ mbsync_args="$*"
 export dir="$(dirname "${BASH_SOURCE[0]}")"
 export config=$dir/config
 
 export dir="$(dirname "${BASH_SOURCE[0]}")"
 export config=$dir/config
 
-for hook in $(find $dir/pre-sync.d -type f -name '*.hook' -executable); do
-    "$hook" $mbsync_args
-done
+pre_sync_dir=$dir/pre-sync.d
+if [[ -d "$pre_sync_dir" ]]; then
+    for hook in $(find $pre_sync_dir -type f -name '*.hook' -executable); do
+        "$hook" $mbsync_args
+    done
+fi
 
 mbsync -c "$config" $mbsync_args
 export mbsync_errno=$?
 
 
 mbsync -c "$config" $mbsync_args
 export mbsync_errno=$?
 
-for hook in $(find $dir/post-sync.d -type f -name '*.hook' -executable); do
-    "$hook" $mbsync_args
-done
+post_sync_dir=$dir/post-sync.d
+if [[ -d "$post_sync_dir" ]]; then
+    for hook in $(find $post_sync_dir -type f -name '*.hook' -executable); do
+        "$hook" $mbsync_args
+    done
+fi
 
 exit $mbsync_errno
 
 exit $mbsync_errno