summaryrefslogtreecommitdiff
path: root/hel/recv-media.nix
blob: 2ae78e90b11a9b7a24188f0451b1499a3300baf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{ stdenv, coreutils, writeScriptBin }:

writeScriptBin "recv-media" ''
  #!${stdenv.shell}

  [[ -z "$1" || -z "$2" ]] && exit 2

  PATH=${coreutils}/bin

  dir=/var/media
  target="''${dir}"/$(basename "$1")

  cp -ln "$1" "''${target}"
  touch -c -d "$(print "$2" | tr '_' ' ')" "''${target}"
''