diff --git a/AutismBotIngame/README.md b/AutismBotIngame/README.md index 8549038f..a5cadce0 100644 --- a/AutismBotIngame/README.md +++ b/AutismBotIngame/README.md @@ -9,12 +9,7 @@ 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 - + apt-get install xvfb xserver-xephyr tigervnc-standalone-server x11-utils gnumeric #NOTICE: steam might not be able to launch in case of the tmpfs /dev/shm filesystem being full. it seems safe to just delete u1001-Shm_* files and u1002-Shm_ files. It should be fine because the files exists as long as at least one process has them open. So until steam is killed i assume. You dont need to be root for killing them, the user running the bot has permissions to rm the files @@ -37,10 +32,6 @@ apt install libgtk2.0-0:i386 - x2go or nomachine or VNC client/server setup
- steam account with css purchased - # launch commands - /home/gameservers/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/autoexec.cfg:
alias loop "exec looptest.cfg; wait 5; loop;"; wait 5; loop;
(textmode is no video output)
@@ -49,35 +40,20 @@
With the virtual desktop related to the VNC/x2go/nomachine client you can log into steam using the normal GUI ->
once logged in steam can run actively for months without requiring restarts - ## bashrc for x2go users - in the users thats running a x2go session edit the .bashrc file and add the follwing (remember SDL_VIDEO_X11_VISUALID deppends on glxinfo from xterm terminal): + ## bashrc for users + in the users thats running a session edit the .bashrc file and add the follwing (remember SDL_VIDEO_X11_VISUALID deppends on glxinfo from xterm terminal): 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 - /home/$USER/.steam/debian-installation/steam.sh -applaunch 240 -textmode -novid -nosound -noipx -nojoy -noshaderapi + dbus-run-session /usr/games/steam -applaunch 240 -novid -noipx -nojoy -noshaderapi fi - #-no-browser +open steam://open/minigameslist reduces cpu being used by steam - - ##steam settings -> library -> low bandwith mode and low performance mode - - #X2GO_NXAGENT_DEFAULT_OPTIONS="-options nx/nx,sleep=0" /etc/x2go/x2goagent.options - - #keeps session as R instead of S which is needed for interaction with graphical components such as steam and CS:S - ovh: 0x205, 0x209 #if running steam native libraries instead of runtime libraries one might require following apt install for making libpipewire work - #specifically on debian steam - apt install pipewire:i386 - apt-get install libbz2-1.0:i386 - - #further steam native libraries specifically for debian - apt-get install libxtst6:i386 libxrandr2:i386 libglib2.0-0:i386 libgtk2.0-0:i386 libpulse0:i386 libgdk-pixbuf2.0-0:i386 libcurl4-openssl-dev:i386 libopenal1:i386 libusb-1.0-0:i386 libdbus-glib-1-2:i386 - apt-get install libsm6:i386 #check if all libs are present with cd ~/.steam/steam/ubuntu12_32 @@ -100,3 +76,6 @@ usermod -a -G autismbots autismbot4 chown root:autismbots -R /tmp/dumps chmod 755 -R /tmp/dumps + +remember to remove source_engine*.lock files from /tmp if they tend to clamp things up. +now using tigervnc instead of x2go. diff --git a/AutismBotIngame/python/config.json b/AutismBotIngame/python/config.json index 893a2d5a..7a94889d 100644 --- a/AutismBotIngame/python/config.json +++ b/AutismBotIngame/python/config.json @@ -5,6 +5,5 @@ "discord_bot_ip": "****", "server_ip_port_ze": "****:****", "server_ip_port_ze2": "****:****", - "ovh_ip": "*******", - "x2go_pw": "**********" + "ovh_ip": "*******" } diff --git a/AutismBotIngame/python/ingamefollowct.py b/AutismBotIngame/python/ingamefollowct.py index e08e7176..28055b09 100644 --- a/AutismBotIngame/python/ingamefollowct.py +++ b/AutismBotIngame/python/ingamefollowct.py @@ -7,6 +7,7 @@ from threading import Timer import string import random import signal +import traceback import socket import codecs import json @@ -26,19 +27,21 @@ chatmsg = "" def writeCfgInput(Input_user): with open(looptestPath, 'w') as f: f.write(Input_user) + #print("wrote to file: ", Input_user) + #time.sleep(10.0) time.sleep(0.1) - open(looptestPath, 'w').close() 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 cstrike_linux64") kill_owned_process("pidof xterm") + #deleting POSIX shared memory objects, as long as one process has them open they exist. THis is to prevent /dev/shm from being full #due to steam child processes. #even with steam turned offline might there be chromium web browsers left over from steam who still hold processes open. - #only kind of potential issues from this is steam cloud being out of sync, which is really fucking irrelevant. + #only kind of potential issues from this is steam cloud being out of sync, which is really fucking irrelevant. subprocess.getoutput([f"pkill -9 -u {whoami}"]) def bot_process_movement(input_line): @@ -54,7 +57,7 @@ def bot_process_movement(input_line): #request by bane that bots should simply not infect people shrug strInput = "-attack; wait 2; -use; wait 5; -attack; wait 5; cl_minmodels 1; wait 2; +use; wait 5; " if targeteam == 3: - strInput = "-attack; wait 2; -use; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; wait 5; " + strInput = "-attack; wait 2; -use; wait 5; -attack; wait 5; cl_minmodels 1; wait 2; +use; wait 5; " #python has no switches and such if state in [5, 7]: strInput += "-forward; wait 2; use weapon_knife; wait 5;" @@ -107,29 +110,17 @@ def kill_owned_process(pidof): def restart_sdl_and_steam(): #subprocess.getoutput(["screen -XS XTERM quit"]) - kill_owned_process("pidof hl2_linux") + kill_owned_process("pidof cstrike_linux64") kill_owned_process("pidof xterm") - - x2go_session_list = subprocess.getoutput(["x2golistsessions"]) - print('x2golistsessions: ', x2go_session_list) - if not x2go_session_list: - 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] - x2go_session_pid = x2go_session_list.split('|')[0] - 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(f'xterm_cmd: {xterm_cmd}') - subprocess.getoutput([xterm_cmd]) + subprocess.getoutput([f'vncserver -kill']) #only displays vncservers for the specific user. + time.sleep(5) + + cmd = f'vncserver -localhost no -geometry 1x1 -depth 24' + print(f'cmd: {cmd}') + subprocess.getoutput([cmd]) print('reached .bashrc executing steam and variables') - time.sleep(40) + time.sleep(10) #we sleep here to wait for .bashrc to launch steam. It takes some time def bot_connect(data): @@ -142,9 +133,19 @@ def bot_connect(data): writeCfgInput(str1) time.sleep(1) writeCfgInput("") - t = Timer(150, attempt_bot_connect) + t = Timer(30, attempt_bot_connect) t.start() +def cpulimit_pid_of_game(): + pid = return_user_owned_pid("pidof cstrike_linux64") + cmd = f"cpulimit --pid={pid} --limit=5 --background" + #print('the command is: ', cmd) + subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE).communicate()[0] + +def delete_tmp_leftovers(): + #just delete the tmp source_engine .lock file here so multiple instances can run at same time. + subprocess.Popen(["rm -f /tmp/source_engine*.lock"], shell=True, stdout=subprocess.PIPE).communicate()[0] + def attempt_bot_connect(): global connection_issue_counter global call_bot_connect @@ -183,6 +184,7 @@ if __name__ == '__main__': if maps_folder_size > 40.0: for f in glob.glob(f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps/*"): subprocess.Popen(["rm", f], stdout=subprocess.PIPE).communicate()[0] + restart_sdl_and_steam() is_bot_connected_to_ze2 = False @@ -193,9 +195,17 @@ if __name__ == '__main__': sock.settimeout(5.0) messager_name = "" + t = Timer(10, delete_tmp_leftovers) + t.start() + + #limit the cpu allowed to be used by the game instance. + t = Timer(11, cpulimit_pid_of_game) + t.start() + try: while True: try: + #print("socket waiting for recvfrom") data, addr = sock.recvfrom(buffer_size) except socket.timeout: continue @@ -232,9 +242,9 @@ if __name__ == '__main__': is_bot_connected_to_ze2 = True elif "connect to ze" == data or ("connect to ze2" == data and not is_bot_connected_to_ze2): if connection_issue_counter == 5: - kill_owned_process("pidof hl2_linux") - print('exiting') + kill_owned_process("pidof cstrike_linux64") sock.close() + print('exiting') sys.exit(1) else: if call_bot_connect: @@ -243,8 +253,8 @@ if __name__ == '__main__': print("connection_issue_counter: ", connection_issue_counter) bot_connect(data) elif "clientmessage:" in data: - messager_name = data.split("clientmessage:", 1)[1].split(" put your magic code here.")[0] - databyte_send_message = messager_name + data.split("put your magic code here.")[1] + messager_name = data.split("clientmessage:", 1)[1].split(" secret_code_here")[0] + databyte_send_message = messager_name + data.split("secret_code_here")[1] sock.sendto(databyte_send_message.encode(), (data_ports["discord_bot_ip"], external_port_messages)) #print('databyte_send_message: ', databyte_send_message) elif data.startswith("dist_target:"): diff --git a/AutismBotIngame/python/pyhoca_display.py b/AutismBotIngame/python/pyhoca_display.py deleted file mode 100644 index 7e789248..00000000 --- a/AutismBotIngame/python/pyhoca_display.py +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index eed45df3..00000000 --- a/AutismBotIngame/python/run_follow.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -cd "$(dirname "$0")" -source venv/bin/activate -python3 pyhoca_display.py