Removal of fabric file installation support, this should be its own separate project

This commit is contained in:
Roberto Rosario
2014-06-20 20:20:58 -04:00
parent 956bf0f9d8
commit 58930fed8c
24 changed files with 7 additions and 1040 deletions

View File

@@ -19,27 +19,6 @@ text parsing and OCR capabilities.
`Mailing list (via Google Groups)`_
Quick install
-------------
To bootstrap **Mayan EDMS** via the fabfile without having to clone
the entire repository, run the following command, replacing the part that
reads: with your current MySQL root password or the MySQL root password
you plan to assign to it, during the MySQL installation when executing the fabfile.
- Debian or Ubuntu:
cd /tmp && sudo apt-get install -y fabric wget tar gzip && wget
https://github.com/mayan-edms/mayan-edms/raw/master/contrib/fabfile.tar.gz
-O - \| tar -xvzf - && echo “database\_manager\_admin\_password=<Your
MySQL root password>” > ~/.fabricrc && fab -H localhost install
- Fedora:
cd /tmp && sudo yum install -y fabric wget tar gzip && wget
https://github.com/mayan-edms/mayan-edms/raw/master/contrib/fabfile.tar.gz
-O - \| tar -xvzf - && echo “database\_manager\_admin\_password=<Your
MySQL root password>” > ~/.fabricrc && fab -H localhost install
License
-------

Binary file not shown.

View File

@@ -2,82 +2,6 @@
Installation
============
Automatic install using included fabfile
----------------------------------------
A Fabric_ file is included to help users not very familiar with Ubuntu_,
Python_ and Django_ install **Mayan EDMS**, or for system administrators
looking to automate the install whether in a local or remote system.
To bootstrap **Mayan EDMS** via the fabfile without having to clone the
entire repository, run the following command, replacing the part that
reads: <Your MySQL root password> with your current MySQL root password
or the MySQL root password you plan to assign to it, during the MySQL
installation when executing the fabfile.
* Debian or Ubuntu::
$ cd /tmp && sudo apt-get install -y fabric wget tar gzip && wget https://github.com/mayan-edms/mayan-edms/raw/master/contrib/fabfile.tar.gz -O - | tar -xvzf - && echo "database_manager_admin_password=<Your MySQL root password>" > ~/.fabricrc && fab -H localhost install
* Fedora::
$ cd /tmp && sudo yum install -y fabric wget tar gzip && wget https://github.com/mayan-edms/mayan-edms/raw/master/contrib/fabfile.tar.gz -O - | tar -xvzf - && echo "database_manager_admin_password=<Your MySQL root password>" > ~/.fabricrc && fab -H localhost install
The ``fabfile`` also supports deploying to more than one server whether
the they same configuration or not, via a ``server_config.json`` file.
The fabfile also supports YAML server configuration
files but requires installing ``pyyaml`` via ``pip``, ``python-yaml``
via ``apt`` (Debian_, Ubuntu_) or ``PyYAML`` via ``yum`` (Fedora_)
A sample ``server_config.yaml`` would be as follows::
debian_server:
host: 192.168.1.1
database_manager_admin_password: my_debian_mysql_pa$$word
drop_database: True
os: debian
ubuntu_server:
host: 192.168.1.2
database_manager_admin_password: my_ubuntu_mysql_pa$$word
drop_database: True
os: ubuntu
database_username: mayan_release_12
database_name: mayan_release_12
all_servers: [debian_server, ubuntu_server]
To install **Mayan EDMS** to these servers the ``fabfile`` should be called in the following manner::
$ fab servers:debian_server install
or::
$ fab servers:ubuntu_server,debian_server install
or::
$ fab servers:all_servers install
Configuration options for the ``fabfile``:
* ``host`` Hostname or address of the host to which to install **Mayan EDMS**. Required setting.
* ``os`` Operating system of the target host. Options: ubuntu, debian, fedora. default: ubuntu
* ``install_path`` Installation path. Default: /usr/share
* ``virtualenv_name`` Name of the directory that will house the virtualenv under the ``install_path``. Default: mayan
* ``repository_name`` Name of the directory where the repository will be clone under the ``virtualenv_name`` directory. Default: mayan
* ``database_manager`` Database manager to use. Options: mysql. Default: mysql
* ``database_username`` Username that will be created and used to access the database. Default: mayan
* ``database_password`` Password of the database user account. Default: random autogenerated password
* ``database_host`` Address of the database manager host. Default: 127.0.0.1
* ``drop_database`` Weather or not to drop the database when uninstalling **Mayan EDMS** via the fabfile. Default: False
* ``database_manager_admin_password`` Administrator password of the database manager, only used to create the **Mayan EDMS** database and user. Required setting.
* ``database_name`` Name of the **Mayan EDMS** database. Default: mayan
* ``webserver`` Web server that will be install and configure to server **Mayan EDMS**. Options: apache. Default: apache
Only the options: ``host``, ``os`` and ``database_manager_admin_password`` should be required for most installations.
Local or managed Ubuntu or Debian server
----------------------------------------
@@ -215,14 +139,6 @@ SaaS provied Appsembler_ has started providing a "1-click install" cloud
offering of **Mayan EDMS**. Go to their website and click on apps to start
your trial period of **Mayan EDMS** on the cloud.
DjangoZoom
----------
For instructions on how to deploy **Mayan EDMS** on DjangoZoom, watch the screencast:
"Deploying Mayan EDMS on DjangoZoom.net" available on Youtube_
Webfaction
----------
@@ -353,5 +269,4 @@ To install **Mayan EDMS** on Webfaction_, follow these steps:
.. _virtualenv: http://www.virtualenv.org/en/latest/index.html
.. _`Reducing mod_wsgi Memory Consumption`: http://docs.webfaction.com/software/mod-wsgi.html#mod-wsgi-reducing-memory-consumption
.. _Fedora: http://fedoraproject.org/
.. _Fabric: http://docs.fabfile.org/
.. _Appsembler: http://appsembler.com/

View File

@@ -20,10 +20,11 @@ The growth and reach of the project has necessitaded for a while the move
of the project to its own organization in Github. This move has finally been
done, the new URL of the project is: https://github.com/mayan-edms/mayan-edms
Django 1.4.13
Django 1.5
~~~~~~~~~~~~~
This release updates the required version of Django to 1.4.13, bringing with it
not only new features, but also a lot of security updates.
This release updates the required version of Django to 1.5, bringing with it
not only new features, but also a lot of security updates, a new project
directory structure and new deployment methods.
Translation updates
~~~~~~~~~~~~~~~~~~~
@@ -69,6 +70,9 @@ Deletion of detached signatures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Detached signatures can now be deleted, if accidentally added to the wrong document.
Removal of fabric based installations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Upgrading from a previous version
=================================

View File

@@ -1,72 +0,0 @@
import sys
from fabric.api import task, env
from fabric.colors import white
import databases as database
import platforms as platform
import webservers as webserver
import django
import mayan_edms
from conf import print_supported_configs
from server_config import servers
print(white('\n\n ######## ', bold=True))
print(white(' ######## ', bold=True))
print(white(' ### ### ', bold=True))
print(white(' ##### ##### ', bold=True))
print(white(' ############## ', bold=True))
print(white(' ####### ####### ', bold=True))
print(white(' ################## ', bold=True))
print(white(' ######### ######### ', bold=True))
print(white(' ###################### ', bold=True))
print(white(' ########### ########### ', bold=True))
print(white(' ########################## ', bold=True))
print(white('############# #############', bold=True))
print(white('\nMayan EDMS Fabric installation file\n\n', bold=True))
print_supported_configs()
@task
def install():
"""
Perform a complete install of Mayan EDMS on a host
"""
platform.install_dependencies()
platform.install_mayan()
platform.install_database_manager()
database.create_database()
database.create_user()
django.database_config()
django.syncdb()
django.collectstatic()
platform.fix_permissions()
platform.install_webserver()
webserver.install_site()
webserver.restart()
platform.post_install()
'''
# Disabled until properly implemented
@task
def upgrade():
"""
Perform a Mayan EDMS installation upgrade
"""
mayan_edms.upgrade()
'''
@task
def uninstall():
"""
Perform a complete removal of Mayan EDMS from a host
"""
platform.delete_mayan()
webserver.remove_site()
webserver.restart()
if env.drop_database:
database.drop_database()
database.drop_user()

