Overhaul some things to support a basic CORE Office install

This commit is contained in:
Lance Edgar 2018-05-31 20:42:57 -05:00
parent a84d360509
commit 2c5e073168
5 changed files with 52 additions and 23 deletions

View file

@ -26,7 +26,7 @@ Fabric lib for Composer (PHP dependency manager)
from __future__ import unicode_literals, absolute_import
from fabric.api import sudo
from fabric.api import sudo, cd
from fabric.contrib.files import exists
from rattail_fabric import make_deploy
@ -45,3 +45,14 @@ def install_composer(user=None):
sudo('rm install-composer.sh')
if user:
sudo('chown {}: composer.phar'.format(user))
def install_globally():
"""
Install `composer.phar` in global location
"""
if not exists('/usr/local/bin/composer.phar'):
with cd('/usr/local/bin'):
deploy('composer/install-composer.sh', 'install-composer.sh')
sudo('./install-composer.sh')
sudo('rm install-composer.sh')

View file

@ -112,6 +112,8 @@ def put(local_path, remote_path, owner='root:root', **kwargs):
kwargs.setdefault('mirror_local_mode', True)
kwargs['use_sudo'] = True
fab_put(local_path, remote_path, **kwargs)
if ':' not in owner:
owner = '{}:'.format(owner)
sudo("chown {} '{}'".format(owner, remote_path))

View file

@ -32,34 +32,39 @@ from fabric.api import sudo, cd, env, run
from fabric.contrib.files import exists
from rattail_fabric import apt, mysql, mkdir
from rattail_fabric import make_deploy
def install_fannie(rootdir, branch='version-2.3', first_time=None, url=None):
deploy = make_deploy(__file__)
def install_fannie(rootdir, user='www-data', branch='version-2.3', first_time=None, url=None):
"""
Install the Fannie app to the given location
Install the Fannie app to the given location.
Please note, this assumes composer is already installed and available.
"""
if first_time is None:
first_time = not exists(rootdir)
mkdir(rootdir)
mkdir(rootdir, owner=user)
with cd(rootdir):
# fannie source
if not exists('IS4C'):
sudo('git clone https://github.com/CORE-POS/IS4C.git')
sudo('git clone https://github.com/CORE-POS/IS4C.git', user=user)
with cd('IS4C'):
sudo('git checkout {}'.format(branch))
sudo('git checkout {}'.format(branch), user=user)
with cd('IS4C'):
sudo('git pull')
sudo('git pull', user=user)
# composer
if not exists('composer.phar'):
sudo('curl -sS https://getcomposer.org/installer | php')
mkdir('/var/www/.composer', owner='www-data')
if user == 'www-data':
# TODO: why is this necessary? (but it is, nonetheless)
mkdir('/var/www/.composer', owner=user)
# fannie dependencies
with cd('IS4C'):
mkdir(['vendor', 'fannie/src/javascript/composer-components'], owner='www-data')
sudo('../composer.phar install', user='www-data')
mkdir(['vendor', 'fannie/src/javascript/composer-components'], owner=user)
sudo('composer.phar install', user=user)
# shadowread
with cd('IS4C/fannie/auth/shadowread'):
@ -69,15 +74,12 @@ def install_fannie(rootdir, branch='version-2.3', first_time=None, url=None):
# fannie config
with cd('IS4C/fannie'):
if not exists('config.php'):
sudo('cp config.php.dist config.php')
sudo('chown root:www-data config.php')
sudo('chmod 0660 config.php')
deploy('corepos/fannie/config.php.mako', 'config.php', owner=user, mode='0600')
# fannie logging
with cd('IS4C/fannie/logs'):
for name in ['fannie', 'debug_fannie', 'queries', 'php-errors', 'dayend']:
sudo('touch {}.log'.format(name))
sudo('chown www-data:www-data {}.log'.format(name))
sudo('touch {}.log'.format(name), user=user)
# fannie databases
mysql.create_user('is4c', host='%', password='is4c')

View file

@ -0,0 +1,12 @@
<?php
$FANNIE_ROOT = '/srv/fannie/IS4C/fannie/';
$FANNIE_URL = '/fannie/';
$FANNIE_SERVER = '127.0.0.1';
$FANNIE_SERVER_DBMS = 'MYSQLI';
$FANNIE_SERVER_USER = 'is4c';
$FANNIE_SERVER_PW = 'is4c';
$FANNIE_OP_DB = 'core_op';
$FANNIE_TRANS_DB = 'core_trans';
?>

View file

@ -35,14 +35,16 @@ from rattail_fabric import apt, make_deploy
deploy = make_deploy(__file__)
def install(password):
def install(password=None):
"""
Install the MySQL database service
"""
if password:
deploy('mysql/debconf.mako', 'debconf', context={'password': password})
sudo('debconf-set-selections debconf')
sudo('rm debconf')
apt.install('mysql-server')
if password:
deploy('mysql/my.cnf.mako', '/root/.my.cnf', mode='0600', context={'password': password})