Skip to content

Instantly share code, notes, and snippets.

@raco
Last active April 4, 2020 00:23
Show Gist options
  • Save raco/904d235c6c5939110bd218fd32fb4259 to your computer and use it in GitHub Desktop.
Save raco/904d235c6c5939110bd218fd32fb4259 to your computer and use it in GitHub Desktop.
Script to install a git bare repository to deploy easily
#!/bin/sh
#
export DEBIAN_FRONTEND=noninteractive;
# Define a project name
projectname='your_project_name';
cd /var/www;
mkdir $projectname;
cd /var;
mkdir repo;
cd repo;
mkdir $projectname;
cd $projectname;
mkdir site.git;
cd site.git;
git init --bare;
cd hooks;
sudo touch post-receive;
echo "#!/bin/sh
git --work-tree=/var/www/$projectname --git-dir=/var/repo/$projectname/site.git checkout -f" > post-receive;
sudo chmod +x post-receive;
green=`tput setaf 1`
reset=`tput sgr0`
echo "${green}---------LISTO AHORA: git remote add development "USER"@"SERVER_IP":/var/repo/$projectname/site.git
-----${reset}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment