Created
March 14, 2013 11:15
-
-
Save schleumer/5160560 to your computer and use it in GitHub Desktop.
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/sh | |
X_NAME=$1 | |
X_HOST="schleumer.com.br" | |
X_DEFAULT_VHOST=" | |
<VirtualHost *:80>\n | |
ServerAdmin webmaster@$X_NAME.$X_HOST\n | |
ServerName $X_NAME.$X_HOST\n | |
DocumentRoot /var/www/$X_NAME\n | |
<Directory /var/www/$_XNAME>\n | |
Options Indexes FollowSymLinks MultiViews\n | |
AllowOverride All\n | |
Order allow,deny\n | |
allow from all\n | |
</Directory>\n | |
ErrorLog ${APACHE_LOG_DIR}/error.log\n | |
LogLevel warn\n | |
CustomLog ${APACHE_LOG_DIR}/access.log combined\n | |
</VirtualHost>\n | |
" | |
X_GIT_POST_RECEIVE_HOOK=" | |
#Add these commands to the filei \n | |
echo \"\\\\n\"\n | |
echo \"********************\"\n | |
echo \"Post receive hook: Updating website\"\n | |
echo \"********************\"\n | |
echo \"\\\\n\"\n | |
#Change to working git repository to pull changes from bare repository\n | |
cd /var/www/$X_NAME || exit\n | |
unset GIT_DIR\n | |
git pull origin master\n | |
#End of commands for post-receive hook\n | |
echo \"\\\\n\"\n | |
" | |
if [ -z "$1" ] | |
then | |
echo "Você precisa inserir o nome do projeto"; | |
else | |
if [ -d "/var/git/$X_NAME" ] | |
then | |
echo "Já existe um Projeto GIT com esse nome na past /var/git/$X_NAME" | |
exit | |
fi | |
if [ -d "/var/www/$X_NAME" ] | |
then | |
echo "Já existe um Projeto WEB com esse nome na pasta /var/www/$X_NAME" | |
exit | |
fi | |
if [ ! -d "/var/git" ] | |
then | |
mkdir "/var/git" | |
fi | |
cd /var/git | |
echo "\n####CRIANDO REPOSITÓRIO GIT EM MODO BARE \n" | |
git init --bare $X_NAME | |
echo "\n####CRIANDO HOOK DE POST RECEIVE DENTRO DO REPOSITÓRIO GIT \n" | |
echo $X_GIT_POST_RECEIVE_HOOK > "/var/git/$X_NAME/hooks/post-receive" | |
echo "\n####DANDO PERMISSÕES AO HOOK PARA SER EXECUTADO \n" | |
chmod +x "/var/git/$X_NAME/hooks/post-receive" | |
echo "\n####CLONANDO NO PROJETO WEB \n" | |
mkdir -p "/var/www/$X_NAME" | |
cd "/var/www" | |
git clone "file:///var/git/$X_NAME" "$X_NAME" | |
echo "\n####CRIANDO VHOST NO APACHE\n" | |
echo $X_DEFAULT_VHOST > "/etc/apache2/sites-enabled/$X_NAME" | |
echo "\n####RECARREGANDO CONFIGURAÇÕES DO APACHE\n" | |
service apache2 reload | |
echo "\n####É NÓIS LEK\n" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment