mirror of
https://git.zavage.net/Zavage-Software/smileyface.git
synced 2024-12-22 04:39:21 -07:00
first run implemented with Popen
This commit is contained in:
parent
edb0f70e2e
commit
7b2643cf45
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/bash
|
||||
# Edit local site config on Linux.
|
||||
|
||||
CONFIG_FILE="$HOME"/.config/smileyface-ut4/hub-config.ini
|
||||
|
||||
[ -z "$EDITOR" ] && export EDITOR=vim
|
||||
|
||||
"$EDITOR" "$CONFIG_FILE"
|
||||
|
@ -30,15 +30,13 @@ class SmileyFace(app_skellington.ApplicationContainer):
|
||||
"""
|
||||
if config_file is None:
|
||||
config_file = self._get_config_filepath(
|
||||
'app_name',
|
||||
'smileyface-ut4',
|
||||
'app_author',
|
||||
'app_config_filename'
|
||||
'hub-config.ini'
|
||||
)
|
||||
|
||||
rc = self.ctx.config.load_config_from_file(config_file)
|
||||
|
||||
|
||||
|
||||
def _cli_options(self):
|
||||
pass
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
from app_skellington import _util
|
||||
from functools import partial
|
||||
import collections
|
||||
import configobj
|
||||
import configparser
|
||||
import glob
|
||||
import hashlib
|
||||
import os
|
||||
import subprocess
|
||||
import pathlib
|
||||
import configobj
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
class UT4ServerMachine:
|
||||
def __init__(self, ctx):
|
||||
@ -127,7 +128,8 @@ ssh {remote_game_host} rm {remote_game_dir}/LinuxServer/UnrealTournament/Saved/L
|
||||
})
|
||||
self._invoke_command(cmd)
|
||||
|
||||
# self._first_run()
|
||||
if self._needs_first_run():
|
||||
self._first_run()
|
||||
self._install_config()
|
||||
self._install_paks()
|
||||
self._install_redirect_lines()
|
||||
@ -219,14 +221,26 @@ ssh {remote_game_host} chown ut4.ut4 {remote_game_dir} -R
|
||||
self.ctx.log['ut4'].info('Starting instance once to get UID.')
|
||||
self.ctx.log['ut4'].info('Unfortunately, this takes 20 seconds. Just wait.')
|
||||
|
||||
# cd "$PROJECT_DIR"/instance/LinuxServer/Engine/Binaries/Linux
|
||||
# chmod 770 UE4Server-Linux-Shipping
|
||||
# ./UE4Server-Linux-Shipping UnrealTournament UT-Entry?Game=Lobby -log &>/dev/null &
|
||||
# cd - >/dev/null
|
||||
# Make binary executable:
|
||||
bin_name = 'UE4Server-Linux-Shipping'
|
||||
project_dir = self.ctx.config['app']['project_dir']
|
||||
|
||||
cwd = '{project_dir}/instance/LinuxServer/Engine/Binaries/Linux'\
|
||||
.format(project_dir=project_dir)
|
||||
target_file = '{cwd}/{bin_name}'.format(cwd=cwd, bin_name=bin_name)
|
||||
cmd = ['chmod', '770', target_file]
|
||||
p = subprocess.run(cmd)
|
||||
|
||||
cmd = ['./'+bin_name, 'UnrealTournament', 'UT-Entry?Game=Lobby', '-log']
|
||||
p = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE)
|
||||
|
||||
try:
|
||||
stdout, stsderr = p.communicate(timeout=20)
|
||||
except subprocess.TimeoutExpired:
|
||||
p.kill()
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
self.ctx.log['ut4'].info('sleeping 20 seconds and then we\'ll kill the server we started just now.')
|
||||
# sleep 20
|
||||
# stop_server
|
||||
# # TODO(MG) get uid and export
|
||||
|
||||
def _install_config(self):
|
||||
@ -338,10 +352,10 @@ PackageChecksum="{md5sum}")'\
|
||||
self.ctx.log['ut4'].info('out filename=%s', out_filename)
|
||||
|
||||
# echo {\"rules\":[ > "$OUT_FILENAME"
|
||||
cmd = 'echo {\"rules\":[ > "{out_filename}"'
|
||||
cmd = 'echo {{\"rules\":[ > "{out_filename}"'.format(out_filename=out_filename)
|
||||
self._invoke_command(cmd)
|
||||
|
||||
cmd = 'for f in "{src_dir}"/*.json ; do ; cat "$f" >> "{out_filename}" ; done'.format(
|
||||
cmd = 'for f in "{src_dir}"/*.json ; do cat "$f" >> "{out_filename}" ; done'.format(
|
||||
**{
|
||||
'src_dir': src_dir,
|
||||
'out_filename': out_filename
|
||||
@ -362,7 +376,7 @@ PackageChecksum="{md5sum}")'\
|
||||
print(msg)
|
||||
self.ctx.log['ut4'].info('running cmd: %s', cmd)
|
||||
cwd = None # todo(mg) ?
|
||||
# os.system(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
def _md5sum_file(self, filename):
|
||||
with open(filename, mode='rb') as f:
|
||||
@ -372,6 +386,9 @@ PackageChecksum="{md5sum}")'\
|
||||
h = d.hexdigest()
|
||||
return h
|
||||
|
||||
def _needs_first_run(self):
|
||||
return False # TODO(MG): Hard-coded
|
||||
|
||||
def _validate_env_vars(self):
|
||||
variable_names = (
|
||||
'project_dir',
|
||||
|
Loading…
Reference in New Issue
Block a user