Files
@ 5e5702bc107e
Branch filter:
Location: rattail-project/rattail/fabfile.py - annotation
5e5702bc107e
5.9 KiB
text/x-python
Comment out broken test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | cb0cb5abcb0e ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 cb0cb5abcb0e ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 ce10ee7d7ef8 cb0cb5abcb0e cb0cb5abcb0e b24cd9b8fac0 ce10ee7d7ef8 ce10ee7d7ef8 331f775512a6 ce10ee7d7ef8 ce10ee7d7ef8 0bd512b7f502 0bd512b7f502 0bd512b7f502 0bd512b7f502 0bd512b7f502 0bd512b7f502 0bd512b7f502 0bd512b7f502 0bd512b7f502 0bd512b7f502 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 0128177a4f14 331f775512a6 0128177a4f14 0128177a4f14 0128177a4f14 0128177a4f14 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 710ef746644d 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 331f775512a6 665457257332 331f775512a6 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 710ef746644d 665457257332 | # -*- coding: utf-8 -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2014 Lance Edgar
#
# This file is part of Rattail.
#
# Rattail is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
from __future__ import unicode_literals
import shutil
from fabric.api import *
from fabric.contrib.files import exists, upload_template
@task
def release():
"""
Release a new version of `rattail`.
"""
shutil.rmtree('rattail.egg-info')
local('python setup.py sdist --formats=gztar register upload')
def get_overwrite(overwrite=None):
"""
Obtain a canonical "overwrite" directive.
"""
if overwrite in (True, False):
return overwrite
if overwrite is None:
overwrite = raw_input("Overwrite as needed? [y/N]: ")
overwrite = overwrite.strip().lower()
else:
overwrite = overwrite.lower()
return overwrite.startswith('y')
def prettify(text):
"""
Return a "prettified" version of text.
"""
text = text.replace('_', ' ')
text = text.replace('-', ' ')
words = text.split()
return ' '.join([x.capitalize() for x in words])
@task
def create_user(overwrite=None):
"""
Create the 'rattail' user account.
"""
overwrite = get_overwrite(overwrite)
with settings(warn_only=True):
result = run('id rattail')
if result.return_code: # user doesn't exist
sudo('adduser --system --home /var/lib/rattail --group rattail')
elif overwrite:
sudo('usermod --home /var/lib/rattail --move-home --shell /bin/false rattail')
def configure_rattail_lib(overwrite=None):
"""
Configure basic Rattail "library" files.
"""
overwrite = get_overwrite(overwrite)
if not exists('/etc/default/rattail') or overwrite:
put('data/etc/default/rattail', '/etc/default', use_sudo=True)
sudo('chown root: /etc/default/rattail')
if not exists('/var/lib/rattail'):
create_user(overwrite=True)
if not exists('/var/lib/rattail/init.d'):
sudo('mkdir /var/lib/rattail/init.d', user='rattail')
if not exists('/var/run/rattail'):
sudo('mkdir /var/run/rattail')
sudo('chown rattail: /var/run/rattail')
@task
def configure_filemon(name=None, desc=None, envdir=None, overwrite=None):
"""
Configure a Rattail File Monitor daemon.
"""
if name is None:
default_name = 'rattail-filemon'
name = raw_input("Enter a name for the service [{0}]: ".format(default_name))
name = name.strip() or default_name
if desc is None:
default_desc = prettify(name.replace('filemon', 'file-monitor'))
desc = raw_input("Enter a description [{0}]: ".format(default_desc))
desc = desc.strip() or default_desc
if envdir is None:
default_envdir = name.replace('-filemon', '')
default_envdir = default_envdir.replace('-', '.')
default_envdir = '/srv/envs/{0}'.format(default_envdir)
envdir = raw_input("Enter a virtual environment path [{0}]: ".format(default_envdir))
envdir = envdir.strip() or default_envdir
overwrite = get_overwrite(overwrite)
configure_rattail_lib(overwrite)
if not exists('/var/lib/rattail/init.d/filemon') or overwrite:
put('data/var/lib/rattail/init.d/filemon', '/var/lib/rattail/init.d', use_sudo=True)
sudo('chown rattail: /var/lib/rattail/init.d/filemon')
script = '/etc/init.d/{0}'.format(name)
if not exists(script) or overwrite:
upload_template('data/etc/init.d/rattail-filemon_tmpl', script,
context=locals(), use_sudo=True, mode=0755)
sudo('chown root: {0}'.format(script))
sudo('update-rc.d {0} defaults'.format(script))
@task
def configure_dbsync(name=None, desc=None, envdir=None, overwrite=None):
"""
Configure a Rattail Database Synchonizer daemon.
"""
if name is None:
default_name = 'rattail-dbsync'
name = raw_input("Enter a name for the service [{0}]: ".format(default_name))
name = name.strip() or default_name
if desc is None:
default_desc = prettify(name.replace('dbsync', 'database-synchronizer'))
desc = raw_input("Enter a description [{0}]: ".format(default_desc))
desc = desc.strip() or default_desc
if envdir is None:
default_envdir = name.replace('-dbsync', '')
default_envdir = default_envdir.replace('-', '.')
default_envdir = '/srv/envs/{0}'.format(default_envdir)
envdir = raw_input("Enter a virtual environment path [{0}]: ".format(default_envdir))
envdir = envdir.strip() or default_envdir
overwrite = get_overwrite(overwrite)
configure_rattail_lib(overwrite)
if not exists('/var/lib/rattail/init.d/dbsync') or overwrite:
put('data/var/lib/rattail/init.d/dbsync', '/var/lib/rattail/init.d', use_sudo=True)
sudo('chown rattail: /var/lib/rattail/init.d/dbsync')
script = '/etc/init.d/{0}'.format(name)
if not exists(script) or overwrite:
upload_template('data/etc/init.d/rattail-dbsync_tmpl', script,
context=locals(), use_sudo=True, mode=0755)
sudo('chown root: {0}'.format(script))
sudo('update-rc.d {0} defaults'.format(script))
|