#!/bin/sh

# deploy on server
ssh=
ssh_port=
while [ -z $ssh ]
do
    echo -n 'SSH login-name@host? '
    read ssh
    if [[ $ssh =~ ^[^@]+@{1}[^@]*$ ]]
    then
        while [ -z $ssh_port ]
        do
            echo -n 'SSH PORT? '
            read ssh_port
            if [[ $ssh_port =~ ^[0-9]+$ ]]
            then
                rsync -azv --no-o --no-g --delete --delete-excluded --delete-after --progress -e "ssh -p $ssh_port" \
                --include "/dist" \
                --include "/index.html" \
                --exclude "/*" \
                --filter "P /.htaccess" \
                . \
                "$ssh":~/stefanbartko.sk/src/email-autocomplete/public/

                break
            fi
            echo 'Wrong SSH PORT "'$ssh_port'"'
            ssh_port=
        done
        break
    fi
    echo 'Wrong SSH "'$ssh'"'
    ssh=
done
