#!/usr/bin/env bash

if [ $# -lt 2 ]; then
	echo "$0 <source> <host/dest>"
	exit 1
fi
source="$1"
host=$(echo "$2" | cut -d "/" -f 1)
dest=/$(echo "$2" | cut -d "/" -f 2-)
echo "$source -> $host$dest"
ssh "$host" rm -rfv "$dest/"\*
scp -r "$source"/* "scp://$host/$dest"
ssh "$host" sudo chown -Rv :www-data "$dest"
ssh "$host" ls -al "$dest"
