diff --git a/AutismBotIngame/README.md b/AutismBotIngame/README.md index 82517321..e1a43011 100644 --- a/AutismBotIngame/README.md +++ b/AutismBotIngame/README.md @@ -9,6 +9,12 @@ apt install mesa-vulkan-drivers libglx-mesa0:i386 mesa-vulkan-drivers:i386 libgl1-mesa-dri:i386 libxtst6:i386 libpipewire-0.3-dev libbz2-dev + apt-get install pyhoca-cli (pyhoca-cli --server localhost -N) #needed to avoid x2go client login + + apt-get install xvfb xserver-xephyr tigervnc-standalone-server x11-utils gnumeric #needed to avoid x2go client login + + pip3 install pyvirtualdisplay pillow EasyProcess #needed for virtual display, create it inside a venv + #intel specific: apt-get remove xserver-xorg-video-intel @@ -21,6 +27,10 @@ apt install libgtk2.0-0:i386 + #pyhoca x2go terminal + aptitude install pyhoca-cli + apt-get install x2goclient + #debian hostname unloze.com @@ -77,3 +87,5 @@ #check if all libs are present with cd ~/.steam/steam/ubuntu12_32 LD_LIBRARY_PATH=. ldd vgui2_s.so + + diff --git a/AutismBotIngame/python/config.json b/AutismBotIngame/python/config.json index 41019133..893a2d5a 100644 --- a/AutismBotIngame/python/config.json +++ b/AutismBotIngame/python/config.json @@ -1,11 +1,10 @@ { - "udp_port": 48470, - "chat_external_port": 48475, - "steam_port": 29074, - "discord_bot_ip": "5.104.107.39", - "server_ip_port_ze": "135.125.188.157:27015", - "server_ip_port_ze2": "135.125.188.157:27035", - "ovh_ip": "135.125.188.157" + "udp_port": *****, + "chat_external_port": ****, + "steam_port": *****, + "discord_bot_ip": "****", + "server_ip_port_ze": "****:****", + "server_ip_port_ze2": "****:****", + "ovh_ip": "*******", + "x2go_pw": "**********" } - - diff --git a/AutismBotIngame/python/ingamefollowct.py b/AutismBotIngame/python/ingamefollowct.py index c75a59d0..bddef6ca 100644 --- a/AutismBotIngame/python/ingamefollowct.py +++ b/AutismBotIngame/python/ingamefollowct.py @@ -28,6 +28,8 @@ def exit_handler(): print('reached exithandler') writeCfgInput('') #securing the looptest.cfg wont be stuck accidently with commands + kill_owned_process("pidof hl2_linux") + kill_owned_process("pidof xterm") def bot_process_movement(input_line): dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("targethuman:")] @@ -89,11 +91,12 @@ def restart_sdl_and_steam(): x2go_session_list = subprocess.getoutput(["x2golistsessions"]) print('x2golistsessions: ', x2go_session_list) if not x2go_session_list: - print('creating new session') - raise Exception('') - #TODO https://pypi.org/project/PyVirtualDisplay/ - subprocess.getoutput(["x2gostartagent 20x20 wan 2m-png-jpeg unix-kde-depth_24 dk pc105/dk 1 R xterm"]) - restart_sdl_and_steam() + print('no session. creating Display to make idle session') + subprocess.getoutput([f"screen -d -m -S pyhoca_display ./run_follow.sh"]) + while not x2go_session_list or len(x2go_session_list.split('|')[0].replace(" ", "")) == 0: + time.sleep(5) + x2go_session_list = subprocess.getoutput(["x2golistsessions"]) + print(f'finally found x2go_session_list: {x2go_session_list}') hostname = subprocess.getoutput(['hostname']) x2go_session_display = x2go_session_list.split(f'|{hostname}')[0].rsplit('|', 1)[1] @@ -101,27 +104,11 @@ def restart_sdl_and_steam(): x2go_session_id = x2go_session_list.split('|')[1].split('|')[0] x2go_session_command = 'TERMINAL xterm' xterm_cmd = f'screen -d -m -S XTERM x2goruncommand {x2go_session_display} {x2go_session_pid} {x2go_session_id} {x2go_session_command}' - print(xterm_cmd) + print(f'xterm_cmd: {xterm_cmd}') subprocess.getoutput([xterm_cmd]) print('reached .bashrc executing steam and variables') time.sleep(60) - """ - steampid = None - while steampid is None: - time.sleep(1) - print(subprocess.getoutput(["pidof steam"])) - steampids = subprocess.getoutput(["pidof steam"]) - found_steam = False - while not found_steam: - for spid in steampids.split(' '): - owner = subprocess.getoutput([f"ps -o user={spids}"]) - if whoami == owner: - print('steam finished loading!') - found_steam = True - time.sleep(10) - steampids = subprocess.getoutput(["pidof steam"]) - """ - #we sleep here to wait for .bashrc to launch steam. It takes some minutes + #we sleep here to wait for .bashrc to launch steam. It takes some time def launch_css_process(): print('preparing to launch game....') @@ -247,20 +234,14 @@ if __name__ == '__main__': #cd /home/gameservers/ze_runner_files #python3 ingamefollowct.py -#before steam login: export SDL_VIDEO_X11_VISUALID=0x074 -#to find correct SDL_VIDEO_X11_VISUALID use glxinfo in X2GO - """ .bashrc requires: if [[ $DISPLAY ]]; then echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID export SDL_VIDEO_X11_VISUALID=0x205 echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID - steam + steam -no-browser fi """ - #apt-get install tmux -> tmux -> cd /home/autismbot1/ze_runner -> python3 ingamefollowct.py - -#https://pypi.org/project/PyVirtualDisplay/ - +#screen -d -m -S ze_runner python3 ingamefollowct.py diff --git a/AutismBotIngame/python/pyhoca_display.py b/AutismBotIngame/python/pyhoca_display.py new file mode 100644 index 00000000..647cff36 --- /dev/null +++ b/AutismBotIngame/python/pyhoca_display.py @@ -0,0 +1,18 @@ +from pyvirtualdisplay import Display +import json +import subprocess + +whoami = subprocess.getoutput(["whoami"]) +with open(f'/home/{whoami}/ze_runner/config.json') as jsonfile: + data_ports = json.load(jsonfile) + +#enter screen to enter password +def main(): + with Display() as disp: + d = subprocess.getoutput(["echo $DISPLAY"]) + print(d) + subprocess.getoutput([f"pyhoca-cli --server localhost -N --password {data_ports['x2go_pw']}"]) + + +if __name__ == '__main__': + main() diff --git a/AutismBotIngame/python/run_follow.sh b/AutismBotIngame/python/run_follow.sh new file mode 100644 index 00000000..eed45df3 --- /dev/null +++ b/AutismBotIngame/python/run_follow.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cd "$(dirname "$0")" +source venv/bin/activate +python3 pyhoca_display.py