]>
Commit | Line | Data |
---|---|---|
967baf16 | 1 | #!/usr/bin/env bash |
89e9c6b7 | 2 | |
0dc78c13 | 3 | KEY=.slurp-key |
0605a43e | 4 | LEGACY='-oHostKeyAlgorithms=+ssh-dss' |
0dc78c13 SW |
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 | |
0605a43e | 12 | |
b8d03101 | 13 | seendir="slurp-seen" |
89e9c6b7 | 14 | while read host path;do |
b8d03101 | 15 | outdir="slurp-$host-${path//\//,}" |
89e9c6b7 | 16 | { |
20f5e5b6 | 17 | mkdir -p "$outdir" "$seendir/$outdir" |
89e9c6b7 | 18 | echo "cd $path" |
0605a43e | 19 | "${sftp[@]}" "slurp@$host" <<< "cd $path"$'\n'"ls -1" | |
89e9c6b7 SW |
20 | sed 1,2d | |
21 | while read filename;do | |
348610a4 | 22 | output_filename="$outdir/${filename/jpg/jpeg}" |
20f5e5b6 | 23 | if [[ -e "$output_filename" || -e "$seendir/$output_filename" ]];then |
89e9c6b7 SW |
24 | echo "skipping $filename" >&2 |
25 | else | |
26 | echo "getting $filename" >&2 | |
348610a4 | 27 | echo "get -p $filename $output_filename" |
89e9c6b7 SW |
28 | fi |
29 | done | |
0605a43e | 30 | } | "${sftp[@]}" "slurp@$host" |
20f5e5b6 SW |
31 | for f in "$outdir"/*;do |
32 | touch "$seendir/$f" | |
33 | done | |
1eb4e1cb | 34 | ./rename-to-date "$outdir"/* |
89e9c6b7 | 35 | done < .slurp-hosts |