From 801a8bcf5fcc1d7796f916fc9af88211ea457dfa Mon Sep 17 00:00:00 2001 From: cronekorkn Date: Sat, 3 Dec 2022 19:51:13 +0100 Subject: [PATCH] left4dead: only individual server workshop downloads --- bundles/left4dead2/items.py | 83 +++++++++------------ bundles/left4dead2/metadata.py | 30 +------- bundles/pip/items.py | 1 + bundles/pip/metadata.py | 3 + bundles/steam-workshop-download/metadata.py | 3 + bundles/steam/items.py | 4 +- groups/os/debian.py | 1 + 7 files changed, 48 insertions(+), 77 deletions(-) create mode 100644 bundles/pip/items.py create mode 100644 bundles/pip/metadata.py diff --git a/bundles/left4dead2/items.py b/bundles/left4dead2/items.py index ad2d0f9..59c8429 100644 --- a/bundles/left4dead2/items.py +++ b/bundles/left4dead2/items.py @@ -1,19 +1,6 @@ assert node.has_bundle('steam') and node.has_bundle('steam-workshop-download') directories = { - '/opt/steam/left4dead2/left4dead2/ems/admin system': { - 'owner': 'steam', - 'group': 'steam', - 'mode': '0755', - }, - '/opt/steam/left4dead2/left4dead2/addons': { - 'owner': 'steam', - 'group': 'steam', - 'purge': True, - 'triggers': [ - *[f'svc_systemd:left4dead2-{name}.service:restart' for name in node.metadata.get('left4dead2/servers')], - ], - }, '/opt/steam/left4dead2-servers': { 'owner': 'steam', 'group': 'steam', @@ -30,30 +17,6 @@ directories = { }, } -files = { - '/opt/steam/left4dead2/left4dead2/ems/admin system/admins.txt': { - 'owner': 'steam', - 'group': 'steam', - 'mode': '0755', - 'content': '\n'.join(sorted(node.metadata.get('left4dead2/admins'))), - }, - '/opt/steam/left4dead2/left4dead2/addons/readme.txt': { - 'content_type': 'any', - 'owner': 'steam', - 'group': 'steam', - } -} - -for id in node.metadata.get('left4dead2/workshop'): - files[f'/opt/steam/left4dead2/left4dead2/addons/{id}.vpk'] = { - 'content_type': 'any', - 'owner': 'steam', - 'group': 'steam', - 'triggers': [ - *[f'svc_systemd:left4dead2-{name}.service:restart' for name in node.metadata.get('left4dead2/servers')], - ], - } - # /opt/steam/steam/.steam/sdk32/steamclient.so: cannot open shared object file: No such file or directory symlinks = { '/opt/steam/steam/.steam/sdk32': { @@ -99,7 +62,24 @@ for name, config in node.metadata.get('left4dead2/servers').items(): ], } - # addons + # service + svc_systemd[f'left4dead2-{name}.service'] = { + 'needs': [ + f'file:/opt/steam/left4dead2-servers/{name}/left4dead2/cfg/server.cfg', + f'file:/usr/local/lib/systemd/system/left4dead2-{name}.service', + ], + } + + # + # ADDONS + # + + # base + files[f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons/readme.txt'] = { + 'content_type': 'any', + 'owner': 'steam', + 'group': 'steam', + } directories[f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons'] = { 'owner': 'steam', 'group': 'steam', @@ -108,11 +88,6 @@ for name, config in node.metadata.get('left4dead2/servers').items(): f'svc_systemd:left4dead2-{name}.service:restart', ], } - files[f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons/readme.txt'] = { - 'content_type': 'any', - 'owner': 'steam', - 'group': 'steam', - } for id in [ *config.get('workshop', []), *node.metadata.get('left4dead2/workshop'), @@ -126,10 +101,22 @@ for name, config in node.metadata.get('left4dead2/servers').items(): ], } - # service - svc_systemd[f'left4dead2-{name}.service'] = { - 'needs': [ - f'file:/opt/steam/left4dead2-servers/{name}/left4dead2/cfg/server.cfg', - f'file:/usr/local/lib/systemd/system/left4dead2-{name}.service', + # admin system + + directories[f'/opt/steam/left4dead2-servers/{name}/left4dead2/ems/admin system'] = { + 'owner': 'steam', + 'group': 'steam', + 'mode': '0755', + 'triggers': [ + f'svc_systemd:left4dead2-{name}.service:restart', + ], + } + files[f'/opt/steam/left4dead2-servers/{name}/left4dead2/ems/admin system/admins.txt'] = { + 'owner': 'steam', + 'group': 'steam', + 'mode': '0755', + 'content': '\n'.join(sorted(node.metadata.get('left4dead2/admins'))), + 'triggers': [ + f'svc_systemd:left4dead2-{name}.service:restart', ], } diff --git a/bundles/left4dead2/metadata.py b/bundles/left4dead2/metadata.py index f7906bb..3ab593f 100644 --- a/bundles/left4dead2/metadata.py +++ b/bundles/left4dead2/metadata.py @@ -33,31 +33,6 @@ def rconn_password(metadata): } -@metadata_reactor.provides( - 'steam-workshop-download', -) -def workshop_download(metadata): - if metadata.get('left4dead2/workshop'): - return { - 'steam-workshop-download': { - 'left4dead2-global': { - 'ids': metadata.get('left4dead2/workshop'), - 'path': '/opt/steam/left4dead2/left4dead2/addons', - 'user': 'steam', - 'requires': { - 'steam-update.service', - }, - 'required_by': { - f'left4dead2-{name}.service' - for name in metadata.get('left4dead2/servers') - }, - }, - }, - } - else: - return {} - - @metadata_reactor.provides( 'steam-workshop-download', 'systemd/units', @@ -95,9 +70,10 @@ def server_units(metadata): } # individual workshop - if 'workshop' in config: + workshop_ids = config.get('workshop', set()) | metadata.get('left4dead2/workshop', set()) + if workshop_ids: workshop[f'left4dead2-{name}'] = { - 'ids': config['workshop'], + 'ids': workshop_ids, 'path': f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons', 'user': 'steam', 'requires': { diff --git a/bundles/pip/items.py b/bundles/pip/items.py new file mode 100644 index 0000000..2b550ea --- /dev/null +++ b/bundles/pip/items.py @@ -0,0 +1 @@ +pkg_pip = node.metadata.get('pip') diff --git a/bundles/pip/metadata.py b/bundles/pip/metadata.py new file mode 100644 index 0000000..d25783e --- /dev/null +++ b/bundles/pip/metadata.py @@ -0,0 +1,3 @@ +defaults = { + 'pip': {}, +} diff --git a/bundles/steam-workshop-download/metadata.py b/bundles/steam-workshop-download/metadata.py index b51fbe5..a330107 100644 --- a/bundles/steam-workshop-download/metadata.py +++ b/bundles/steam-workshop-download/metadata.py @@ -3,6 +3,9 @@ from shlex import quote defaults = { 'steam-workshop-download': {}, + 'pip': { + 'vpk': {}, + }, } diff --git a/bundles/steam/items.py b/bundles/steam/items.py index 451d702..be7636a 100644 --- a/bundles/steam/items.py +++ b/bundles/steam/items.py @@ -46,8 +46,8 @@ actions = { } svc_systemd['steam-update.service'] = { - 'running': False, - 'enabled': False, + 'running': None, + 'enabled': True, 'needs': { 'file:/usr/local/lib/systemd/system/steam-update.service', } diff --git a/groups/os/debian.py b/groups/os/debian.py index 69c32f5..ac8c8f6 100644 --- a/groups/os/debian.py +++ b/groups/os/debian.py @@ -5,6 +5,7 @@ 'bundles': [ 'apt', 'nftables', + 'pip', ], 'metadata': { 'apt': {