vq3srv, config.example.yml: more mod support, set vars from command line
This commit is contained in:
parent
10009f0337
commit
582dc79ac7
2 changed files with 17 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
user: quake3
|
||||
cmd: /opt/ioquake3/ioq3ded.x86_64 +exec autoexec.cfg
|
||||
autoexec: /home/quake3/.q3a/baseq3/autoexec.cfg
|
||||
cmd: /opt/ioquake3/ioq3ded.x86_64
|
||||
exec: /home/quake3/.q3a/baseq3/autoexec.cfg
|
||||
gamemodes:
|
||||
ffa:
|
||||
maps: [
|
||||
|
@ -19,6 +19,12 @@ gamemodes:
|
|||
vars:
|
||||
fraglimit: 15
|
||||
timelimit: 5
|
||||
cpma_duel:
|
||||
maps: [ q3dm6 ]
|
||||
vars:
|
||||
sv_game: cpma
|
||||
fraglimit: 15
|
||||
timelimit: 15
|
||||
bots:
|
||||
level: '3'
|
||||
names: [
|
||||
|
|
13
vq3srv
13
vq3srv
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
from argparse import ArgumentParser
|
||||
from os import system
|
||||
from os.path import basename
|
||||
from random import shuffle
|
||||
from sys import exit
|
||||
from yaml import safe_load
|
||||
|
@ -47,7 +48,7 @@ def gen_addbots(count, level='3', names=list()):
|
|||
|
||||
def main():
|
||||
args = parse_arguments()
|
||||
cfg_data, bvars, svars = str(), dict(), dict()
|
||||
cfg_data, cmd_vars, bvars, svars = str(), list(), dict(), dict()
|
||||
try:
|
||||
with open(args.config, 'r') as config_file:
|
||||
cfg = safe_load(config_file)
|
||||
|
@ -55,6 +56,7 @@ def main():
|
|||
with open(args.bootstrap, 'r') as bootstrap_file:
|
||||
bvars.update(safe_load(bootstrap_file))
|
||||
assert args.gamemode in cfg['gamemodes']
|
||||
exec_filename = basename(cfg['exec'])
|
||||
except FileNotFoundError as error:
|
||||
exit('Config `{}` not found!'.format(error.filename))
|
||||
except AssertionError:
|
||||
|
@ -66,18 +68,19 @@ def main():
|
|||
svars.update({'fraglimit': args.fraglimit})
|
||||
if args.timelimit:
|
||||
svars.update({'timelimit': args.timelimit})
|
||||
|
||||
for param in bvars:
|
||||
cfg_data += gen_confline(param, bvars[param], archive=True)
|
||||
for param in svars:
|
||||
cfg_data += gen_confline(param, svars[param])
|
||||
cmd_vars.append('+set {} {}'.format(param, svars[param]))
|
||||
cmd_vars.append('+exec {}'.format(exec_filename))
|
||||
cmd_opts = ' '.join(cmd_vars)
|
||||
cfg_data += gen_maplist(smaps)
|
||||
if args.bots:
|
||||
cfg_data += gen_addbots(args.bots, **cfg['bots'])
|
||||
|
||||
with open(cfg['autoexec'], 'w+') as config:
|
||||
with open(cfg['exec'], 'w+') as config:
|
||||
config.write(cfg_data)
|
||||
system('sudo -u {} {}'.format(cfg['user'], cfg['cmd']))
|
||||
system('sudo -u {} {} {}'.format(cfg['user'], cfg['cmd'], cmd_opts))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue