#!/bin/bash


#ssh -p 10760 root@www.secomn.com


SSH_PORT=10760 

REMOTE_USER=root
SERVER_HOSTNAME=www.secomn.com

SRC_VHOST=scripts/vhost/www.secomn.com.conf
SRC_SNIPPETS=scripts/vhost/snippets

echo "Crear el VHOST en el servidor"
scp -P $SSH_PORT $SRC_VHOST $REMOTE_USER@$SERVER_HOSTNAME:/etc/nginx/http.d/


SNIPPETS_FOLDER=/etc/nginx/snippets
echo "Subiendo snippets en el servidor"

ssh -q -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${SSH_PORT} ${REMOTE_USER}@${SERVER_IP4} "echo ${REMOTE_PWD} | sudo -S -- sh -c 'mkdir -p ${SNIPPETS_FOLDER};chown -R ${REMOTE_USER}:${REMOTE_USER} ${SNIPPETS_FOLDER};chmod -R 775 ${SNIPPETS_FOLDER}'"

echo "scp -P $SSH_PORT -r $SRC_SNIPPETS $REMOTE_USER@$SERVER_HOSTNAME:$SNIPPETS_FOLDER"
scp -P $SSH_PORT -r $SRC_SNIPPETS $REMOTE_USER@$SERVER_HOSTNAME:$SNIPPETS_FOLDER

echo "Cambios anviados a produccion"
