diff --git a/bundles/nextcloud/items.py b/bundles/nextcloud/items.py index f07717a..76085e1 100644 --- a/bundles/nextcloud/items.py +++ b/bundles/nextcloud/items.py @@ -88,7 +88,7 @@ actions['install_nextcloud'] = { data_dir=node.metadata.get('nextcloud/data_dir'), ), 'unless': """ - psql -At -d nextcloud -c "SELECT 'OK' FROM information_schema.tables WHERE table_name='users' AND table_schema='public'" | grep -q "^OK$" + psql -At -d nextcloud -c "SELECT 'OK' FROM information_schema.tables WHERE table_name='oc_users' AND table_schema='public'" | grep -q "^OK$" """, 'needs': [ 'postgres_db:nextcloud', @@ -125,9 +125,9 @@ files['/opt/nextcloud/config/config.php'] = { actions['upgrade_nextcloud'] = { 'command': occ('upgrade'), - 'unless': occ('status') + ' | grep -q "installed: true"', - 'needs': [ - 'file:/opt/nextcloud/config/config.php', + 'triggered': True, + 'triggered_by': [ + f'action:extract_nextcloud', ], } diff --git a/bundles/nextcloud/metadata.py b/bundles/nextcloud/metadata.py index 5fcd0c8..3f16ee3 100644 --- a/bundles/nextcloud/metadata.py +++ b/bundles/nextcloud/metadata.py @@ -1,3 +1,6 @@ +import string +from uuid import UUID + defaults = { 'apt': { 'packages': { @@ -28,7 +31,6 @@ defaults = { }, }, 'nextcloud': { - 'instance_id': 'oc3wqc1kg39w', 'data_dir': '/var/lib/nextcloud', 'admin_user': 'admin', 'admin_pass': repo.vault.password_for(f'{node.name} nextcloud admin pw'), @@ -54,3 +56,18 @@ defaults = { }, }, } + + +@metadata_reactor.provides( + 'nextcloud/instance_id', +) +def instance_id(metadata): + return { + 'nextcloud': { + 'instance_id': repo.libs.derive_string.derive_string( + UUID(metadata.get('id')).bytes, + length=12, + choices=(string.ascii_lowercase + string.digits).encode(), + ).decode(), + }, + } diff --git a/libs/derive_string.py b/libs/derive_string.py index 06ecebd..828103c 100644 --- a/libs/derive_string.py +++ b/libs/derive_string.py @@ -62,9 +62,10 @@ def chacha_chracter(input, choices): def derive_string(input, length, choices): - get_character = chacha_chracter(input, choices) + sorted_choices = bytes(sorted(choices)) + get_character = chacha_chracter(input, sorted_choices) return bytes(islice(get_character, length)) -print( - derive_string(b'12344', length=100, choices=b'abcdefghijklmnopqrstuvwxyz0123456789') -) +# print( +# derive_string(b'12344', length=100, choices=b'abcdefghijklmnopqrstuvwxyz0123456789') +# )