blob: 2c42c5dab7df992a9f1d30f0dd2cdd792ec804b4 (
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 $(dirname "''${tmpFile}")
${eject}/bin/ionice -c 3 -t cp -vn --preserve=all "$1" ''${tmpFile} && mv -v ''${tmpFile} "''${target}"
touch -c -m -t "$2" "''${target}"
''
|