. ./.env

TOMCAT_DIR=$(ssh mstr@$ENV_IP "ls /opt/apache/tomcat | head -1")


if [ $OSTYPE == "msys" ]; then
    ssh $ENV_USR@$ENV_IP "rm -rf /opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategy/plugins/$PLUGIN_NAME/"
    scp -rp $PATH_OF_VIZ "$ENV_USR@$ENV_IP:/opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategy/plugins/$PLUGIN_NAME"
else
    rsync -r $PATH_OF_VIZ/ "$ENV_USR@$ENV_IP:/opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategy/plugins/$PLUGIN_NAME" --delete
fi


ssh $ENV_USR@$ENV_IP "rsync -r /opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategy/plugins/$PLUGIN_NAME/ /opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategyLibrary/plugins/$PLUGIN_NAME --delete"
ssh $ENV_USR@$ENV_IP "rsync -r /opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategy/plugins/$PLUGIN_NAME /opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategyMobile/plugins/$PLUGIN_NAME --delete"
ssh $ENV_USR@$ENV_IP "rsync -r /opt/apache/tomcat/$TOMCAT_DIR/webapps/MicroStrategy/plugins/$PLUGIN_NAME /opt/mstr/MicroStrategy/install/Export/resources/plugins/$PLUGIN_NAME --delete"