This commit is contained in:
Peder Bergebakken Sundt 2022-01-29 22:54:52 +01:00
parent 15c9431c10
commit 6cae4cb0e2
1 changed files with 14 additions and 5 deletions

View File

@ -1,14 +1,23 @@
#!/usr/bin/env bash
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 # Empty the file
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)"
echo "$user:$realname" >> $unamefile
echo "$user:$realname" >> "$unamefile"
destination="$outfolder/$user"
mkdir -p $destination
mkdir -p "$destination"
rsync -rtvz --delete "$imgfolder/" "$destination" # Copy and keep timestamps
echo
done