Created
June 3, 2016 01:07
-
-
Save iver/10a5833847e491ffd5ae8b5feca1e425 to your computer and use it in GitHub Desktop.
Deploy script for phoenix project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PROJECT=stats | |
export RELEASE=${PROJECT}.tar.gz | |
PROG_NAME=$(basename $0) | |
while getopts :s:v: OPTION | |
do | |
case ${OPTION} in | |
s) TARGET=${OPTARG};; | |
v) VERSION=${OPTARG};; | |
\?) echo "Modo de uso: ${PROG_NAME} [ -s server -v version ]" | |
exit 1;; | |
:) | |
echo "Opción -${OPTARG} requiere un argumento." >&2 | |
exit 1 | |
;; | |
esac | |
done | |
if [ "${TARGET}" == '' ]; then | |
echo "Ingresa el servidor destino (ej. ${PROJECT}01):"; | |
read TARGET | |
fi | |
if [ "${VERSION}" == '' ]; then | |
echo "Ingresa la versión a desplegar (ej. 0.0.1):"; | |
read VERSION | |
fi | |
echo "Subiendo versión ${VERSION} al servidor ${TARGET}"; | |
scp rel/${PROJECT}/releases/$VERSION/$RELEASE $TARGET:/tmp | |
export DEPLOY_PATH=/var/www/${PROJECT}/releases/${VERSION}/ | |
ssh -t $TARGET " | |
sudo -u www-data mkdir -p $DEPLOY_PATH && | |
sudo chown www-data:www-data /tmp/$RELEASE && | |
sudo -u www-data mv /tmp/$RELEASE $DEPLOY_PATH; | |
"; | |
echo "El release ${VERSION} se ha enviado a ${TARGET}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment