#!/usr/bin/env bash # Usage: # $ ./push.sh julm/2023 cd "${0%/*}" set -eux for dir in "$@"; do IFS=/ read -r user year x month x <<<"$dir" test "${user:+set}" test "${year:+set}" || exec "$0" "$user"/*/ rsync -ai --no-inc-recursive --info=progress2 --inplace --partial \ --copy-dirlinks \ --chmod=D755,F644 \ --exclude "*.vp9.webm" \ --exclude "*.opus" \ --exclude "*.uuid" \ --delete --delete-after --delete-excluded \ "$user"/"$year"/fav/${month:+"$month"/} \ mermet.sp:/var/lib/nginx/autogeree.net/"$user"/perso/camera/"$year"/${month:+"$month"/} rsync -ai --chmod=D755,F644 \ "$user"/"$year"/fav/index.css \ mermet.sp:/var/lib/nginx/autogeree.net/"$user"/perso/camera/"$year"/ if test "$(date +%Y)" == "$year"; then ssh mermet.sp ln -sf "$(date +%m)" /var/lib/nginx/autogeree.net/"$user"/perso/camera/"$year"/latest fi done