multistream/bin/deploy
File Type: text/x-shellscript
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCEDIR="$SCRIPTDIR/../"
cd "$SOURCEDIR"
source .env || exit 1
TARGETUNAME=$DEPLOYUNAME
TARGETSERVER=$DEPLOYSERVER
TARGETPORT=$DEPLOYPORT
TARGETDIR=$DEPLOYDIR
pipenv run pip freeze > requirements.txt
if [ "$1" == "--full" ]; then
EXCLUDE=(--exclude '*.pyc' --exclude '__pycache__/' --exclude '.git/')
elif [ "$1" == "--db" ]; then
EXCLUDE=(--exclude '*.pyc' --exclude '__pycache__/' --exclude '.git/' --exclude '.env')
elif [ "$1" == "--env" ]; then
EXCLUDE=(--exclude '*.pyc' --exclude '__pycache__/' --exclude '.git/' --exclude '*.sqlite3')
else
EXCLUDE=(--exclude '*.pyc' --exclude '__pycache__/' --exclude '.git/' --exclude '*.sqlite3' --exclude '.env')
fi
rsync -rvzc --delete -e "ssh -p $TARGETPORT" ${EXCLUDE[@]} \
"$SOURCEDIR" ${TARGETUNAME}@$TARGETSERVER:"$TARGETDIR"