Skip to content

Instantly share code, notes, and snippets.

@enlacee
Created April 8, 2019 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enlacee/be29de13f22d71a7b9955bd6e3131378 to your computer and use it in GitHub Desktop.
Save enlacee/be29de13f22d71a7b9955bd6e3131378 to your computer and use it in GitHub Desktop.
subir archivos al servidor
#!/bin/bash
ult_comt=$1;
pri_comt=$2;
dir_local=$3;
dir_remot=$4;
if [ $# -lt 4 ]; then
echo "use: <ult-cod-commit> <pri-cod-commit> <dir_local> <dir_remot>";
exit;
fi
if [ ! -d ${dir_local}/.git ]; then
echo "Debe de ejecutar el script en un proyecto configurado con git.";
exit;
fi
puer_remoto="21";
host_remoto="111.111.111.111";
user_remoto="email@example.com";
user_pass="123456";
nolistatar=".env|config_PRD.js";
cd $dir_local;
function listar_archivos(){
git --no-pager diff $ult_comt $pri_comt | grep "diff --" | awk '{print $NF}' | sed 's/b//g' | grep -vE "${nolistatar}";
}
function subir_archivo(){
local arch_local=$1;
curl -T ".${arch_local}" -u "${user_remoto}:${user_pass}" "ftp://${host_remoto}:${puer_remoto}${arch_local}" --ftp-create-dirs ;
#echo "curl -T .${arch_local} -u ${user_remoto}:${user_pass} ftp://${host_remoto}:${puer_remoto}${arch_local}" --ftp-create-dirs;
echo ".${arch_local} -> ftp://${host_remoto}:${puer_remoto}${arch_local}";
}
function subir_archivo_old(){
local arch_local=$1;
curl -T "${arch_local}" -u "${user_remoto}:${user_pass}" \
"ftp://${host_remoto}:${puer_remoto}/${dir_remot}/${arch_local}" >& /dev/null;
echo "curl -T ${arch_local} -u ${user_remoto}:${user_pass} ftp://${host_remoto}:${puer_remoto}/${dir_remot}/${arch_local}";
}
function main(){
echo "archivos cambiados";
for file in $(listar_archivos); do
subir_archivo $file;
done;
}
main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment