wip
This commit is contained in:
parent
7302811418
commit
6fc6f0b6f4
10 changed files with 178 additions and 9 deletions
1
bundles/l4d2/README.md
Normal file
1
bundles/l4d2/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
https://developer.valvesoftware.com/wiki/List_of_L4D2_Cvars
|
21
bundles/l4d2/items.py
Normal file
21
bundles/l4d2/items.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
directories = {
|
||||
'/etc/left4dead2': {
|
||||
'owner': 'steam',
|
||||
'purge': True,
|
||||
}
|
||||
}
|
||||
|
||||
for name, config in node.metadata.get('left4dead2').items():
|
||||
config.pop('port')
|
||||
config['hostname'] = name
|
||||
|
||||
files[f'/etc/left4dead2/{name}.cfg'] = {
|
||||
'content': '\n'.join(
|
||||
f'{key} "{value}"' for key, value in config.items()
|
||||
),
|
||||
'owner': 'steam',
|
||||
'triggers': [
|
||||
f'svc_systemd:left4dead2-server-{name}:restart',
|
||||
],
|
||||
}
|
||||
svc_systemd[f'left4dead2-server-{name}'] = {}
|
|
@ -1,7 +1,41 @@
|
|||
@metadata_reactor.provides()
|
||||
defaults = {
|
||||
'steam': {
|
||||
'games': {
|
||||
'left4dead2': '222860',
|
||||
},
|
||||
},
|
||||
'servers': {},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor.provides(
|
||||
'systemd/units',
|
||||
)
|
||||
def steam(metadata):
|
||||
units = {}
|
||||
services = {}
|
||||
|
||||
for name, config in metadata.get('left4dead2').items():
|
||||
units[f'left4dead2-server-{name}.service'] = {
|
||||
'Unit': {
|
||||
'Description': 'steam: install and update games',
|
||||
'After': 'network.target',
|
||||
'Requires': 'steam-update.service',
|
||||
},
|
||||
'Service': {
|
||||
'User': 'steam',
|
||||
'Group': 'steam',
|
||||
'WorkingDirectory': '/opt/left4dead2',
|
||||
'ExecStart': f'/opt/left4dead2/srcds_run -port {config["port"]} -secure +exec /etc/left4dead2/{name}.cfg',
|
||||
'Restart': 'on-failure',
|
||||
},
|
||||
'Install': {
|
||||
'WantedBy': ['multi-user.target'],
|
||||
},
|
||||
}
|
||||
|
||||
return {
|
||||
'steam': {
|
||||
'222860': 'l4d2',
|
||||
'systemd': {
|
||||
'units': units,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
GNU nano 4.8 /etc/systemd/system/l4d2-update.service
|
||||
[Unit]
|
||||
Description=l4d2 update
|
||||
After=network.target
|
||||
|
|
|
@ -1,4 +1,41 @@
|
|||
for id, name in node.metadata.get('steam'):
|
||||
pass
|
||||
users = {
|
||||
'steam': {
|
||||
'home': '/opt/steam',
|
||||
},
|
||||
}
|
||||
|
||||
directories = {
|
||||
'/opt/steam': {
|
||||
'owner': 'steam',
|
||||
'group': 'steam',
|
||||
},
|
||||
}
|
||||
|
||||
files = {
|
||||
'/opt/steam/steamcmd_linux.tar.gz': {
|
||||
'content_type': 'download',
|
||||
'source': 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz',
|
||||
'owner': 'steam',
|
||||
'group': 'steam',
|
||||
},
|
||||
}
|
||||
|
||||
actions = {
|
||||
'extract_steamcmd': {
|
||||
'command': 'tar xfvz /opt/steam/steamcmd_linux.tar.gz --directory /opt/steam',
|
||||
'unless': 'test -f /opt/steam/steamcmd.sh',
|
||||
'needs': [
|
||||
'file:/opt/steam/steamcmd_linux.tar.gz',
|
||||
],
|
||||
},
|
||||
'chown_steamcmd': {
|
||||
'command': 'chown -R steam:steam /opt/steam',
|
||||
'triggered': True,
|
||||
'triggered_by': [
|
||||
'action:extract_steamcmd',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
# sudo -Hiu steam bash -c '~/steam/steamcmd.sh +login anonymous +force_install_dir ./l4d2/ +app_update 222860 validate +quit'
|
||||
# https://github.com/SegoCode/swd/releases/download/1.1/swd-linux-amd64
|
||||
|
|
42
bundles/steam/metadata.py
Normal file
42
bundles/steam/metadata.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
defaults = {
|
||||
'apt': {
|
||||
'packages': {
|
||||
'lib32gcc-s1': {},
|
||||
},
|
||||
},
|
||||
'steam': {
|
||||
'games': {},
|
||||
}
|
||||
}
|
||||
|
||||
@metadata_reactor.provides(
|
||||
'systemd/units',
|
||||
)
|
||||
def initial_unit(metadata):
|
||||
install_games = ' '.join(
|
||||
f'+force_install_dir /opt/{name} +app_update {id}'
|
||||
for name, id in metadata.get('steam/games').items()
|
||||
)
|
||||
|
||||
return {
|
||||
'systemd': {
|
||||
'units': {
|
||||
'steam-update.service': {
|
||||
'Unit': {
|
||||
'Description': 'steam: install and update games',
|
||||
'After': 'network.target',
|
||||
},
|
||||
'Service': {
|
||||
'Type': 'oneshot',
|
||||
'User': 'steam',
|
||||
'Group': 'steam',
|
||||
'WorkingDirectory': '/opt/steam',
|
||||
'ExecStart': f'/opt/steam/steamcmd.sh +login anonymous {install_games} validate +quit',
|
||||
},
|
||||
'Install': {
|
||||
'WantedBy': 'multi-user.target',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
|
@ -48,7 +48,7 @@ def services(metadata):
|
|||
extension = name.split('.')[-1]
|
||||
|
||||
if extension not in ['timer', 'service']:
|
||||
raise Exception(f'unknown extension {extension}')
|
||||
raise Exception(f'unknown extension: {extension}')
|
||||
|
||||
return {
|
||||
'systemd': {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
'metadata': {
|
||||
'apt': {
|
||||
'sources': {
|
||||
'deb http://deb.debian.org/debian {release} main non-free contrib',
|
||||
'deb http://deb.debian.org/debian {release} main contrib non-free',
|
||||
'deb http://deb.debian.org/debian {release}-updates main contrib non-free',
|
||||
'deb http://deb.debian.org/debian {release}-backports main contrib non-free',
|
||||
},
|
||||
|
|
35
nodes/htz.games-2.py
Normal file
35
nodes/htz.games-2.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
'hostname': '23.88.121.141',
|
||||
'groups': [
|
||||
'backup',
|
||||
'debian-11',
|
||||
'hetzner-cloud',
|
||||
],
|
||||
'bundles': [
|
||||
'steam',
|
||||
'l4d2',
|
||||
# 'java',
|
||||
# 'minecraft',
|
||||
],
|
||||
'metadata': {
|
||||
'id': '3915f236-dd0a-4c6c-8fb3-1584c81038c6',
|
||||
'left4dead2': {
|
||||
'realism-expert': {
|
||||
'port': 27001,
|
||||
}
|
||||
},
|
||||
'network': {
|
||||
'internal': {
|
||||
'interface': 'ens10',
|
||||
'ipv4': '10.0.10.4/32',
|
||||
},
|
||||
'external': {
|
||||
'interface': 'eth0',
|
||||
'ipv4': '23.88.121.141/32',
|
||||
'ipv6': '2a01:4f8:c17:e0b4::2/64',
|
||||
'gateway4': '172.31.1.1',
|
||||
'gateway6': 'fe80::1',
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
# 'steam',
|
||||
# 'l4d2',
|
||||
'java',
|
||||
'minecraft',
|
||||
# 'minecraft',
|
||||
],
|
||||
'metadata': {
|
||||
# TEMP
|
||||
|
|
Loading…
Reference in a new issue