#!/bin/bash

SSH_LOGIN="kasu@s21.wservices.ch"
SYNC_ASSESTS="requirements static"
SYNC_SOURCECODE="src"
EXCLUDE_FILES="*.pyc"

grunt

echo "Syncing project assets ..."
rsync -r --copy-links --delete ${SYNC_ASSESTS} ${SSH_LOGIN}:~/

echo "Installing dependecies"
ssh ${SSH_LOGIN} "virtualenv/bin/pip install --upgrade -r requirements/base.txt"

echo "Syncing Sourcecode ..."
find . -name "*.pyc" -exec rm -rf {} \;
rsync -r --copy-links --delete ${SYNC_SOURCECODE} ${SSH_LOGIN}:~/ --exclude 'src/kasu/local_settings.py'

echo "Rebuild and reload django..."
ssh ${SSH_LOGIN} "rm src/kasu/settings/development.*"
ssh ${SSH_LOGIN} "~/virtualenv/bin/python ~/src/manage.py collectstatic -l --noinput -v1"
ssh ${SSH_LOGIN} "~/init/kasu restart"
