You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
858 B
27 lines
858 B
#!/bin/sh
|
|
set -e
|
|
sysdir="$1"; shift
|
|
[ -d "$basedir" ] || exit 1
|
|
|
|
# no built-in tar support, write to a temporary directory first
|
|
tempdir=/tmp/kiekpull.$$
|
|
mkdir -p "$tempdir"
|
|
trap 'rm -r "$tempdir"' EXIT INT TERM
|
|
|
|
# read file listing, find files of interest, and fetch them
|
|
busnum=$(cat "$sysdir/busnum")
|
|
devnum=$(cat "$sysdir/devnum")
|
|
files="$(printf "%s\n" "$@")"
|
|
while read -r handler size date time filename; do
|
|
if printf "%s\n" "$files" | grep -q "^$filename\$"; then
|
|
(cd "$tempdir" && ptpcam --bus=$busnum --dev=$devnum --get-file="${handler%:}" --filename="$filename")
|
|
files="$(printf "%s\n" "$files" | grep -v "^$filename\$")"
|
|
fi
|
|
done <<EOF
|
|
$(ptpcam --bus=$busnum --dev=$devnum -L | sed -ne '/^Handler:/,$p' | sed -ne '2,$p')
|
|
EOF
|
|
# managed to get all the files?
|
|
[ -z "$files" ]
|
|
|
|
# tar it up!
|
|
(cd "$tempdir" && tar -cz -- "$@")
|
|
|