Created
December 27, 2016 19:12
-
-
Save reginaldojunior/23d2382a2f8e8accf6f7cfa10e63de5e to your computer and use it in GitHub Desktop.
automatizador-deploy-laravel.py
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
directory = raw_input("Digite o diretorio da instalação: ") | |
source_git = raw_input("Digite a URL do repositorio com o username e senha e .git no final + a pasta de instalacao. 'username:senha@url.git pastainstalacao': ") | |
domain = raw_input("Digite o dominio: ") | |
# install project | |
os.system(""" | |
cd """ + directory + """ && | |
git clone """ + source_git + """ | |
""") | |
project_laravel = raw_input("É um projeto laravel? Sim(1) Não(0): ") | |
directory_full = raw_input("Caminho completo da instalação '/path/full/site:' ") | |
os.system(""" | |
cd """ + directory_full + """ && | |
composer install | |
""") | |
if project_laravel: | |
host_bd = raw_input("Digite o host do banco: ") | |
user_bd = raw_input("Digite o user do banco: ") | |
pass_bd = raw_input("Digite a senha do banco: ") | |
name_db = raw_input("Digite o nome do banco: ") | |
os.system(""" | |
echo "APP_ENV=production | |
APP_DEBUG=true | |
APP_KEY=RandomString | |
APP_LOG_LEVEL=debug | |
APP_URL=""" + domain + """ | |
DB_CONNECTION=mysql | |
DB_HOST=""" + host_bd + """ | |
DB_PORT=3306 | |
DB_DATABASE=""" + name_db + """ | |
DB_USERNAME=""" + user_bd + """ | |
DB_PASSWORD=""" + pass_bd + """" >> """ + directory_full + """/.env | |
""") | |
os.system(""" | |
cd """ + directory_full + """ && | |
php artisan key:generate | |
""") | |
run_migrations = raw_input("Deseja rodar as migrations do laravel? Sim(1) Não(0): ") | |
if run_migrations: | |
os.system(""" | |
cd """ + directory_full + """ && | |
php artisan migration | |
""") | |
# install apache.conf | |
os.system(""" | |
echo "<VirtualHost *:80> | |
ServerAdmin contato@plugg.to | |
ServerName """ + domain + """ | |
ServerAlias www.""" + domain + """ | |
DocumentRoot """ + domain + """/public | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost>" >> /etc/apache2/sites-available/""" + domain + """.conf | |
""") | |
# active site ensite apache.conf | |
os.system(""" | |
a2ensite """ + domain + """.conf | |
""") | |
# restart apache2 | |
os.system(""" | |
service apache2 reload | |
""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment