summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-04-17 15:59:27 +0200
committerlassulus <lass@lassul.us>2017-04-18 21:14:55 +0200
commitd34d95ec3ed4230faa2dc9dd90938e9991dd73d7 (patch)
tree4b4ee395d41a7f20c7dc13dc1d2bb503689195cf
parent82aa7c6f101c16d7e2607f3429cfbb222c572438 (diff)
shared shack-drivedroid: cleanup
-rw-r--r--shared/2configs/shack-drivedroid.nix27
1 files changed, 16 insertions, 11 deletions
diff --git a/shared/2configs/shack-drivedroid.nix b/shared/2configs/shack-drivedroid.nix
index 07fcffa42..12e4a39c3 100644
--- a/shared/2configs/shack-drivedroid.nix
+++ b/shared/2configs/shack-drivedroid.nix
@@ -1,8 +1,7 @@
{ config, pkgs, ... }:
with import <stockholm/lib>;
let
- repodir = "/var/srv/drivedroid";
- srepodir = shell.escape repodir;
+ root = "/var/srv/drivedroid";
in
{
environment.systemPackages = [ pkgs.drivedroid-gen-repo ];
@@ -15,28 +14,34 @@ in
];
# TODO: prepare this somehow
locations."/".extraConfig = ''
- root ${repodir};
+ root ${root};
index main.json;
'';
};
};
- systemd.services.drivedroid = {
+ systemd.services.drivedroid-gen-repo = {
description = "generates drivedroid repo file";
- restartIfChanged = true;
+ path = [
+ pkgs.coreutils
+ pkgs.drivedroid-gen-repo
+ pkgs.inotify-tools
+ ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Restart = "always";
- ExecStartPre = pkgs.writeScript "prepare-drivedroid-gen-repo" ''
- #!/bin/sh
- mkdir -p ${srepodir}/repos
+ ExecStartPre = pkgs.writeDash "prepare-drivedroid-gen-repo" ''
+ mkdir -p ${root}/repos
'';
- ExecStart = pkgs.writeScript "start-drivedroid-gen-repo" ''
- #!/bin/sh
+ ExecStart = pkgs.writeDash "start-drivedroid-gen-repo" ''
+ set -efu
+ cd ${root}
while sleep 60; do
- ${pkgs.inotify-tools}/bin/inotifywait -r ${srepodir} && ${pkgs.drivedroid-gen-repo}/bin/drivedroid-gen-repo --chdir "${srepodir}" repos/ > "${srepodir}/main.json"
+ if inotifywait -r .; then
+ drivedroid-gen-repo repos > main.json
+ fi
done
'';
};