left4dead unit dependencies
This commit is contained in:
parent
ccb6dcd14f
commit
daf582d6d8
4 changed files with 68 additions and 50 deletions
|
@ -37,57 +37,40 @@ def rconn_password(metadata):
|
||||||
'steam-workshop-download',
|
'steam-workshop-download',
|
||||||
)
|
)
|
||||||
def workshop_download(metadata):
|
def workshop_download(metadata):
|
||||||
if not metadata.get('left4dead2/workshop'):
|
if metadata.get('left4dead2/workshop'):
|
||||||
return {}
|
return {
|
||||||
|
'steam-workshop-download': {
|
||||||
result = {
|
'left4dead2-global': {
|
||||||
'left4dead-global': {
|
|
||||||
'ids': metadata.get('left4dead2/workshop'),
|
'ids': metadata.get('left4dead2/workshop'),
|
||||||
'path': '/opt/steam/left4dead2/left4dead2/addons',
|
'path': '/opt/steam/left4dead2/left4dead2/addons',
|
||||||
'user': 'steam',
|
'user': 'steam',
|
||||||
|
'requires': {
|
||||||
|
'steam.target',
|
||||||
|
},
|
||||||
|
'required_by': {
|
||||||
|
f'left4dead2-{name}.service'
|
||||||
|
for name in metadata.get('left4dead2/servers')
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
for name, config in metadata.get('left4dead2/servers').items():
|
return {}
|
||||||
if 'workshop' in config:
|
|
||||||
result[f'left4dead2-{name}'] = {
|
|
||||||
'ids': config['workshop'],
|
|
||||||
'path': f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons',
|
|
||||||
'user': 'steam',
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
'steam-workshop-download': result,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@metadata_reactor.provides(
|
@metadata_reactor.provides(
|
||||||
|
'steam-workshop-download',
|
||||||
'systemd/units',
|
'systemd/units',
|
||||||
)
|
)
|
||||||
def server_units(metadata):
|
def server_units(metadata):
|
||||||
units = {}
|
units = {}
|
||||||
|
workshop = {}
|
||||||
|
|
||||||
for name, config in metadata.get('left4dead2/servers').items():
|
for name, config in metadata.get('left4dead2/servers').items():
|
||||||
units[f'left4dead2-{name}.service'] = {
|
# mount overlay
|
||||||
'Unit': {
|
|
||||||
'Description': f'left4dead2 server {name}',
|
|
||||||
'After': {'steam.target'},
|
|
||||||
},
|
|
||||||
'Service': {
|
|
||||||
'User': 'steam',
|
|
||||||
'Group': 'steam',
|
|
||||||
'WorkingDirectory': f'/opt/steam/left4dead2-servers/{name}',
|
|
||||||
'ExecStart': f'/opt/steam/left4dead2-servers/{name}/srcds_run -port {config["port"]} +exec server.cfg',
|
|
||||||
'Restart': 'on-failure',
|
|
||||||
},
|
|
||||||
'Install': {
|
|
||||||
'WantedBy': {'multi-user.target'},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
mountpoint = f'/opt/steam/left4dead2-servers/{name}'
|
mountpoint = f'/opt/steam/left4dead2-servers/{name}'
|
||||||
formatted_name = mountpoint[1:].replace('-', '\\x2d').replace('/', '-') + '.mount'
|
mount_unit_name = mountpoint[1:].replace('-', '\\x2d').replace('/', '-') + '.mount'
|
||||||
units[formatted_name] = {
|
units[mount_unit_name] = {
|
||||||
'Unit': {
|
'Unit': {
|
||||||
'Description': f"Mount left4dead2 server {name} overlay",
|
'Description': f"Mount left4dead2 server {name} overlay",
|
||||||
'Conflicts': 'umount.target',
|
'Conflicts': 'umount.target',
|
||||||
|
@ -105,13 +88,47 @@ def server_units(metadata):
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
'Install': {
|
'Install': {
|
||||||
'WantedBy': {
|
'RequiredBy': {
|
||||||
'multi-user.target',
|
f'left4dead2-{name}.service',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# individual workshop
|
||||||
|
if 'workshop' in config:
|
||||||
|
workshop[f'left4dead2-{name}'] = {
|
||||||
|
'ids': config['workshop'],
|
||||||
|
'path': f'/opt/steam/left4dead2-servers/{name}/left4dead2/addons',
|
||||||
|
'user': 'steam',
|
||||||
|
'requires': {
|
||||||
|
mount_unit_name,
|
||||||
|
},
|
||||||
|
'required_by': {
|
||||||
|
f'left4dead2-{name}.service',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
# left4dead2 server unit
|
||||||
|
units[f'left4dead2-{name}.service'] = {
|
||||||
|
'Unit': {
|
||||||
|
'Description': f'left4dead2 server {name}',
|
||||||
|
'After': {'steam.target'},
|
||||||
|
'Requires': {'steam.target'},
|
||||||
|
},
|
||||||
|
'Service': {
|
||||||
|
'User': 'steam',
|
||||||
|
'Group': 'steam',
|
||||||
|
'WorkingDirectory': f'/opt/steam/left4dead2-servers/{name}',
|
||||||
|
'ExecStart': f'/opt/steam/left4dead2-servers/{name}/srcds_run -port {config["port"]} +exec server.cfg',
|
||||||
|
'Restart': 'on-failure',
|
||||||
|
},
|
||||||
|
'Install': {
|
||||||
|
'WantedBy': {'multi-user.target'},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'steam-workshop-download': workshop,
|
||||||
'systemd': {
|
'systemd': {
|
||||||
'units': units,
|
'units': units,
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,6 +21,7 @@ def workshop(metadata):
|
||||||
'steam-update.target',
|
'steam-update.target',
|
||||||
},
|
},
|
||||||
'Before': 'steam.target',
|
'Before': 'steam.target',
|
||||||
|
'Requires': conf['requires'],
|
||||||
},
|
},
|
||||||
'Service': {
|
'Service': {
|
||||||
'Type': 'oneshot',
|
'Type': 'oneshot',
|
||||||
|
@ -28,7 +29,7 @@ def workshop(metadata):
|
||||||
'ExecStart': f"/opt/steam-workshop-download {' '.join(quote(str(id)) for id in conf['ids'])} --out {quote(conf['path'])}",
|
'ExecStart': f"/opt/steam-workshop-download {' '.join(quote(str(id)) for id in conf['ids'])} --out {quote(conf['path'])}",
|
||||||
},
|
},
|
||||||
'Install': {
|
'Install': {
|
||||||
'WantedBy': {'multi-user.target'},
|
'RequiredBy': conf['required_by'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ def initial_unit(metadata):
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Install': {
|
'Install': {
|
||||||
'WantedBy': {'multi-user.target'},
|
'RequiredBy': {'steam.target'},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -79,12 +79,12 @@
|
||||||
'standard': {
|
'standard': {
|
||||||
'port': 27020,
|
'port': 27020,
|
||||||
},
|
},
|
||||||
'standard-2': {
|
# 'standard-2': {
|
||||||
'port': 27021,
|
# 'port': 27021,
|
||||||
'workshop': {
|
# 'workshop': {
|
||||||
#2256379828, # bhop detect
|
# #2256379828, # bhop detect
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
},
|
},
|
||||||
'admins': {
|
'admins': {
|
||||||
'STEAM_1:0:12376499', # CroneKorkN ☮️UKRAINE❤
|
'STEAM_1:0:12376499', # CroneKorkN ☮️UKRAINE❤
|
||||||
|
|
Loading…
Reference in a new issue