Created
September 24, 2012 15:09
-
-
Save eamexicano/3776443 to your computer and use it in GitHub Desktop.
Inicializa repositorio de git. Lo envia vía ssh a un nuevo repositorio vacío y sincroniza con htdocs. Necesita el nombre del repo, usuario y modificar las rutas.
This file contains 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 | |
SITIO="$1" | |
USUARIO="$2" | |
PUERTO="22" | |
REPOSITORIO_REMOTO="/var/repo/$SITIO" | |
SHEBANG="#!/bin/bash" | |
SITIO_HTDOCS="/var/www/$SITIO" | |
read -r -d '' HOOK <<EOF | |
${SHEBANG} | |
echo ' * * * Actualizando $SITIO_HTDOCS * * * ' | |
GIT_WORK_TREE=$SITIO_HTDOCS git checkout -f | |
echo ' * * * ¡ Hecho ! * * * ' | |
EOF | |
# Repositorio local | |
git init | |
echo ".DS_Store" > .gitignore | |
git add . | |
git commit -m "Repositorio local inicializado" | |
# Repositorio Remoto | |
ssh -p $PUERTO $USUARIO "mkdir -m 0775 $SITIO_HTDOCS; mkdir $REPOSITORIO_REMOTO; cd $REPOSITORIO_REMOTO; git init --bare; echo \"$HOOK\" > $REPOSITORIO_REMOTO/hooks/post-receive; chmod +x $REPOSITORIO_REMOTO/hooks/post-receive; exit;" | |
wait | |
# Repositorio local | |
git remote add origin ssh://$USUARIO:$PUERTO$REPOSITORIO_REMOTO | |
git push origin +master:refs/heads/master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment