{ 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 -m -t "$2" "''${target}"
''