removed unused files related to x2go, switched from x2go to tigervnc (GLX 1.3 issue?), had to give up on headless textmode, instead now limiting cpu usage simply since it cant be headless any longer.

This commit is contained in:
jenz 2025-04-11 01:27:38 +02:00
parent 3de3e69510
commit a2eb7ade88
5 changed files with 47 additions and 80 deletions

View File

@ -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 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
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
#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 #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 apt install libgtk2.0-0:i386
x2go or nomachine or VNC client/server setup <br/>
steam account with css purchased
# launch commands
/home/gameservers/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/autoexec.cfg: <br/> /home/gameservers/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/autoexec.cfg: <br/>
alias loop "exec looptest.cfg; wait 5; loop;"; wait 5; loop; <br/> alias loop "exec looptest.cfg; wait 5; loop;"; wait 5; loop; <br/>
(textmode is no video output) <br/> (textmode is no video output) <br/>
@ -49,35 +40,20 @@
<br/> With the virtual desktop related to the VNC/x2go/nomachine client you can log into steam using the normal GUI -> <br/> <br/> With the virtual desktop related to the VNC/x2go/nomachine client you can log into steam using the normal GUI -> <br/>
once logged in steam can run actively for months without requiring restarts once logged in steam can run actively for months without requiring restarts
## bashrc for x2go users ## bashrc for 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): 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 if [[ $DISPLAY ]]; then
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
export SDL_VIDEO_X11_VISUALID=0x205 export SDL_VIDEO_X11_VISUALID=0x205
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID 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 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 ovh: 0x205, 0x209
#if running steam native libraries instead of runtime libraries one might require following apt install for making libpipewire work #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 #check if all libs are present with
cd ~/.steam/steam/ubuntu12_32 cd ~/.steam/steam/ubuntu12_32
@ -100,3 +76,6 @@ usermod -a -G autismbots autismbot4
chown root:autismbots -R /tmp/dumps chown root:autismbots -R /tmp/dumps
chmod 755 -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.

View File

@ -5,6 +5,5 @@
"discord_bot_ip": "****", "discord_bot_ip": "****",
"server_ip_port_ze": "****:****", "server_ip_port_ze": "****:****",
"server_ip_port_ze2": "****:****", "server_ip_port_ze2": "****:****",
"ovh_ip": "*******", "ovh_ip": "*******"
"x2go_pw": "**********"
} }

View File

