KIEKjes Upload System
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

set -e
sysdir="$1"; shift
[ -d "$basedir" ] || exit 1
# no built-in tar support, write to a temporary directory first
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\$")"
done <<EOF
$(ptpcam --bus=$busnum --dev=$devnum -L | sed -ne '/^Handler:/,$p' | sed -ne '2,$p')
# managed to get all the files?
[ -z "$files" ]
# tar it up!
(cd "$tempdir" && tar -cz -- "$@")