Add new/improved install_corepos()
function
probably needs still more improvement, but getting here. so far it only does the office setup
This commit is contained in:
parent
cde124b916
commit
6c78d3c1d5
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2019 Lance Edgar
|
# Copyright © 2010-2023 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -24,13 +24,89 @@
|
||||||
Fabric library for CORE-POS (IS4C)
|
Fabric library for CORE-POS (IS4C)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from rattail_fabric2 import mysql, exists, mkdir
|
from rattail_fabric2 import mysql, exists, make_deploy, mkdir
|
||||||
|
|
||||||
|
|
||||||
|
deploy_generic = make_deploy(__file__)
|
||||||
|
|
||||||
|
|
||||||
|
def install_corepos(c, rootdir, rooturl_office, production=True,
|
||||||
|
user='www-data',
|
||||||
|
repo='https://github.com/CORE-POS/IS4C.git',
|
||||||
|
branch='master',
|
||||||
|
mysql_username='corepos',
|
||||||
|
mysql_password='corepos',
|
||||||
|
mysql_name_prefix='',
|
||||||
|
composer='composer.phar',
|
||||||
|
make_shadowread=False):
|
||||||
|
"""
|
||||||
|
Install the CORE software to the given location.
|
||||||
|
|
||||||
|
This will clone CORE code to the ``IS4C`` folder within the
|
||||||
|
specified ``rootdir`` location.
|
||||||
|
"""
|
||||||
|
rooturl_office = rooturl_office.rstrip('/')
|
||||||
|
|
||||||
|
mkdir(c, rootdir, use_sudo=True, owner=user)
|
||||||
|
|
||||||
|
# CORE source
|
||||||
|
is4c = os.path.join(rootdir, 'IS4C')
|
||||||
|
if not exists(c, is4c):
|
||||||
|
c.sudo('git clone --branch {} {} {}'.format(branch, repo, is4c),
|
||||||
|
user=user)
|
||||||
|
if production:
|
||||||
|
c.sudo('rm -f {}/fannie/DEV_MODE'.format(is4c), user=user)
|
||||||
|
else:
|
||||||
|
c.sudo('touch {}/fannie/DEV_MODE'.format(is4c), user=user)
|
||||||
|
|
||||||
|
# composer install
|
||||||
|
# TODO: these 'allow' entries are needed for composer 2.4 at least...
|
||||||
|
c.sudo("bash -c 'cd {} && {} config --no-plugins allow-plugins.composer/installers true'".format(is4c, composer),
|
||||||
|
user=user)
|
||||||
|
c.sudo("bash -c 'cd {} && {} config --no-plugins allow-plugins.oomphinc/composer-installers-extender true'".format(is4c, composer),
|
||||||
|
user=user)
|
||||||
|
c.sudo("bash -c 'cd {} && {} config --no-plugins allow-plugins.corepos/composer-installer true'".format(is4c, composer),
|
||||||
|
user=user)
|
||||||
|
# TODO: why is 'update' needed instead of 'install' ?
|
||||||
|
# c.sudo("bash -c 'cd {} && {} install'".format(is4c, composer),
|
||||||
|
# user=user)
|
||||||
|
c.sudo("bash -c 'cd {} && {} update'".format(is4c, composer),
|
||||||
|
user=user)
|
||||||
|
|
||||||
|
# shadowread
|
||||||
|
if make_shadowread:
|
||||||
|
c.sudo("bash -c 'cd {}/fannie/auth/shadowread && make'".format(is4c),
|
||||||
|
user=user)
|
||||||
|
# nb. must run `make install` as root
|
||||||
|
c.sudo("bash -c 'cd {}/fannie/auth/shadowread && make install'".format(is4c))
|
||||||
|
|
||||||
|
# fannie databases
|
||||||
|
mysql.create_db(c, '{}core_op'.format(mysql_name_prefix),
|
||||||
|
user='{}@localhost'.format(mysql_username))
|
||||||
|
mysql.create_db(c, '{}core_trans'.format(mysql_name_prefix),
|
||||||
|
user='{}@localhost'.format(mysql_username))
|
||||||
|
mysql.create_db(c, '{}trans_archive'.format(mysql_name_prefix),
|
||||||
|
user='{}@localhost'.format(mysql_username))
|
||||||
|
|
||||||
|
# fannie config
|
||||||
|
remote_path = '{}/IS4C/fannie/config.php'.format(rootdir)
|
||||||
|
if not exists(c, remote_path):
|
||||||
|
deploy_generic(c, 'corepos/fannie-config.php.mako', remote_path,
|
||||||
|
use_sudo=True, owner='www-data:{}'.format(user), mode='0640',
|
||||||
|
context={'rootdir': rootdir,
|
||||||
|
'rooturl': rooturl_office,
|
||||||
|
'mysql_username': mysql_username,
|
||||||
|
'mysql_password': mysql_password,
|
||||||
|
'mysql_name_prefix': mysql_name_prefix})
|
||||||
|
|
||||||
|
# fannie logging
|
||||||
|
mkdir(c, '{}/fannie/logs'.format(is4c), use_sudo=True,
|
||||||
|
owner='{}:www-data'.format(user), mode='0775')
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: deprecate / remove this
|
||||||
def install_fannie(c, rootdir, user='www-data', branch='version-2.10',
|
def install_fannie(c, rootdir, user='www-data', branch='version-2.10',
|
||||||
mysql_user='is4c', mysql_pass='is4c'):
|
mysql_user='is4c', mysql_pass='is4c'):
|
||||||
"""
|
"""
|
||||||
|
|
13
rattail_fabric2/deploy/corepos/fannie-config.php.mako
Normal file
13
rattail_fabric2/deploy/corepos/fannie-config.php.mako
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$FANNIE_ROOT = '${rootdir}/IS4C/fannie/';
|
||||||
|
$FANNIE_URL = '${rooturl}/';
|
||||||
|
$FANNIE_SERVER = '127.0.0.1';
|
||||||
|
$FANNIE_SERVER_DBMS = 'MYSQLI';
|
||||||
|
$FANNIE_SERVER_USER = '${mysql_username}';
|
||||||
|
$FANNIE_SERVER_PW = '${mysql_password}';
|
||||||
|
$FANNIE_OP_DB = '${mysql_name_prefix}core_op';
|
||||||
|
$FANNIE_TRANS_DB = '${mysql_name_prefix}core_trans';
|
||||||
|
$FANNIE_ARCHIVE_DB = '${mysql_name_prefix}trans_archive';
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in a new issue