#!/bin/bash

DESTINATION=${1:-dev}

case $DESTINATION in
  dev)
    SERVER=webtest.aoc.nrao.edu
    USER=webapps
    ;;
  test)
    SERVER=vlass-test.nrao.edu
    USER=webapps
    ;;
  prod)
    SERVER=vlass.nrao.edu
    USER=webapps
    ;;
  *)
    echo $"Usage: ${DESTINATION} {dev|test|prod}"
    exit 1
    ;;
esac

ng build --optimization=true --prod=true --base-href /vlass-manager/
ssh $USER@$SERVER "rm -R /home/${SERVER}/content/vlass-manager/*"
scp -r dist/vlass-manager/* $USER@$SERVER:/home/$SERVER/content/vlass-manager
ssh $USER@$SERVER "chmod -R 775 /home/${SERVER}/content/vlass-manager/*"
