wip
This commit is contained in:
parent
ef2b190964
commit
01aaebd05c
3 changed files with 47 additions and 23 deletions
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$CONFIG = array (
|
$CONFIG = array (
|
||||||
|
'instanceid' => '${instance_id}',
|
||||||
|
% if not setup:
|
||||||
'passwordsalt' => 'jySy/iELFRob7rRpecEXAI2Rn1gbNI',
|
'passwordsalt' => 'jySy/iELFRob7rRpecEXAI2Rn1gbNI',
|
||||||
'secret' => 'wj3r+B2/NS8X/ETWCTnwwrNy+dyy2OSWRCVQxDE8+UZBJrRd',
|
'secret' => 'wj3r+B2/NS8X/ETWCTnwwrNy+dyy2OSWRCVQxDE8+UZBJrRd',
|
||||||
'trusted_domains' =>
|
'trusted_domains' =>
|
||||||
|
@ -8,14 +10,14 @@ $CONFIG = array (
|
||||||
),
|
),
|
||||||
'datadirectory' => '/var/lib/nextcloud',
|
'datadirectory' => '/var/lib/nextcloud',
|
||||||
'dbtype' => 'pgsql',
|
'dbtype' => 'pgsql',
|
||||||
'version' => '21.0.2.1',
|
'version' => '${version}',
|
||||||
'overwrite.cli.url' => 'http://localhost',
|
'overwrite.cli.url' => 'http://localhost',
|
||||||
'dbname' => 'nextcloud',
|
'dbname' => 'nextcloud',
|
||||||
'dbhost' => 'localhost',
|
'dbhost' => 'localhost',
|
||||||
'dbport' => '',
|
'dbport' => '',
|
||||||
'dbtableprefix' => 'oc_',
|
'dbtableprefix' => 'oc_',
|
||||||
'dbuser' => 'nextcloud',
|
'dbuser' => 'nextcloud',
|
||||||
'dbpassword' => 'JQImkLIeaa38whvJ1lBj3UeMqNt0SH33',
|
'dbpassword' => '${db_password}',
|
||||||
'instanceid' => 'oc3wqc1kg39w',
|
|
||||||
'installed' => true,
|
'installed' => true,
|
||||||
|
% endif
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
assert node.has_bundle('php')
|
assert node.has_bundle('php')
|
||||||
|
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
|
from os.path import join
|
||||||
|
from mako.template import Template
|
||||||
|
|
||||||
def occ(command, *args, **kwargs):
|
def occ(command, *args, **kwargs):
|
||||||
return f"""sudo -u www-data php /opt/nextcloud/occ {command} {' '.join(args)} {' '.join(f'--{name.replace("_", "-")}' + (f'={value}' if value else '') for name, value in kwargs.items())}"""
|
return f"""sudo -u www-data php /opt/nextcloud/occ {command} {' '.join(args)} {' '.join(f'--{name.replace("_", "-")}' + (f'={value}' if value else '') for name, value in kwargs.items())}"""
|
||||||
|
|
||||||
version = node.metadata.get('nextcloud/version')
|
version = node.metadata.get('nextcloud/version')
|
||||||
|
|
||||||
|
# FILES AND FOLDERS
|
||||||
|
|
||||||
downloads[f'/tmp/nextcloud-{version}.tar.bz2'] = {
|
downloads[f'/tmp/nextcloud-{version}.tar.bz2'] = {
|
||||||
'url': f'https://download.nextcloud.com/server/releases/nextcloud-{version}.tar.bz2',
|
'url': f'https://download.nextcloud.com/server/releases/nextcloud-{version}.tar.bz2',
|
||||||
'sha256': node.metadata.get('nextcloud/sha256'),
|
'sha256': node.metadata.get('nextcloud/sha256'),
|
||||||
|
@ -49,28 +53,27 @@ actions['chown_/opt/nextcloud/config'] = {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
files['/opt/nextcloud/config/config.php'] = {
|
|
||||||
'owner': 'www-data',
|
|
||||||
'group': 'www-data',
|
|
||||||
'mode': '0770',
|
|
||||||
'needs': [
|
|
||||||
'action:extract_nextcloud',
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
directories[node.metadata.get('nextcloud/data_dir')] = {
|
directories[node.metadata.get('nextcloud/data_dir')] = {
|
||||||
'owner': 'www-data',
|
'owner': 'www-data',
|
||||||
'group': 'www-data',
|
'group': 'www-data',
|
||||||
'mode': '0770',
|
'mode': '0770',
|
||||||
}
|
}
|
||||||
|
|
||||||
actions['set_nextcloud_uninstalled'] = {
|
# SETUP
|
||||||
'command': """sed -i "/installed/d" /opt/nextcloud/config/config.php""",
|
|
||||||
'triggered': True,
|
with open(join(repo.path, 'bundles', 'nextcloud', 'files', 'config.php')) as file:
|
||||||
'needs': [
|
content = Template(file.read()).render(
|
||||||
'file:/opt/nextcloud/config/config.php',
|
setup=True,
|
||||||
],
|
instance_id=node.metadata.get('nextcloud/instance_id'),
|
||||||
}
|
)
|
||||||
|
actions['nextcloud_config_for_install'] = {
|
||||||
|
'command': f'echo {quote(content)} > /opt/nextcloud/config/config.php && chown www-data:www-data /opt/nextcloud/config/config.php',
|
||||||
|
'needs': [
|
||||||
|
'action:extract_nextcloud',
|
||||||
|
],
|
||||||
|
'triggered': True,
|
||||||
|
}
|
||||||
|
|
||||||
actions['install_nextcloud'] = {
|
actions['install_nextcloud'] = {
|
||||||
'command': occ(
|
'command': occ(
|
||||||
'maintenance:install',
|
'maintenance:install',
|
||||||
|
@ -85,28 +88,46 @@ actions['install_nextcloud'] = {
|
||||||
data_dir=node.metadata.get('nextcloud/data_dir'),
|
data_dir=node.metadata.get('nextcloud/data_dir'),
|
||||||
),
|
),
|
||||||
'unless': """
|
'unless': """
|
||||||
psql -At -d nextcloud -c "SELECT 'OK' FROM information_schema.tables WHERE table_name='oc_users' AND table_schema='public'" | grep -q "^OK$"
|
psql -At -d nextcloud -c "SELECT 'OK' FROM information_schema.tables WHERE table_name='users' AND table_schema='public'" | grep -q "^OK$"
|
||||||
""",
|
""",
|
||||||
'needs': [
|
'needs': [
|
||||||
|
'postgres_db:nextcloud',
|
||||||
f"directory:{node.metadata.get('nextcloud/data_dir')}",
|
f"directory:{node.metadata.get('nextcloud/data_dir')}",
|
||||||
'directory:/opt/nextcloud',
|
'directory:/opt/nextcloud',
|
||||||
'directory:/opt/nextcloud/config',
|
'directory:/opt/nextcloud/config',
|
||||||
'directory:/opt/nextcloud/apps',
|
'directory:/opt/nextcloud/apps',
|
||||||
'file:/opt/nextcloud/config/config.php',
|
|
||||||
'action:chown_/opt/nextcloud/config',
|
'action:chown_/opt/nextcloud/config',
|
||||||
'action:chown_/opt/nextcloud/apps',
|
'action:chown_/opt/nextcloud/apps',
|
||||||
'action:extract_nextcloud',
|
'action:extract_nextcloud',
|
||||||
],
|
],
|
||||||
'preceded_by': [
|
'preceded_by': [
|
||||||
f'action:set_nextcloud_uninstalled',
|
'action:nextcloud_config_for_install',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files['/opt/nextcloud/config/config.php'] = {
|
||||||
|
'content_type': 'mako',
|
||||||
|
'context': {
|
||||||
|
'setup': False,
|
||||||
|
'version': version,
|
||||||
|
'instance_id': node.metadata.get('nextcloud/instance_id'),
|
||||||
|
'db_password': node.metadata.get('postgresql/roles/nextcloud/password'),
|
||||||
|
},
|
||||||
|
'owner': 'www-data',
|
||||||
|
'group': 'www-data',
|
||||||
|
'mode': '0770',
|
||||||
|
'needs': [
|
||||||
|
'action:install_nextcloud',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
# UPGRADE
|
||||||
|
|
||||||
actions['upgrade_nextcloud'] = {
|
actions['upgrade_nextcloud'] = {
|
||||||
'command': occ('upgrade'),
|
'command': occ('upgrade'),
|
||||||
'unless': occ('status') + ' | grep -q "installed: true"',
|
'unless': occ('status') + ' | grep -q "installed: true"',
|
||||||
'needs': [
|
'needs': [
|
||||||
'action:install_nextcloud',
|
'file:/opt/nextcloud/config/config.php',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ defaults = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'nextcloud': {
|
'nextcloud': {
|
||||||
|
'instance_id': 'oc3wqc1kg39w',
|
||||||
'data_dir': '/var/lib/nextcloud',
|
'data_dir': '/var/lib/nextcloud',
|
||||||
'admin_user': 'admin',
|
'admin_user': 'admin',
|
||||||
'admin_pass': repo.vault.password_for(f'{node.name} nextcloud admin pw'),
|
'admin_pass': repo.vault.password_for(f'{node.name} nextcloud admin pw'),
|
||||||
|
|
Loading…
Reference in a new issue