Add Fedora support to the fabfile (Tested on Fedora 17)
This commit is contained in:
@@ -39,6 +39,7 @@ def install():
|
||||
platform.install_webserver()
|
||||
webserver.install_site()
|
||||
webserver.restart()
|
||||
platform.post_install()
|
||||
|
||||
|
||||
@task
|
||||
|
||||
@@ -15,15 +15,18 @@ OS_CHOICES = {
|
||||
}
|
||||
|
||||
DEFAULT_INSTALL_PATH = {
|
||||
OS_UBUNTU: '/usr/share'
|
||||
OS_UBUNTU: '/usr/share',
|
||||
OS_FEDORA: '/usr/share'
|
||||
}
|
||||
|
||||
DEFAULT_VIRTUALENV_NAME = {
|
||||
OS_UBUNTU: 'mayan'
|
||||
OS_UBUNTU: 'mayan',
|
||||
OS_FEDORA: 'mayan'
|
||||
}
|
||||
|
||||
DEFAULT_REPOSITORY_NAME = {
|
||||
OS_UBUNTU: 'mayan'
|
||||
OS_UBUNTU: 'mayan',
|
||||
OS_FEDORA: 'mayan'
|
||||
}
|
||||
|
||||
DB_MYSQL = 'mysql'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from fabric.api import run, sudo, cd, env, task
|
||||
from fabric.colors import green
|
||||
|
||||
from ..literals import OS_UBUNTU
|
||||
import ubuntu
|
||||
from ..literals import OS_UBUNTU, OS_FEDORA
|
||||
import linux, ubuntu, fedora
|
||||
|
||||
|
||||
@task
|
||||
@@ -14,6 +14,8 @@ def install_dependencies():
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_dependencies()
|
||||
elif env.os == OS_FEDORA:
|
||||
fedora.install_dependencies()
|
||||
|
||||
|
||||
@task
|
||||
@@ -24,9 +26,9 @@ def install_mayan():
|
||||
|
||||
print(green('Installing Mayan EDMS from git repository', bold=True))
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_mayan()
|
||||
|
||||
if env.os in [OS_UBUNTU, OS_FEDORA]:
|
||||
linux.install_mayan()
|
||||
|
||||
|
||||
@task
|
||||
def install_database_manager():
|
||||
@@ -38,6 +40,8 @@ def install_database_manager():
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_database_manager()
|
||||
elif env.os == OS_FEDORA:
|
||||
fedora.install_database_manager()
|
||||
|
||||
|
||||
@task
|
||||
@@ -49,7 +53,9 @@ def fix_permissions():
|
||||
print(green('Fixing installation files\' permissions', bold=True))
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.fix_permissions()
|
||||
ubuntu.fix_permissions()
|
||||
elif env.os == OS_FEDORA:
|
||||
fedora.fix_permissions()
|
||||
|
||||
|
||||
@task
|
||||
@@ -62,6 +68,8 @@ def install_webserver():
|
||||
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.install_webserver()
|
||||
elif env.os == OS_FEDORA:
|
||||
fedora.install_webserver()
|
||||
|
||||
|
||||
@task
|
||||
@@ -72,5 +80,16 @@ def delete_mayan():
|
||||
|
||||
print(green('Deleting Mayan EDMS files', bold=True))
|
||||
|
||||
if env.os in [OS_UBUNTU, OS_FEDORA]:
|
||||
linux.delete_mayan()
|
||||
|
||||
|
||||
@task
|
||||
def post_install():
|
||||
"""
|
||||
Perform post install operations
|
||||
"""
|
||||
if env.os == OS_UBUNTU:
|
||||
ubuntu.delete_mayan()
|
||||
ubuntu.post_install()
|
||||
elif env.os == OS_FEDORA:
|
||||
fedora.post_install()
|
||||
|
||||
62
fabfile/platforms/fedora.py
Normal file
62
fabfile/platforms/fedora.py
Normal file
@@ -0,0 +1,62 @@
|
||||
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()
|
||||
20
fabfile/platforms/linux.py
Normal file
20
fabfile/platforms/linux.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from fabric.api import run, sudo, cd, env, task, settings
|
||||
|
||||
|
||||
def delete_mayan():
|
||||
"""
|
||||
Delete Mayan EDMS files from an Ubuntu system
|
||||
"""
|
||||
sudo('rm %s -Rf' % 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)
|
||||
@@ -10,33 +10,6 @@ def install_dependencies():
|
||||
sudo('apt-get install -y git-core gcc tesseract-ocr unpaper python-virtualenv ghostscript libjpeg-dev libpng-dev poppler-utils')
|
||||
|
||||
|
||||
def delete_mayan():
|
||||
"""
|
||||
Delete Mayan EDMS files 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 install_database_manager():
|
||||
"""
|
||||
Install the database manager on an Ubuntu system
|
||||
@@ -60,3 +33,18 @@ def install_webserver():
|
||||
with settings(warn_only=True):
|
||||
# Get rid of Apache's default site
|
||||
sudo('a2dissite default')
|
||||
|
||||
|
||||
def fix_permissions():
|
||||
"""
|
||||
Fix installation files' permissions on an Ubuntu 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 an Ubuntu system
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</Directory>
|
||||
ErrorLog /var/log/apache2/mayan_error.log
|
||||
#ErrorLog /var/log/apache2/mayan_error.log
|
||||
LogLevel warn
|
||||
CustomLog /var/log/apache2/mayan_access.log combined
|
||||
#CustomLog /var/log/apache2/mayan_access.log combined
|
||||
|
||||
Alias /mayan-static "%(repository_path)s/static/"
|
||||
<Location "/static">
|
||||
|
||||
10
fabfile/templates/selinux.config
Normal file
10
fabfile/templates/selinux.config
Normal file
@@ -0,0 +1,10 @@
|
||||
# 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
|
||||
@@ -1,34 +1,49 @@
|
||||
import os
|
||||
|
||||
from fabric.api import run, sudo, cd, env, task
|
||||
from fabric.api import run, sudo, cd, env, task, settings
|
||||
from fabric.contrib.files import upload_template
|
||||
|
||||
from ..literals import OS_UBUNTU, OS_FEDORA
|
||||
|
||||
|
||||
def install_site():
|
||||
"""
|
||||
Install Mayan EDMS's site file in Apache configuration
|
||||
"""
|
||||
# TODO: configurable site name
|
||||
upload_template(filename=os.path.join('fabfile', 'templates', 'apache_site'), destination='/etc/apache2/sites-available/mayan', context=env, use_sudo=True)
|
||||
sudo('a2ensite mayan')
|
||||
if env.os == OS_UBUNTU:
|
||||
upload_template(filename=os.path.join('fabfile', 'templates', 'apache_site'), destination='/etc/apache2/sites-available/mayan', 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
|
||||
"""
|
||||
sudo('a2dissite mayan')
|
||||
if env.os == OS_UBUNTU:
|
||||
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
|
||||
"""
|
||||
sudo('/etc/init.d/apache2 restart')
|
||||
if env.os == OS_UBUNTU:
|
||||
sudo('/etc/init.d/apache2 restart')
|
||||
elif env.os == OS_FEDORA:
|
||||
sudo('systemctl restart httpd.service')
|
||||
|
||||
|
||||
def reload():
|
||||
"""
|
||||
Reload Apache configuration files
|
||||
"""
|
||||
sudo('/etc/init.d/apache2 reload')
|
||||
if env.os == OS_UBUNTU:
|
||||
sudo('/etc/init.d/apache2 reload')
|
||||
elif env.os == OS_FEDORA:
|
||||
sudo('systemctl reload httpd.service')
|
||||
|
||||
Reference in New Issue
Block a user