#!/bin/bash
# Deploy to www.jovian-hersemeule.eu

echo 'Deploy website to OVH'

gitRoot=`git rev-parse --show-toplevel`
origin="$gitRoot/src"
host='ftp.cluster021.hosting.ovh.net'
user='jovianhedk'
port='21'
dest='www'

cd $origin
files=`echo favicon.ico *.php include/*.php projets/*.php include/css/*.css include/css/custom/*.css include/js/*.js include/images/* include/icon/* include/generated/*.txt download/*`
echo 'Files to be sent :'
echo "$files"

echo "FTP to $host"
read -s -p "[deploy] password for $user: " password
echo

# Dump varying files
bash "$gitRoot/undeployed/scripts/deploy/up-date.sh"
bash "$gitRoot/undeployed/scripts/deploy/up-version.sh"

# ftp operation
ftp -pvin $host $port<<EOT
user $user $password
nmap \$1 $dest/\$1
mput $files
bye
EOT

# Cancel dump mofifications
git checkout -- "$gitRoot/src/include/generated/date.txt"
git checkout -- "$gitRoot/src/include/generated/version.txt"