From 3bb2f9a6caef07cd2d798fe52e340df524663a82 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 14 Apr 2018 14:17:56 +0200 Subject: monitor-uucp --- monitor-uucp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ nix/default.nix | 1 + nix/monitor-uucp.nix | 29 ++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100755 monitor-uucp create mode 100644 nix/monitor-uucp.nix diff --git a/monitor-uucp b/monitor-uucp new file mode 100755 index 0000000..412c707 --- /dev/null +++ b/monitor-uucp @@ -0,0 +1,64 @@ +#!@zsh@/bin/zsh + +lsof() { @lsof@/bin/lsof ${@} 2>/dev/null | tail -n +2} +ignoredFiles() { + cat < len) print substr($0, 1, len-3) "..."; else print; }') + + [[ ${fType} == "REG" ]] || continue + + clear + @pv@/bin/pv -W -D 2 -i 0.5 -d ${pid}:${fd} -s ${size} -F "%r %a %p %e %I" -p -r -I -e -N ${name} + + slept=0 + watched=true + + break + done + + if $watched || [[ $slept -ge $(($sleepTimeout / $sleep)) ]]; then + printf "inotify (%s)\n" $(date +"%T") + @inotify@/bin/inotifywait -r -e access /var/spool/uucp &>/dev/null + slept=0 + else + sleep 0.1 + printf "." + slept=$(($slept + 1)) + fi +done diff --git a/nix/default.nix b/nix/default.nix index ad181fa..1c0105f 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -6,4 +6,5 @@ in rec { cliparg = pkgs.callPackage ./cliparg.nix {}; rebuild-system = pkgs.callPackage ./rebuild-system.nix {}; pulseaudio-ctl = pkgs.callPackage ./pulseaudio-ctl.nix {}; + monitor-uucp = pkgs.callPackage ./monitor-uucp.nix {}; } diff --git a/nix/monitor-uucp.nix b/nix/monitor-uucp.nix new file mode 100644 index 0000000..b1abdda --- /dev/null +++ b/nix/monitor-uucp.nix @@ -0,0 +1,29 @@ +{ stdenv +, fetchgit +, makeWrapper +, zsh, lsof, pv, inotify-tools +}: + +stdenv.mkDerivation rec { + name = "monitor-uucp-${version}"; + version = "0.1"; + src = ../monitor-uucp; + + buildInputs = [ makeWrapper ]; + + phases = [ "buildPhase" "installPhase" ]; + + inherit zsh lsof pv; + inotify = inotify-tools; + + buildPhase = '' + substituteAll $src monitor-uucp + ''; + + installPhase = '' + mkdir -p $out/bin + + install -m 755 -t $out/bin \ + monitor-uucp + ''; +} -- cgit v1.2.3