{ stdenv, coreutils, writeScriptBin, eject }: writeScriptBin "recv-media" '' #!${stdenv.shell} pid=$? exec 1> >(${eject}/bin/logger --id=$pid -t recv-media -p user.notice) exec 2> >(${eject}/bin/logger --id=$pid -t recv-media -p user.error) [[ -z "$1" || -z "$2" ]] && exit 2 PATH=${coreutils}/bin dir=/var/media target="''${dir}"/$(basename "$1") tmpFile=$(${coreutils}/bin/mktemp --dry-run --tmpdir=''${dir} .recv-media.XXXXXXXXXX) ${eject}/bin/ionice -c 3 -t cp -vn --preserve=all "$1" ''${tmpFile} && mv -v ''${tmpFile} "''${target}" touch -c -m -t "$2" "''${target}" ''