View File

@@ -1,60 +0,0 @@
import os
import string
import random
from fabric.api import env
from fabric.colors import green
from literals import (DEFAULT_INSTALL_PATH, DEFAULT_VIRTUALENV_NAME,
DEFAULT_REPOSITORY_NAME, DEFAULT_OS, OS_CHOICES,
DEFAULT_DATABASE_MANAGER, DB_CHOICES, DEFAULT_DATABASE_NAME,
DEFAULT_WEBSERVER, WEB_CHOICES, DEFAULT_DATABASE_USERNAME,
DJANGO_DB_DRIVERS, DEFAULT_DATABASE_HOST, DEFAULT_PASSWORD_LENGTH)
from server_config import reduce_env
def password_generator():
# http://snipplr.com/view/63223/python-password-generator/
chars = string.ascii_letters + string.digits
return ''.join(random.choice(chars) for x in range(DEFAULT_PASSWORD_LENGTH))
@reduce_env
def setup_environment():
env['os'] = getattr(env, 'os', DEFAULT_OS)
env['os_name'] = OS_CHOICES[env.os]
env['install_path'] = getattr(env, 'install_path', DEFAULT_INSTALL_PATH[env.os])
env['virtualenv_name'] = getattr(env, 'virtualenv_name', DEFAULT_VIRTUALENV_NAME[env.os])
env['repository_name'] = getattr(env, 'repository_name', DEFAULT_REPOSITORY_NAME[env.os])
env['virtualenv_path'] = os.path.join(env.install_path, env.virtualenv_name)
env['repository_path'] = os.path.join(env.virtualenv_path, env.repository_name)
env['database_manager'] = getattr(env, 'database_manager', DEFAULT_DATABASE_MANAGER)
env['database_manager_name'] = DB_CHOICES[env.database_manager]
env['database_username'] = getattr(env, 'database_username', DEFAULT_DATABASE_USERNAME)
env['database_password'] = getattr(env, 'database_password', password_generator())
env['database_host'] = getattr(env, 'database_host', DEFAULT_DATABASE_HOST)
env['drop_database'] = getattr(env, 'drop_database', False)
if not getattr(env, 'database_manager_admin_password', None):
print('Must set the database_manager_admin_password entry in the fabric settings file (~/.fabricrc by default)')
exit(1)
env['database_name'] = getattr(env, 'database_name', DEFAULT_DATABASE_NAME)
env['webserver'] = getattr(env, 'webserver', DEFAULT_WEBSERVER)
env['webserver_name'] = WEB_CHOICES[env.webserver]
env['django_database_driver'] = DJANGO_DB_DRIVERS[env.database_manager]
def print_supported_configs():
print('Supported operating systems (os=): %s, default=\'%s\'' % (dict(OS_CHOICES).keys(), green(DEFAULT_OS)))
print('Supported database managers (database_manager=): %s, default=\'%s\'' % (dict(DB_CHOICES).keys(), green(DEFAULT_DATABASE_MANAGER)))
print('Supported webservers (webserver=): %s, default=\'%s\'' % (dict(WEB_CHOICES).keys(), green(DEFAULT_WEBSERVER)))
print('\n')

View File

@@ -1,54 +0,0 @@
from fabric.api import env, task
from fabric.colors import green
from ..conf import setup_environment
from ..literals import DB_MYSQL
import mysql
@task
def create_database():
"""
Create the Mayan EDMS database
"""
setup_environment()
print(green('Creating Mayan EDMS database', bold=True))
if env.database_manager == DB_MYSQL:
mysql.create_database()
@task
def create_user():
"""
Create the Mayan EDMS user
"""
setup_environment()
print(green('Creating Mayan EDMS user', bold=True))
if env.database_manager == DB_MYSQL:
mysql.create_user()
@task
def drop_database():
"""
Drop Mayan EDMS's database
"""
setup_environment()
print(green('Droping Mayan EDMS database', bold=True))
if env.database_manager == DB_MYSQL:
mysql.drop_database()
@task
def drop_user():
"""
Drop Mayan EDMS's user
"""
setup_environment()
print(green('Droping Mayan EDMS user', bold=True))
if env.database_manager == DB_MYSQL:
mysql.drop_user()

