]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env bash | |
2 | ||
3 | KEY=.slurp-key | |
4 | LEGACY='-oHostKeyAlgorithms=+ssh-dss' | |
5 | sftp=( sftp -v -P 19362 -i "$KEY" -oConnectTimeout=4 $LEGACY ) | |
6 | ||
7 | if [[ ! -e "$KEY" ]];then | |
8 | ssh-keygen -f "$KEY" | |
9 | echo "I generated you a key! Copy $KEY.pub to devices' authorized_keys" | |
10 | exit 1 | |
11 | fi | |
12 | ||
13 | seendir="slurp-seen" | |
14 | while read host path;do | |
15 | outdir="slurp-$host-${path//\//,}" | |
16 | { | |
17 | mkdir -p "$outdir" "$seendir/$outdir" | |
18 | echo "cd $path" | |
19 | "${sftp[@]}" "slurp@$host" <<< "cd $path"$'\n'"ls -1" | | |
20 | sed 1,2d | | |
21 | while read filename;do | |
22 | output_filename="$outdir/${filename/jpg/jpeg}" | |
23 | if [[ -e "$output_filename" || -e "$seendir/$output_filename" ]];then | |
24 | echo "skipping $filename" >&2 | |
25 | else | |
26 | echo "getting $filename" >&2 | |
27 | echo "get -p $filename $output_filename" | |
28 | fi | |
29 | done | |
30 | } | "${sftp[@]}" "slurp@$host" | |
31 | for f in "$outdir"/*;do | |
32 | touch "$seendir/$f" | |
33 | done | |
34 | ./rename-to-date "$outdir"/* | |
35 | done < .slurp-hosts |