Update fabfile to user global environment configuration, abstracted tasks for platform, webserver and database manager
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
from fabric.api import run, sudo, cd, env, task
|
||||
|
||||
from ..literals import OS_UBUNTU
|
||||
import ubuntu
|
||||
|
||||
|
||||
@task
|
||||
def install_dependencies():
|
||||
"""
|
||||
Install OS dependencies
|
||||
"""
|
||||
|
||||
print('Installing dependencies for %s' % env.os_name)
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_dependencies()
|
||||
|
||||
|
||||
@task
|
||||
def install_mayan():
|
||||
"""
|
||||
Install Mayan EDMS
|
||||
"""
|
||||
|
||||
print('Installing Mayan EDMS from git repository')
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_mayan()
|
||||
|
||||
|
||||
@task
|
||||
def install_database_manager():
|
||||
"""
|
||||
Install the selected database manager
|
||||
"""
|
||||
|
||||
print('Installing database manager: %s' % env.database_manager_name)
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_database_manager()
|
||||
|
||||
|
||||
@task
|
||||
def fix_permissions():
|
||||
"""
|
||||
Fix installation files' permissions
|
||||
"""
|
||||
|
||||
print('Fixing installation files\' permissions')
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.fix_permissions()
|
||||
|
||||
|
||||
@task
|
||||
def install_webserver():
|
||||
"""
|
||||
Installing the OS packages for the webserver
|
||||
"""
|
||||
|
||||
print('Installing webserver: %s' % env.webserver_name)
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_webserver()
|
||||
@@ -0,0 +1,68 @@
|
||||
from fabric.api import run, sudo, cd, env, task
|
||||
|
||||
from ..literals import DB_MYSQL, WEB_APACHE
|
||||
|
||||
|
||||
def install_dependencies():
|
||||
"""
|
||||
Install Ubuntu dependencies
|
||||
"""
|
||||
sudo('apt-get install -y git-core gcc tesseract-ocr unpaper python-virtualenv ghostscript libjpeg-dev libpng-dev poppler-utils')
|
||||
|
||||
|
||||
def uninstall():
|
||||
"""
|
||||
Uninstall Mayan EDMS from an Ubuntu system
|
||||
"""
|
||||
sudo('rm %s -Rf' % env.virtualenv_path)
|
||||
|
||||
|
||||
def fix_permissions():
|
||||
"""
|
||||
Fix installation files' permissions on an Ubuntu system
|
||||
"""
|
||||
sudo('chmod 777 %s -R' % env.virtualenv_path)
|
||||
sudo('chgrp www-data %s -R' % env.virtualenv_path)
|
||||
|
||||
|
||||
def install_mayan():
|
||||
"""
|
||||
Install Mayan EDMS on an Ubuntu system
|
||||
"""
|
||||
with cd(env.install_path):
|
||||
sudo('virtualenv --no-site-packages %s' % env.virtualenv_name)
|
||||
|
||||
with cd(env.virtualenv_path):
|
||||
sudo('git clone http://www.github.com/rosarior/mayan %s' % env.repository_name)
|
||||
sudo('source bin/activate; pip install -r %s/requirements/production.txt' % env.repository_name)
|
||||
|
||||
|
||||
def syncdb():
|
||||
with cd(env.virtualenv_path):
|
||||
sudo('source bin/activate; %(repository_name)s/manage.py syncdb --noinput; %(repository_name)s/manage.py migrate' % (env))
|
||||
|
||||
|
||||
def install_database_manager():
|
||||
"""
|
||||
Install the database manager on an Ubuntu system
|
||||
"""
|
||||
|
||||
if env.database_manager == DB_MYSQL:
|
||||
sudo('apt-get install -y mysql-server libmysqlclient-dev')
|
||||
|
||||
with cd(env.virtualenv_path):
|
||||
sudo('source bin/activate; pip install MySQL-python')
|
||||
|
||||
|
||||
@task
|
||||
def install_webserver():
|
||||
"""
|
||||
Installing the Ubuntu packages for the webserver
|
||||
"""
|
||||
|
||||
if env.webserver == WEB_APACHE:
|
||||
sudo('apt-get install -y apache2 libapache2-mod-wsgi')
|
||||
|
||||
with settings(warn_only=True):
|
||||
# Get rid of Apache's default site
|
||||
sudo('a2dissite default')
|
||||
Reference in New Issue
Block a user