View File

@@ -1,36 +0,0 @@
from fabric.api import run, env, task, settings
from fabric.colors import green
def create_database():
"""
Create the MySQL Mayan EDMS database
"""
run('echo "CREATE DATABASE %(database_name)s;" | mysql -u root --password=%(database_manager_admin_password)s' % env)
def create_user():
"""
Create the MySQL Mayan EDMS user
"""
run('echo "CREATE USER \'%(database_username)s\'@\'%(database_host)s\' IDENTIFIED BY \'%(database_password)s\';" | mysql -u root --password=%(database_manager_admin_password)s' % env)
run('echo "GRANT ALL PRIVILEGES ON %(database_name)s.* TO \'%(database_username)s\'@\'%(database_host)s\' WITH GRANT OPTION;" | mysql -u root --password=%(database_manager_admin_password)s' % env)
print(green('Password used for Mayan EDMS database account: %s' % env.database_password, bold=True))
def drop_database():
"""
Drop MySQL's Mayan EDMS's database
"""
with settings(warn_only=True):
run('echo "DROP DATABASE %(database_name)s;" | mysql -u root --password=%(database_manager_admin_password)s' % env)
def drop_user():
"""
Drop MySQL's Mayan EDMS's user
"""
with settings(warn_only=True):
run('echo "DROP USER \'%(database_username)s\'@\'%(database_host)s\';" | mysql -u root --password=%(database_manager_admin_password)s' % env)

View File

@@ -1,34 +0,0 @@
import os
from fabric.api import env, task, cd, sudo
from fabric.contrib.files import upload_template
from ..conf import setup_environment
@task
def syncdb():
"""
Perform Django's syncdb command
"""
setup_environment()
with cd(env.virtualenv_path):
sudo('source bin/activate; %(repository_name)s/manage.py syncdb --noinput; %(repository_name)s/manage.py migrate' % (env))
@task
def database_config():
"""
Create a settings_local.py file tailored to the database manager selected
"""
setup_environment()
upload_template(filename=os.path.join('fabfile', 'templates', 'settings_local.py'), destination=env.repository_path, context=env, use_sudo=True)
@task
def collectstatic():
"""
Perform Django's collectstatic command
"""
setup_environment()
with cd(env.virtualenv_path):
sudo('source bin/activate; %(repository_name)s/manage.py collectstatic --noinput' % (env))

View File

@@ -1,72 +0,0 @@
OS_UBUNTU = 'ubuntu'
OS_REDHAT = 'redhat'
OS_CENTOS = 'centos'
OS_FEDORA = 'fedora'
OS_WINDOWS = 'windows'
OS_FREEBSD = 'freebds'
OS_DEBIAN = 'debian'
OS_CHOICES = {
OS_UBUNTU: 'Ubuntu',
OS_FEDORA: 'Fedora',
OS_DEBIAN: 'Debian',
#OS_REDHAT: 'RedHat',
#OS_CENTOS: 'CentOS',
#OS_WINDOWS: 'MS Windows',
#OS_FREEBSD: 'FreeBSD',
}
DEFAULT_INSTALL_PATH = {
OS_UBUNTU: '/usr/share',
OS_FEDORA: '/usr/share',
OS_DEBIAN: '/usr/share',
}
DEFAULT_VIRTUALENV_NAME = {
OS_UBUNTU: 'mayan',
OS_FEDORA: 'mayan',
OS_DEBIAN: 'mayan',
}
DEFAULT_REPOSITORY_NAME = {
OS_UBUNTU: 'mayan',
OS_FEDORA: 'mayan',
OS_DEBIAN: 'mayan',
}
DB_MYSQL = 'mysql'
DB_PGSQL = 'pgsql'
DB_SQLITE = 'sqlite'
DB_ORACLE = 'oracle'
DB_CHOICES = {
DB_MYSQL: 'MySQL',
#DB_PGSQL: 'PostgreSQL',
#DB_SQLITE: 'SQLite',
#DB_ORACLE: 'ORACLE'
}
DJANGO_DB_DRIVERS = {
DB_MYSQL: 'mysql',
DB_PGSQL: 'postgresql_psycopg2',
DB_SQLITE: 'sqlite3',
DB_ORACLE: 'oracle',
}
WEB_APACHE = 'apache'
WEB_NGINX = 'nginx'
WEB_CHOICES = {
WEB_APACHE: 'Apache',
#WEB_NGINX: 'Nginx',
}
DEFAULT_OS = OS_UBUNTU
DEFAULT_DATABASE_MANAGER = DB_MYSQL
DEFAULT_DATABASE_NAME = 'mayan'
DEFAULT_WEBSERVER = WEB_APACHE
DEFAULT_DATABASE_USERNAME = 'mayan'
DEFAULT_DATABASE_HOST = '127.0.0.1'
DEFAULT_PASSWORD_LENGTH = 10
FABFILE_MARKER = 'fabfile_install'

