Commit 28a00cce authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Evita dejar modificado fichero .env local

Durante el proceso de preparación del despliegue, se utiliza el fichero
.env para almacenar variables que deben propagarse al entorno destino
del despliegue. Tras mandar los recursos (o fallar al intentarlo), se
restaura el fichero .env a su estado original.

Ajusta algunos detalles de salida por consola.
parent b63e240f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -117,9 +117,9 @@ checkDeployCmd="\

if ssh ${SSH_PARAMS} "${SSH_REMOTE}" "${checkDeployCmd}"
then
	echo -e "\\n${PASS_COLOR}All services seems ok!${NULL_COLOR}"
	echo -e "\n${PASS_COLOR}All services seems ok!${NULL_COLOR}"
else
	echo -e "\\n${FAIL_COLOR}One or more services seems failed!${NULL_COLOR}"
	echo -e "\n${FAIL_COLOR}One or more services seems failed!${NULL_COLOR}"
	ssh ${SSH_PARAMS} -q -O exit "${SSH_REMOTE}"
	exit 1
fi
+2 −2
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ cleanDeployCmd="ssh ${SSH_PARAMS} \"${SSH_REMOTE}\" \"rm -rf ${DEPLOY_HOME}\""

if ssh ${SSH_PARAMS} "${SSH_REMOTE}" "${deployCmd}"
then
	echo -e "${PASS_COLOR}Services successfully deployed!${NULL_COLOR}"
	echo -e "\n${PASS_COLOR}Services successfully deployed!${NULL_COLOR}"
	if [ ${OMIT_CLEAN_DEPLOY} -eq 0 ]
	then
		eval "${cleanDeployCmd}"
@@ -63,7 +63,7 @@ then
		echo -e "${INFO_COLOR}Deployment resources cleaning omitted${NULL_COLOR}"
	fi
else
	echo -e "${FAIL_COLOR}Services deployment failed!${NULL_COLOR}"
	echo -e "\n${FAIL_COLOR}Services deployment failed!${NULL_COLOR}"
	eval "${cleanDeployCmd}"
	ssh ${SSH_PARAMS} -q -O exit "${SSH_REMOTE}"
	exit 1
+8 −3
Original line number Diff line number Diff line
@@ -75,12 +75,13 @@ do
done

# Se prepara el fichero .env para usarlas en la máquina destino y se setean en este entorno también.
cp -a .env .env-original
echo -e ${envDefs} >> .env

echo -e " ]${NULL_COLOR}"
echo -e "\n${INFO_COLOR}Checking deployment configuration in compose files ..${NULL_COLOR}"
echo -e "  ${INFO_COLOR}compose files [ ${DATA_COLOR}${COMPOSE_FILE}${INFO_COLOR} ]${NULL_COLOR}"
echo -en "  ${INFO_COLOR}checked by [ ${DATA_COLOR}"
echo -en "  ${INFO_COLOR}check command [ ${DATA_COLOR}"

# Antes de continuar, se comprueba que la configuración de despliegue sea válida para compose o swarm.
validComposeMessage="${PASS_COLOR}Valid compose configuration!${NULL_COLOR}"
@@ -122,8 +123,12 @@ then
	exit 1
fi

# Se envían a su destino los ficheros de despliegue del servicio.
if scp ${SSH_PARAMS} ${deployFiles} "${SSH_REMOTE}:${DEPLOY_HOME}"
# Se envían a su destino los ficheros de despliegue del servicio y se restaura el .env local.
scp ${SSH_PARAMS} ${deployFiles} "${SSH_REMOTE}:${DEPLOY_HOME}"
sendResourcesExitCode=${?}
mv .env-original .env

if [ ${sendResourcesExitCode} -eq 0 ]
then
	echo -e "${PASS_COLOR}Deployment resources successfully sent!${NULL_COLOR}"
else