left4dead2 servers on overlayfs
This commit is contained in:
parent
096f9a845c
commit
f2b984e238
2 changed files with 55 additions and 4 deletions
|
@ -16,6 +16,13 @@ directories = {
|
|||
'group': 'steam',
|
||||
'purge': True,
|
||||
},
|
||||
# Current zfs doesnt support zfs upperdir. The support was added in October 2022. Move upperdir - unused anyway -
|
||||
# to another dir. Also move workdir alongside it, as it has to be on same fs.
|
||||
'/opt/steam-zfs-overlay-workarounds': {
|
||||
'owner': 'steam',
|
||||
'group': 'steam',
|
||||
'mode': '0744',
|
||||
},
|
||||
}
|
||||
|
||||
files = {
|
||||
|
@ -26,6 +33,10 @@ files = {
|
|||
}
|
||||
|
||||
for name, config in node.metadata.get('left4dead2/servers').items():
|
||||
directories[f'/opt/steam/left4dead2-servers/{name}'] = {}
|
||||
directories[f'/opt/steam-zfs-overlay-workarounds/{name}/upper'] = {}
|
||||
directories[f'/opt/steam-zfs-overlay-workarounds/{name}/workdir'] = {}
|
||||
|
||||
files[f'/opt/steam/left4dead2/left4dead2/cfg/server/{name}.cfg'] = {
|
||||
'content_type': 'mako',
|
||||
'source': 'server.cfg',
|
||||
|
@ -46,7 +57,22 @@ for name, config in node.metadata.get('left4dead2/servers').items():
|
|||
f'file:/usr/local/lib/systemd/system/left4dead2-{name}.service',
|
||||
],
|
||||
}
|
||||
|
||||
directories[f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons'] = {
|
||||
'owner': 'steam',
|
||||
'group': 'steam',
|
||||
'purge': True,
|
||||
}
|
||||
files[f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons/readme.txt'] = {
|
||||
'content_type': 'any',
|
||||
'owner': 'steam',
|
||||
'group': 'steam',
|
||||
}
|
||||
for id in node.metadata.get('left4dead2/workshop'):
|
||||
files[f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons/{id}.vpk'] = {
|
||||
'content_type': 'any',
|
||||
'owner': 'steam',
|
||||
'group': 'steam',
|
||||
}
|
||||
|
||||
files[f'/opt/steam/left4dead2/left4dead2/addons/readme.txt'] = {
|
||||
'content_type': 'any',
|
||||
|
@ -54,7 +80,6 @@ files[f'/opt/steam/left4dead2/left4dead2/addons/readme.txt'] = {
|
|||
'group': 'steam',
|
||||
}
|
||||
|
||||
|
||||
for id in node.metadata.get('left4dead2/workshop'):
|
||||
files[f'/opt/steam/left4dead2/left4dead2/addons/{id}.vpk'] = {
|
||||
'content_type': 'any',
|
||||
|
|
|
@ -66,8 +66,8 @@ def server_units(metadata):
|
|||
'Service': {
|
||||
'User': 'steam',
|
||||
'Group': 'steam',
|
||||
'WorkingDirectory': '/opt/steam/left4dead2',
|
||||
'ExecStart': f'/opt/steam/left4dead2/srcds_run -port {config["port"]} +exec server/{name}.cfg',
|
||||
'WorkingDirectory': f'/opt/steam/left4dead2-servers/{name}',
|
||||
'ExecStart': f'/opt/steam/left4dead2-servers/{name}/srcds_run -port {config["port"]} +exec server/{name}.cfg',
|
||||
'Restart': 'on-failure',
|
||||
},
|
||||
'Install': {
|
||||
|
@ -75,6 +75,32 @@ def server_units(metadata):
|
|||
},
|
||||
}
|
||||
|
||||
mountpoint = f'/opt/steam/left4dead2-servers/{name}'
|
||||
formatted_name = mountpoint[1:].replace('-', '\\x2d').replace('/', '-') + '.mount'
|
||||
units[formatted_name] = {
|
||||
'Unit': {
|
||||
'Description': f"Mount left4dead2 server {name} overlay",
|
||||
'Conflicts': 'umount.target',
|
||||
'Before': 'umount.target',
|
||||
},
|
||||
'Mount': {
|
||||
'What': 'overlay',
|
||||
'Where': mountpoint,
|
||||
'Type': 'overlay',
|
||||
'Options': ','.join([
|
||||
'auto',
|
||||
'lowerdir=/opt/steam/left4dead2',
|
||||
f'upperdir=/opt/steam-zfs-overlay-workarounds/{name}/upper',
|
||||
f'workdir=/opt/steam-zfs-overlay-workarounds/{name}/workdir',
|
||||
]),
|
||||
},
|
||||
'Install': {
|
||||
'WantedBy': {
|
||||
'multi-user.target',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return {
|
||||
'systemd': {
|
||||
'units': units,
|
||||
|
|
Loading…
Reference in a new issue