wip
This commit is contained in:
parent
6fc6f0b6f4
commit
acb792f0a4
3 changed files with 44 additions and 9 deletions
|
@ -5,17 +5,44 @@ directories = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, config in node.metadata.get('left4dead2').items():
|
for name, config in node.metadata.get('left4dead2/servers').items():
|
||||||
config.pop('port')
|
config.pop('port')
|
||||||
|
config['sv_steamgroup'] = name
|
||||||
config['hostname'] = name
|
config['hostname'] = name
|
||||||
|
config['sv_steamgroup'] = ','.join(str(gid) for gid in node.metadata.get('left4dead2/steamgroups'))
|
||||||
|
|
||||||
files[f'/etc/left4dead2/{name}.cfg'] = {
|
files[f'/etc/left4dead2/{name}.cfg'] = {
|
||||||
'content': '\n'.join(
|
'content': '\n'.join(
|
||||||
f'{key} "{value}"' for key, value in config.items()
|
f'{key} "{value}"' for key, value in sorted(config.items())
|
||||||
),
|
) + '\n',
|
||||||
'owner': 'steam',
|
'owner': 'steam',
|
||||||
'triggers': [
|
'triggers': [
|
||||||
f'svc_systemd:left4dead2-server-{name}:restart',
|
f'svc_systemd:left4dead2-server-{name}:restart',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
svc_systemd[f'left4dead2-server-{name}'] = {}
|
svc_systemd[f'left4dead2-server-{name}'] = {
|
||||||
|
'needs': [
|
||||||
|
f'file:/etc/systemd/system/left4dead2-server-{name}.service',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
# TIDYUP
|
||||||
|
|
||||||
|
find_obsolete_units = (
|
||||||
|
'find /etc/systemd/system -type f -name "left4dead2-server-*.service" ' +
|
||||||
|
' '.join(f"! -name '{service}.service'" for service in svc_systemd)
|
||||||
|
)
|
||||||
|
actions['remove_obsolete_left4dead2_units'] = {
|
||||||
|
'command': (
|
||||||
|
f'for unitfile in $({find_obsolete_units}); '
|
||||||
|
f'do '
|
||||||
|
f'systemctl stop $(basename "$unitfile"); '
|
||||||
|
f'systemctl disable $(basename "$unitfile"); '
|
||||||
|
f'rm "$unitfile"; '
|
||||||
|
f'systemctl daemon-reload; '
|
||||||
|
f'done'
|
||||||
|
),
|
||||||
|
'unless': (
|
||||||
|
find_obsolete_units + " | wc -l | grep -q '^0$'"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@ defaults = {
|
||||||
'left4dead2': '222860',
|
'left4dead2': '222860',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'servers': {},
|
'left4dead2': {
|
||||||
|
'serevrs': {},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ def steam(metadata):
|
||||||
units = {}
|
units = {}
|
||||||
services = {}
|
services = {}
|
||||||
|
|
||||||
for name, config in metadata.get('left4dead2').items():
|
for name, config in metadata.get('left4dead2/servers').items():
|
||||||
units[f'left4dead2-server-{name}.service'] = {
|
units[f'left4dead2-server-{name}.service'] = {
|
||||||
'Unit': {
|
'Unit': {
|
||||||
'Description': 'steam: install and update games',
|
'Description': 'steam: install and update games',
|
||||||
|
|
|
@ -14,8 +14,14 @@
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'id': '3915f236-dd0a-4c6c-8fb3-1584c81038c6',
|
'id': '3915f236-dd0a-4c6c-8fb3-1584c81038c6',
|
||||||
'left4dead2': {
|
'left4dead2': {
|
||||||
'realism-expert': {
|
'steamgroups': [38347879],
|
||||||
'port': 27001,
|
'servers': {
|
||||||
|
'realism-expert2': {
|
||||||
|
'port': 27001,
|
||||||
|
},
|
||||||
|
'realism-expert3': {
|
||||||
|
'port': 27002,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'network': {
|
'network': {
|
||||||
|
|
Loading…
Reference in a new issue