This commit is contained in:
parent
15c9431c10
commit
6cae4cb0e2
|
@ -1,14 +1,23 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
outfolder="bilder/pvv-photos"
|
outfolder="bilder/pvv-photos"
|
||||||
folders=$(ssh pvv@microbel.pvv.ntnu.no -i /home/pvv/c/pvv/.ssh/photofetcher 'find /home/pvv -maxdepth 3 -name "pvv-photos" 2>/dev/null')
|
|
||||||
|
echo "Fetching user list"
|
||||||
|
# Note: `~pvv/.ssh/authorized_keys` forces the command as such
|
||||||
|
folders="$(ssh pvv@microbel.pvv.ntnu.no -i /home/pvv/c/pvv/.ssh/photofetcher 'cat /etc/passwd' | while read line; do test `echo "$line" | cut -d: -f 3` -gt 1000 && echo "$(echo $line | cut -d: -f 6)/pvv-photos" ; done)"
|
||||||
|
|
||||||
unamefile="usernames.txt"
|
unamefile="usernames.txt"
|
||||||
> $unamefile # Empty the file
|
> $unamefile # Empty the file
|
||||||
|
|
||||||
for imgfolder in $folders; do
|
for imgfolder in $folders; do
|
||||||
user=$(echo $imgfolder | cut -d "/" -f5)
|
if ! test -d "$imgfolder"; then continue; fi
|
||||||
|
echo found $imgfolder
|
||||||
|
|
||||||
|
user="$(echo $imgfolder | cut -d "/" -f5)"
|
||||||
realname="$(getent passwd $user | cut -d ':' -f 5)"
|
realname="$(getent passwd $user | cut -d ':' -f 5)"
|
||||||
echo "$user:$realname" >> $unamefile
|
echo "$user:$realname" >> "$unamefile"
|
||||||
destination="$outfolder/$user"
|
destination="$outfolder/$user"
|
||||||
mkdir -p $destination
|
mkdir -p "$destination"
|
||||||
rsync -rtvz --delete "$imgfolder/" "$destination" # Copy and keep timestamps
|
rsync -rtvz --delete "$imgfolder/" "$destination" # Copy and keep timestamps
|
||||||
done
|
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in New Issue