#!/bin/bash

#npm run pack

fname="flo-flex-builder"
zipname="flo-flex-builder.zip"

#get the name of the current script directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 
scp "${DIR}/${zipname}" flo@demo.flothemes.com:/var/www/demo.flothemes.com/releases/1/web/app/plugins
#rm "${zipname}"
# connect via ssh
ssh -t -t flo@demo.flothemes.com << EOF
  ## remove the current plugin if exists
  sudo rm -r -f "demo.flothemes.com/releases/1/web/app/plugins/${fname}"
  #unzip the uploaded file
  cd demo.flothemes.com/releases/1/web/app/plugins/
  unzip -o "${zipname}"
  sudo chown -R www-data ./flo-flex-builder
exit
EOF
exit