View File

@@ -1,50 +0,0 @@
from distutils.version import LooseVersion
import importlib
from fabric.api import env, task, cd, sudo, settings
from fabric.colors import green, red
from ..conf import setup_environment
@task
def upgrade():
"""
Upgrade a Mayan EDMS installation, but doing incremental upgrades
"""
setup_environment()
print(green('Upgrading Mayan EDMS database', bold=True))
with settings(warn_only=True):
with cd(env.virtualenv_path):
version = sudo('source bin/activate; python -c "import os;os.environ[\'DJANGO_SETTINGS_MODULE\']=\'mayan.settings\';from django.core.management import setup_environ;import settings;setup_environ(settings);import main;print main.__version__"')
if version.failed:
print(red('Unable to determined the current version.', bold=True))
exit()
current_verision = 'v%s' % version
print(green('Current version: %s' % version, bold=True))
with settings(warn_only=True):
with cd(env.repository_name):
tags = sudo('git tag').split('\r\n')
if tags.failed:
print(red('Upgrading is only support on git based installations.', bold=True))
exit()
tags.sort(key=LooseVersion)
latest_version = tags[-1]
print(green('Latest version: %s' % latest_version, bold=True))
upgrade_steps = tags.index(latest_version) - tags.index(current_verision)
if not upgrade_steps:
print(green('Already in the latest version, no need to upgrade.', bold=True))
exit()
else:
print(green('Upgrade steps needed until latest version: %d' % (), bold=True))
version_module_name = current_verision.replace('.', '_')
module = importlib.import_module('fabfile.mayan_edms.upgrades.%s' % version_module_name)
module.upgrade()

View File

@@ -1,14 +0,0 @@
from fabric.api import env, task, cd, sudo, settings
from fabric.colors import green, red
from ..conf import setup_environment
@task
def upgrade():
"""
Upgrade a Mayan EDMS installation from version v0.12.2 to v0.12.3
"""
setup_environment()
print(green('Upgrading Mayan EDMS database from version 0.12.2 to 0.12.3', bold=True))
#TODO: upgrade steps

View File

@@ -1,103 +0,0 @@
from fabric.api import run, sudo, cd, env, task
from fabric.colors import green
from ..literals import OS_UBUNTU, OS_FEDORA, OS_DEBIAN
from ..conf import setup_environment
import linux, ubuntu, fedora, debian
@task
def install_dependencies():
"""
Install OS dependencies
"""
setup_environment()
print(green('Installing dependencies for %s' % env.os_name, bold=True))
if env.os in [OS_UBUNTU, OS_DEBIAN]:
debian.install_dependencies()
elif env.os == OS_FEDORA:
fedora.install_dependencies()
@task
def install_mayan():
"""
Install Mayan EDMS
"""
setup_environment()
print(green('Installing Mayan EDMS from git repository', bold=True))
if env.os in [OS_UBUNTU, OS_FEDORA, OS_DEBIAN]:
linux.install_mayan()
@task
def install_database_manager():
"""
Install the selected database manager
"""
setup_environment()
print(green('Installing database manager: %s' % env.database_manager_name, bold=True))
if env.os in [OS_UBUNTU, OS_DEBIAN]:
debian.install_database_manager()
elif env.os == OS_FEDORA:
fedora.install_database_manager()
@task
def fix_permissions():
"""
Fix installation files' permissions
"""
setup_environment()
print(green('Fixing installation files\' permissions', bold=True))
if env.os in [OS_UBUNTU, OS_DEBIAN]:
debian.fix_permissions()
elif env.os == OS_FEDORA:
fedora.fix_permissions()
@task
def install_webserver():
"""
Installing the OS packages for the webserver
"""
setup_environment()
print(green('Installing webserver: %s' % env.webserver_name, bold=True))
if env.os in [OS_UBUNTU, OS_DEBIAN]:
debian.install_webserver()
elif env.os == OS_FEDORA:
fedora.install_webserver()
@task
def delete_mayan():
"""
Delete Mayan EDMS from the OS
"""
setup_environment()
print(green('Deleting Mayan EDMS files', bold=True))
if env.os in [OS_UBUNTU, OS_FEDORA, OS_DEBIAN]:
linux.delete_mayan()
@task
def post_install():
"""
Perform post install operations
"""
setup_environment()
if env.os == OS_UBUNTU:
ubuntu.post_install()
linux.post_install()
elif env.os == OS_FEDORA:
fedora.post_install()
linux.post_install()
elif env.os == OS_DEBIAN:
debian.post_install()
linux.post_install()

