summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-04-18 11:31:19 +0200
committertv <tv@krebsco.de>2019-04-18 11:43:00 +0200
commitc082c8d62be63c7acf31de37c4b87a5b5d8118fa (patch)
tree78da89b13f903239d7150be7b3d5ef6c536f4bf9
parent1bbd53c4599fd1148bdb864f981b6fd4563fb476 (diff)
krebs.permown: use named pipe
This commit fixes following issues: 1. reexecution causes stray inotifywait processes 2. errors in the while part renderes the service defunct
-rw-r--r--krebs/3modules/permown.nix17
1 files changed, 15 insertions, 2 deletions
diff --git a/krebs/3modules/permown.nix b/krebs/3modules/permown.nix
index 0f2ba86c8..63adb2236 100644
--- a/krebs/3modules/permown.nix
+++ b/krebs/3modules/permown.nix
@@ -65,17 +65,30 @@ with import <stockholm/lib>;
find "$ROOT_PATH" -type d -exec chmod "$DIR_MODE" {} +
find "$ROOT_PATH" -type f -exec chmod "$FILE_MODE" {} +
- inotifywait -mrq -e CREATE --format %w%f "$ROOT_PATH" |
+ paths=/tmp/paths
+ rm -f "$paths"
+ mkfifo "$paths"
+
+ inotifywait -mrq -e CREATE --format %w%f "$ROOT_PATH" > "$paths" &
+ inotifywaitpid=$!
+
+ trap cleanup EXIT
+ cleanup() {
+ kill "$inotifywaitpid"
+ }
+
while read -r path; do
if test -d "$path"; then
+ cleanup
exec "$0" "$@"
fi
chown -h "$OWNER_GROUP" "$path"
if test -f "$path"; then
chmod "$FILE_MODE" "$path"
fi
- done
+ done < "$paths"
'';
+ PrivateTemp = true;
Restart = "always";
RestartSec = 10;
UMask = plan.umask;