updated service, python script and README for flatpak steam and solving shared memory being full

This commit is contained in:
jenz 2023-02-13 21:38:06 +01:00
parent a55515b0b2
commit 6916ca5d1e
3 changed files with 27 additions and 45 deletions

View File

@ -15,6 +15,12 @@
pip3 install pyvirtualdisplay pillow EasyProcess #needed for virtual display, create it inside a venv
2023, instead of steam using flatpak steam
https://flatpak.org/setup/Debian
https://flathub.org/apps/details/com.valvesoftware.Steam
#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
#intel specific:
apt-get remove xserver-xorg-video-intel
@ -42,20 +48,20 @@
## 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):
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
#use this one to launch steam minimized once
#flatpak run com.valvesoftware.Steam -no-browser +open steam://open/minigameslist
/home/$USER/.var/app/com.valvesoftware.Steam/data/Steam/steam.sh -applaunch 240 -textmode -novid -nosound -noipx -nojoy -noshaderapi
fi
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 -no-browser +open steam://open/minigameslist
fi
#-no-browser +open steam://open/minigameslist reduces cpu being used by steam
##steam settings -> library -> low bandwith mode and low performance mode
#2023, try steam beta mode in steam settings to prevent Bus error (core dumped) "$STEAMROOT/$STEAMEXEPATH" "$@"
#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
@ -74,5 +80,3 @@
#check if all libs are present with
cd ~/.steam/steam/ubuntu12_32
LD_LIBRARY_PATH=. ldd vgui2_s.so

View File

@ -6,6 +6,7 @@ After=network.target
User=autismbot%i
Group=autismbot%i
WorkingDirectory=/home/autismbot%i/ze_runner
Environment=PYTHONUNBUFFERED=1
Environment=PATH=/home/autismbot%i/ze_runner/venv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
ExecStart=/home/autismbot%i/ze_runner/ingamefollowct.py
Restart=always

View File

@ -16,7 +16,7 @@ import time
whoami = subprocess.getoutput(["whoami"])
with open(f'/home/{whoami}/ze_runner/config.json') as jsonfile:
data_ports = json.load(jsonfile)
looptestPath = f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg"
looptestPath = f"/home/{whoami}/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg"
chatmsg = ""
def writeCfgInput(Input_user):
@ -120,18 +120,9 @@ def restart_sdl_and_steam():
print(f'xterm_cmd: {xterm_cmd}')
subprocess.getoutput([xterm_cmd])
print('reached .bashrc executing steam and variables')
time.sleep(60)
time.sleep(90)
#we sleep here to wait for .bashrc to launch steam. It takes some time
def launch_css_process():
print('preparing to launch game....')
#deleting maps
subprocess.getoutput([f"rm '/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps/'*"])
#launching game
subprocess.getoutput([f"/home/{whoami}/.steam/debian-installation/steam.sh -applaunch 240 -textmode -novid -nosound -noipx -nojoy -noshaderapi -port {data_ports['steam_port']}"])
print('finished starting game')
def bot_connect(data):
#use whatever ip you want here to connect with
str1 = ""
@ -150,13 +141,17 @@ if __name__ == '__main__':
external_port_messages = data_ports['chat_external_port']
buffer_size = 4096 #potentially not large enough?
connection_issue_counter = 0;
pid = return_user_owned_pid("pidof hl2_linux")
if not pid:
restart_sdl_and_steam()
else:
kill_owned_process("pidof hl2_linux")
#deleting maps
subprocess.getoutput([f"rm '/home/{whoami}/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common/Counter-Strike Source/cstrike/download/maps/'*"])
#deleting POSIX shared memory objects, as long as one process has them open they exist. so probably until steam gets turned off. THis is to prevent /dev/shm from being full
subprocess.getoutput([f"rm /dev/shm/u1001-Shm_*"])
subprocess.getoutput([f"rm /dev/shm/u1002-Shm_*"])
restart_sdl_and_steam()
is_bot_connected_to_ze2 = False
launch_css_process()
print('preparing to launch game....')
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(("", local_port))
@ -227,21 +222,3 @@ if __name__ == '__main__':
writeCfgInput(strInput)
finally:
sock.close()
#/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;
#create looptest.cfg in /cfg/ folder
#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
"""
.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 -no-browser
fi
"""
#screen -d -m -S ze_runner python3 ingamefollowct.py