View File

@@ -1,50 +0,0 @@
from fabric.api import run, sudo, cd, env, task, settings
from ..literals import DB_MYSQL, WEB_APACHE
def install_dependencies():
"""
Install Debian dependencies
"""
sudo('apt-get install -y git-core gcc tesseract-ocr unpaper python-virtualenv ghostscript libjpeg-dev libpng-dev poppler-utils python-dev')
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')
def install_webserver():
"""
Installing the Debian 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')
def fix_permissions():
"""
Fix installation files' permissions on a Debian system
"""
sudo('chmod 770 %s -R' % env.virtualenv_path)
sudo('chgrp www-data %s -R' % env.virtualenv_path)
def post_install():
"""
Post install operations on a Debian system
"""
pass

View File

@@ -1,62 +0,0 @@
import os
from fabric.api import run, sudo, cd, env, task, settings
from fabric.operations import put, reboot
from ..literals import DB_MYSQL, WEB_APACHE
def install_dependencies():
"""
Install Fedora dependencies
"""
sudo('yum install -y git gcc tesseract unpaper python-virtualenv ghostscript libjpeg-turbo-devel libpng-devel poppler-utils')
def install_database_manager():
"""
Install the database manager on a Fedora system
"""
if env.database_manager == DB_MYSQL:
sudo('yum install -y mysql-server mysql-devel')
sudo('systemctl enable mysqld.service')
sudo('systemctl start mysqld.service')
sudo('mysql_secure_installation')
with cd(env.virtualenv_path):
sudo('source bin/activate; pip install MySQL-python')
def install_webserver():
"""
Installing the Fedora packages for the webserver
"""
if env.webserver == WEB_APACHE:
sudo('yum install -y httpd mod_wsgi')
sudo('systemctl enable httpd.service')
sudo('systemctl start httpd.service')
with settings(warn_only=True):
# Get rid of Apache's default site
sudo('rm /etc/httpd/conf.d/welcome.conf')
# Disable SELinux as it blocks mod_wsgi's file access
# TODO: implement a proper solution is implemented
put(local_path=os.path.join('fabfile', 'templates', 'selinux.config'), remote_path='/etc/selinux/config', use_sudo=True)
def fix_permissions():
"""
Fix installation files' permissions on a Fedora system
"""
sudo('chmod 770 %s -R' % env.virtualenv_path)
sudo('chgrp apache %s -R' % env.virtualenv_path)
def post_install():
"""
Post install operations on a Fedora system
"""
reboot()

View File

@@ -1,33 +0,0 @@
import os
from fabric.api import run, sudo, cd, env, task, settings
from ..literals import FABFILE_MARKER
def delete_mayan():
"""
Delete Mayan EDMS files from an Linux system
"""
sudo('rm %(virtualenv_path)s -Rf' % env)
def install_mayan():
"""
Install Mayan EDMS on an Linux system
"""
with cd(env.install_path):
sudo('virtualenv --no-site-packages %(virtualenv_name)s' % env)
with cd(env.virtualenv_path):
sudo('git clone git://github.com/rosarior/mayan.git %(repository_name)s' % env)
sudo('source bin/activate; pip install --upgrade distribute')
sudo('source bin/activate; pip install -r %(repository_name)s/requirements/production.txt' % env)
def post_install():
"""
Post install process on a Linux systems
"""
fabfile_marker = os.path.join(env.repository_path, FABFILE_MARKER)
sudo('touch %s' % fabfile_marker)

View File

@@ -1,5 +0,0 @@
def post_install():
"""
Post install operations on an Ubuntu system
"""
pass

View File

@@ -1,141 +0,0 @@
"""Fabric server config management fabfile.
If you need additional configuration, setup ~/.fabricrc file:
user = your_remote_server_username
To get specific command help type:
fab -d command_name
"""
# From http://fueledbylemons.com/blog/2011/04/09/server-configs-and-fabric/
import os
from fabric.api import env, task
from fabric.utils import puts
from fabric import colors
import fabric.network
import fabric.state
YAML_AVAILABLE = True
try:
import yaml
except ImportError:
YAML_AVAILABLE = False
JSON_AVAILABLE = True
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
JSON_AVAILABLE = False
################################
# ENVIRONMENTS #
################################
def _load_config(**kwargs):
"""Find and parse server config file.
If `config` keyword argument wasn't set look for default
'server_config.yaml' or 'server_config.json' file.
"""
config, ext = os.path.splitext(kwargs.get('config',
'server_config.yaml' if os.path.exists('server_config.yaml') else 'server_config.json'))
if not os.path.exists(config + ext):
print colors.red('Error. "%s" file not found.' % (config + ext))
return {}
if YAML_AVAILABLE and ext == '.yaml':
loader = yaml
elif JSON_AVAILABLE and ext =='.json':
loader = json
else:
print colors.red('Parser package not available')
return {}
# Open file and deserialize settings.
with open(config + ext) as config_file:
return loader.load(config_file)
@task
def servers(*args, **kwargs):
"""Set destination servers or server groups by comma delimited list of names"""
# Load config
servers = _load_config(**kwargs)
# If no arguments were recieved, print a message with a list of available configs.
if not args:
print 'No server name given. Available configs:'
for key in servers:
print colors.green('\t%s' % key)
# Create `group` - a dictionary, containing copies of configs for selected servers. Server hosts
# are used as dictionary keys, which allows us to connect current command destination host with
# the correct config. This is important, because somewhere along the way fabric messes up the
# hosts order, so simple list index incrementation won't suffice.
env.group = {}
# For each given server name
for name in args:
# Recursive function call to retrieve all server records. If `name` is a group(e.g. `all`)
# - get it's members, iterate through them and create `group`
# record. Else, get fields from `name` server record.
# If requested server is not in the settings dictionary output error message and list all
# available servers.
_build_group(name, servers)
# Copy server hosts from `env.group` keys - this gives us a complete list of unique hosts to
# operate on. No host is added twice, so we can safely add overlaping groups. Each added host is
# guaranteed to have a config record in `env.group`.
env.hosts = env.group.keys()
def _build_group(name, servers):
"""Recursively walk through servers dictionary and search for all server records."""
# We're going to reference server a lot, so we'd better store it.
server = servers.get(name, None)
# If `name` exists in servers dictionary we
if server:
# check whether it's a group by looking for `members`
if isinstance(server, list):
if fabric.state.output['debug']:
puts("%s is a group, getting members" % name)
for item in server:
# and call this function for each of them.
_build_group(item, servers)
# When, finally, we dig through to the standalone server records, we retrieve
# configs and store them in `env.group`
else:
if fabric.state.output['debug']:
puts("%s is a server, filling up env.group" % name)
env.group[server['host']] = server
else:
print colors.red('Error. "%s" config not found. Run `fab servers` to list all available configs' % name)
def reduce_env(task):
"""
Copies server config settings from `env.group` dictionary to env variable.
This way, tasks have easier access to server-specific variables:
`env.owner` instead of `env.group[env.host]['owner']`
"""
def task_with_setup(*args, **kwargs):
# If `s:server` was run before the current command - then we should copy values to
# `env`. Otherwise, hosts were passed through command line with `fab -H host1,host2
# command` and we skip.
if env.get("group", None):
for key,val in env.group[env.host].items():
setattr(env, key, val)
if fabric.state.output['debug']:
puts("[env] %s : %s" % (key, val))
task(*args, **kwargs)
# Don't keep host connections open, disconnect from each host after each task.
# Function will be available in fabric 1.0 release.
# fabric.network.disconnect_all()
return task_with_setup

View File

@@ -1,20 +0,0 @@
<VirtualHost *:80>
# Uncomment if libapache2-mod-xsendfile is installed
# XSendFile On
# XSendFileAllowAbove On
WSGIScriptAlias / %(repository_path)s/wsgi/dispatch.wsgi
<Directory %(repository_path)s>
Order deny,allow
Allow from all
</Directory>
#ErrorLog /var/log/apache2/mayan_error.log
LogLevel warn
#CustomLog /var/log/apache2/mayan_access.log combined
Alias /mayan-static "%(repository_path)s/static/"
<Location "/static">
SetHandler None
</Location>
</VirtualHost>

View File

@@ -1,10 +0,0 @@
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

View File

@@ -1,10 +0,0 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.%(django_database_driver)s',
'NAME': '%(database_name)s',
'USER': '%(database_username)s',
'PASSWORD': '%(database_password)s',
'HOST': '%(database_host)s',
'PORT': '',
}
}

View File

@@ -1,55 +0,0 @@
from fabric.api import run, sudo, cd, env, task
from fabric.colors import green
from ..conf import setup_environment
from ..literals import WEB_APACHE
import apache
@task
def install_site():
"""
Install Mayan EDMS site in the webserver configuration files
"""
setup_environment()
print(green('Adding Mayan EDMS\'s site files to: %s' % env.webserver_name, bold=True))
if env.webserver == WEB_APACHE:
apache.install_site()
@task
def remove_site():
"""
Install Mayan EDMS's site file from the webserver's configuration
"""
setup_environment()
print(green('Removing Mayan EDMS\'s site file from %s configuration' % env.webserver_name, bold=True))
if env.webserver == WEB_APACHE:
apache.remove_site()
@task
def restart():
"""
Restart the webserver
"""
setup_environment()
print(green('Restarting the web server: %s' % env.webserver_name, bold=True))
if env.webserver == WEB_APACHE:
apache.restart()
@task
def reload():
"""
Reload webserver configuration files
"""
setup_environment()
print(green('Reloading the web server configuration files', bold=True))
if env.webserver == WEB_APACHE:
apache.reload()

View File

@@ -1,50 +0,0 @@
import os
from fabric.api import run, sudo, cd, env, task, settings
from fabric.contrib.files import upload_template
from ..literals import OS_UBUNTU, OS_FEDORA, OS_DEBIAN
def install_site():
"""
Install Mayan EDMS's site file in Apache configuration
"""
# TODO: configurable site name
if env.os in [OS_UBUNTU, OS_DEBIAN]:
upload_template(filename=os.path.join('fabfile', 'templates', 'apache_site'), destination='/etc/apache2/sites-available/mayan.conf', context=env, use_sudo=True)
sudo('a2ensite mayan')
elif env.os == OS_FEDORA:
upload_template(filename=os.path.join('fabfile', 'templates', 'apache_site'), destination='/etc/httpd/conf.d/mayan.conf', context=env, use_sudo=True)
def remove_site():
"""
Install Mayan EDMS's site file from Apache's configuration
"""
if env.os in [OS_UBUNTU, OS_DEBIAN]:
with settings(warn_only=True):
sudo('a2dissite mayan')
elif env.os == OS_FEDORA:
with settings(warn_only=True):
sudo('rm /etc/httpd/conf.d/mayan.conf')
def restart():
"""
Restart Apache
"""
if env.os in [OS_UBUNTU, OS_DEBIAN]:
sudo('/etc/init.d/apache2 restart')
elif env.os == OS_FEDORA:
sudo('systemctl restart httpd.service')
def reload():
"""
Reload Apache configuration files
"""
if env.os in [OS_UBUNTU, OS_DEBIAN]:
sudo('/etc/init.d/apache2 reload')
elif env.os == OS_FEDORA:
sudo('systemctl reload httpd.service')