kaimallea / csgo

A containerized dedicated server for Counter-Strike: Global Offensive
The Unlicense
242 stars 58 forks source link

Still empty config files after #51 was merged #53

Closed minusbrain closed 3 years ago

minusbrain commented 3 years ago

Hi,

I just started using this container to run a local CS:Go Server. But I am facing issues with autoexec.cfg and server.cfg being empty after more than one start of my container. I narrowed the problem down to the use of 'sed -i -n' introduced in #45 . There seems to be an issue / problem with the usage of sed -i -n that I do not fully understand but is quite easy to reproduce on my machine.

minusbrain@homer:~/dev/csgo(master)$ cat ~/.data/csgo/csgo/cfg/autoexec.cfg
log on
hostname "MyServer"
rcon_password "changeme"
sv_password "changeme"
sv_cheats 0
exec banned_user.cfg
exec banned_ip.cfg
minusbrain@homer:~/dev/csgo(master)$ sed -i -n 's/^hostname.*/hostname "MyNewServer"/' ~/.data/csgo/csgo/cfg/autoexec.cfg
minusbrain@homer:~/dev/csgo(master)$ cat ~/.data/csgo/csgo/cfg/autoexec.cfg
minusbrain@homer:~/dev/csgo(master)$

and if I only use 'sed -i' it works fine

minusbrain@homer:~/dev/csgo(master)$ cat ~/.data/csgo/csgo/cfg/autoexec.cfg
log on
hostname "MyServer"
rcon_password "changeme"
sv_password "changeme"
sv_cheats 0
exec banned_user.cfg
exec banned_ip.cfg
minusbrain@homer:~/dev/csgo(master)$ sed -i 's/^hostname.*/hostname "MyNewServer"/' ~/.data/csgo/csgo/cfg/autoexec.cfg
minusbrain@homer:~/dev/csgo(master)$ cat ~/.data/csgo/csgo/cfg/autoexec.cfg
log on
hostname "MyNewServer"
rcon_password "changeme"
sv_password "changeme"
sv_cheats 0
exec banned_user.cfg
exec banned_ip.cfg
minusbrain@homer:~/dev/csgo(master)$

The only reference I found on this online is a comment on a stackoverflow question here: https://stackoverflow.com/questions/5886564/what-actually-the-meaning-of-n-in-sed#comment87033580_5886611

minusbrain commented 3 years ago

I provided a potential fix, but I am not sure what the original intention of passing "-n" to sed was.

kaimallea commented 3 years ago

@minusbrain thank you! I'm not able to test atm. @Soren90 , can you confirm? 🙏🏾

fipso commented 3 years ago

Hello this happend to me after restarting the container after i changed one line in my autoexec:

image

minusbrain commented 3 years ago

@fipso Yes, I just saw that too. The problem existed even before my change, but I think it was masked by the fact that the config file update logic emptied the whole file before. I created a new pull request to fix also this issue: #55

kaimallea commented 3 years ago

Thanks for the PR. I just merged it. Sorry I'm not able to directly test the PRs myself atm, I've been trusting that they just work after reviewing. 😅

I'll have a think about better ways to automate testing this to catch these sooner in the PRs .