@ -7,6 +7,7 @@ from threading import Timer
import string import string
import random import random
import signal import signal
import traceback
import socket import socket
import codecs import codecs
import json import json
@ -26,19 +27,21 @@ chatmsg = ""
def writeCfgInput(Input_user): def writeCfgInput(Input_user):
with open(looptestPath, 'w') as f: with open(looptestPath, 'w') as f:
f.write(Input_user) f.write(Input_user)
#print("wrote to file: ", Input_user)
#time.sleep(10.0)
time.sleep(0.1) time.sleep(0.1)
open(looptestPath, 'w').close()
def exit_handler(): def exit_handler():
print('reached exithandler') print('reached exithandler')
writeCfgInput('') writeCfgInput('')
#securing the looptest.cfg wont be stuck accidently with commands #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") 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 #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. #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. #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}"]) subprocess.getoutput([f"pkill -9 -u {whoami}"])
def bot_process_movement(input_line): 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 #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; " strInput = "-attack; wait 2; -use; wait 5; -attack; wait 5; cl_minmodels 1; wait 2; +use; wait 5; "
if targeteam == 3: 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 #python has no switches and such
if state in [5, 7]: if state in [5, 7]:
strInput += "-forward; wait 2; use weapon_knife; wait 5;" strInput += "-forward; wait 2; use weapon_knife; wait 5;"
@ -107,29 +110,17 @@ def kill_owned_process(pidof):
def restart_sdl_and_steam(): def restart_sdl_and_steam():
#subprocess.getoutput(["screen -XS XTERM quit"]) #subprocess.getoutput(["screen -XS XTERM quit"])
kill_owned_process("pidof hl2_linux") kill_owned_process("pidof cstrike_linux64")
kill_owned_process("pidof xterm") 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']) subprocess.getoutput([f'vncserver -kill']) #only displays vncservers for the specific user.
x2go_session_display = x2go_session_list.split(f'|{hostname}')[0].rsplit('|', 1)[1] time.sleep(5)
x2go_session_pid = x2go_session_list.split('|')[0]
x2go_session_id = x2go_session_list.split('|')[1].split('|')[0] cmd = f'vncserver -localhost no -geometry 1x1 -depth 24'
x2go_session_command = 'TERMINAL xterm' print(f'cmd: {cmd}')
xterm_cmd = f'screen -d -m -S XTERM x2goruncommand {x2go_session_display} {x2go_session_pid} {x2go_session_id} {x2go_session_command}' subprocess.getoutput([cmd])
print(f'xterm_cmd: {xterm_cmd}')
subprocess.getoutput([xterm_cmd])
print('reached .bashrc executing steam and variables') 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 #we sleep here to wait for .bashrc to launch steam. It takes some time
def bot_connect(data): def bot_connect(data):
@ -142,9 +133,19 @@ def bot_connect(data):
writeCfgInput(str1) writeCfgInput(str1)
time.sleep(1) time.sleep(1)
writeCfgInput("") writeCfgInput("")
t = Timer(150, attempt_bot_connect) t = Timer(30, attempt_bot_connect)
t.start() 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(): def attempt_bot_connect():
global connection_issue_counter global connection_issue_counter
global call_bot_connect global call_bot_connect
@ -183,6 +184,7 @@ if __name__ == '__main__':
if maps_folder_size > 40.0: 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/*"): 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] subprocess.Popen(["rm", f], stdout=subprocess.PIPE).communicate()[0]
restart_sdl_and_steam() restart_sdl_and_steam()
is_bot_connected_to_ze2 = False is_bot_connected_to_ze2 = False
@ -193,9 +195,17 @@ if __name__ == '__main__':
sock.settimeout(5.0) sock.settimeout(5.0)
messager_name = "" 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: try:
while True: while True:
try: try:
#print("socket waiting for recvfrom")
data, addr = sock.recvfrom(buffer_size) data, addr = sock.recvfrom(buffer_size)
except socket.timeout: except socket.timeout:
continue continue
@ -232,9 +242,9 @@ if __name__ == '__main__':
is_bot_connected_to_ze2 = True is_bot_connected_to_ze2 = True
elif "connect to ze" == data or ("connect to ze2" == data and not is_bot_connected_to_ze2): elif "connect to ze" == data or ("connect to ze2" == data and not is_bot_connected_to_ze2):
if connection_issue_counter == 5: if connection_issue_counter == 5:
kill_owned_process("pidof hl2_linux") kill_owned_process("pidof cstrike_linux64")
print('exiting')
sock.close() sock.close()
print('exiting')
sys.exit(1) sys.exit(1)
else: else:
if call_bot_connect: if call_bot_connect:
@ -243,8 +253,8 @@ if __name__ == '__main__':
print("connection_issue_counter: ", connection_issue_counter) print("connection_issue_counter: ", connection_issue_counter)
bot_connect(data) bot_connect(data)
elif "clientmessage:" in data: elif "clientmessage:" in data:
messager_name = data.split("clientmessage:", 1)[1].split(" put your magic code here.")[0] messager_name = data.split("clientmessage:", 1)[1].split(" secret_code_here")[0]
databyte_send_message = messager_name + data.split("put your magic code here.")[1] 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)) sock.sendto(databyte_send_message.encode(), (data_ports["discord_bot_ip"], external_port_messages))
#print('databyte_send_message: ', databyte_send_message) #print('databyte_send_message: ', databyte_send_message)
elif data.startswith("dist_target:"): elif data.startswith("dist_target:"):

View File

@ -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()

View File

@ -1,4 +0,0 @@
#!/bin/bash
cd "$(dirname "$0")"
source venv/bin/activate
python3 pyhoca_display.py