blob: 0be20d0cc1c8c3313ce19f7d070ad502c1fa98b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
{ 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
tmpFile="''${dir}"/.tmp/$(basename "$1")
target="''${dir}"/$(basename "$1")
mkdir -pv $(basename "''${tmpFile}")
${eject}/bin/ionice -c 3 -t cp -vn --preserve=all "$1" ''${tmpFile} && mv -v ''${tmpFile} "''${target}"
touch -c -m -t "$2" "''${target}"
''
|