Closed TheShihan closed 2 months ago
Hi,
I'm not familiar with Docker, but don't these lines basically mean you are creating /home/quake2-server/.q2pro/baseq2
path under root account (or whatever account that script runs from) and then launch Q2PRO under quake2-server
account? That would explain permission denied error. Normally you shouldn't create .q2pro
directory yourself, Q2PRO will create it automatically when writing files.
The reason it tries to open console.log
first is because you are enabling logfile
cvar before setting logfile_name
.
You should also use +set game openffa
on the command line rather than +game openffa
since the latter would start the server with game variable unset first and then switch to openffa
, causing unneeded filesystem restart.
P.S. Took me awhile to comprehend your log is upside down, what an odd convention.
Is it strange that all paths in log are absolute, and only one path is not: "logs/console.log"?
Btw, I'll advertise my 2 docs about hosting Q2PRO server - it's autotranslated to English PDF's:
Would it help to define your volumes in your docker run ...
or a docker-compose.yml file, rather than within the Dockerfile? That way, multiple containers can share the same FS. Alternatively, simply referencing the local filesystem of the machine you're on rather than Docker volumes have the benefit of not needing to exec into the container to clean up old logs.
https://github.com/TheShihan/docker-quake2server/blob/main/Dockerfile#L38-L42
clean up old logs
Yeap, it would be a problem inside container. There must be logrotating policy. Or simply output all logs to container's STDOUT instead file.
You're welcome to review the main repository for AQ2 (AQtion), we use Docker heavily for distributing official server images https://github.com/aq2world/server/
The main difference here is that we use pre-compiled binaries rather than building within the container
Thanks for the feedback. I'm now setting the logfile to 2 after setting the name. I'm also now using "set game openffa" instead of "game openffa" (by the way: in the pdfs about the server setup, they use also the option without "set").
Now the message is: ] [1C [K[31mCouldn't open logs/console_openffa.log: Permission denied
But I still have to check out if the issue is because the folder is created with the root user. I guess the user homedir should be setup correctly, but I am not sure what happens when another users creates files in them. Maybe they are indeed owned by the other user.
OK, i changed the order of some commands related to directory creation and chown-ing. I also connected into a locally running container with a shell and everything looks good I believe:
quake2-server@cd23d8c1225e:/home$ ls -al
total 20
drwxr-xr-x 1 root root 4096 Aug 31 12:36 .
drwxr-xr-x 1 root root 4096 Aug 31 12:47 ..
drwxr-xr-x 1 quake2-server quake2-server 4096 Aug 31 12:36 quake2-server
quake2-server@cd23d8c1225e:/home$ cd quake2-server/
quake2-server@cd23d8c1225e:~$ ls -al
total 36
drwxr-xr-x 1 quake2-server quake2-server 4096 Aug 31 12:36 .
drwxr-xr-x 1 root root 4096 Aug 31 12:36 ..
-rw-r--r-- 1 quake2-server quake2-server 220 Mar 29 19:40 .bash_logout
-rw-r--r-- 1 quake2-server quake2-server 3526 Mar 29 19:40 .bashrc
-rw-r--r-- 1 quake2-server quake2-server 807 Mar 29 19:40 .profile
drwxr-xr-x 3 quake2-server quake2-server 4096 Aug 31 12:47 .q2pro
-rwxr-xr-x 1 quake2-server quake2-server 715 Aug 31 12:32 start-quake2-server.sh
quake2-server@cd23d8c1225e:~$ cd .q2pro/
quake2-server@cd23d8c1225e:~/.q2pro$ ls -ak
. .. baseq2
quake2-server@cd23d8c1225e:~/.q2pro$ ls -al
total 16
drwxr-xr-x 3 quake2-server quake2-server 4096 Aug 31 12:47 .
drwxr-xr-x 1 quake2-server quake2-server 4096 Aug 31 12:36 ..
drwxr-xr-x 2 quake2-server quake2-server 4096 Aug 31 12:36 baseq2
quake2-server@cd23d8c1225e:~/.q2pro$ mkdir openffa
quake2-server@cd23d8c1225e:~/.q2pro$ cd openffa/
quake2-server@cd23d8c1225e:~/.q2pro/openffa$ mkdir logs
quake2-server@cd23d8c1225e:~/.q2pro/openffa$ cd logs
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ touchet console.log
bash: touchet: command not found
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ vim console.log
bash: vim: command not found
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ vi console.log
bash: vi: command not found
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ echo "test" >> console.log
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ dir
console.log
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ ls -al
total 12
drwxr-xr-x 2 quake2-server quake2-server 4096 Aug 31 12:49 .
drwxr-xr-x 3 quake2-server quake2-server 4096 Aug 31 12:49 ..
-rw-r--r-- 1 quake2-server quake2-server 5 Aug 31 12:49 console.log
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ cd \
> cd /usr/share
bash: cd: too many arguments
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ cd /usr/shrae
bash: cd: /usr/shrae: No such file or directory
quake2-server@cd23d8c1225e:~/.q2pro/openffa/logs$ cd /usr/share
quake2-server@cd23d8c1225e:/usr/share$ cd q2pro
quake2-server@cd23d8c1225e:/usr/share/q2pro$ ls -al
total 16
drwxr-xr-x 1 quake2-server quake2-server 4096 Aug 31 12:36 .
drwxr-xr-x 1 root root 4096 Aug 31 12:36 ..
drwxr-xr-x 2 quake2-server quake2-server 4096 Aug 31 12:47 baseq2
quake2-server@cd23d8c1225e:/usr/share/q2pro$ cd baseq2
quake2-server@cd23d8c1225e:/usr/share/q2pro/baseq2$ cd ..
quake2-server@cd23d8c1225e:/usr/share/q2pro$ mkdir openffa
quake2-server@cd23d8c1225e:/usr/share/q2pro$ mkdir ope^C
quake2-server@cd23d8c1225e:/usr/share/q2pro$ ^C
quake2-server@cd23d8c1225e:/usr/share/q2pro$ cd openffa
quake2-server@cd23d8c1225e:/usr/share/q2pro/openffa$ echo "test" >> console.log
quake2-server@cd23d8c1225e:/usr/share/q2pro/openffa$ ls -al
total 12
drwxr-xr-x 2 quake2-server quake2-server 4096 Aug 31 12:51 .
drwxr-xr-x 1 quake2-server quake2-server 4096 Aug 31 12:51 ..
-rw-r--r-- 1 quake2-server quake2-server 5 Aug 31 12:51 console.log
And still the error persists. It would maybe help me the exact location of the logfile that is tried to be created:
31mCouldn't open logs/console_openffa.log: Permission denied
As someone mentioned, this is a bit strange as it is the only path that is not absolute. So I don't know currently if the file is tried to be created inside the user's home dir (and there in the mod dir?): ~/.q2pro/logs/console_openffa.log ~/.q2pro/openffa/logs/console_openffa.log
Or if it is inside the dir of q2pro: /usr/share/q2pro/logs/console_openffa.log /usr/share/q2pro/openffa/console_openffa.log /usr/share/q2pro/baseq2/console_openffa.log
Or even another directoy? I see in the log that the server tries to search PAKs and game.so in many different locations. Any hints regarding this?
As someone mentioned, this is a bit strange as it is the only path that is not absolute.
If it's a relative path, there's a good probability it's relative to the current working directory. You could find that out by adding a pwd
right before you start the server.
pwd gives out
/
So, it's the root of the filesystem... Of course there this user would have no permissions but why would q2 try to create the dir there? shoudln't it be automatically the dir of the mod or the root dir of the quake2 installation?
But yeah, I can now try to change the working directory and see what happens.
Update: changed working dir to /usr/share/q2pro - entry in logfile still exists:
Couldn't open logs/console_openffa.log: Permission denied
Well, I'm not sure why it isn't working for you. Permissions look fine. Unless there is some deeper stuff in play (SELinux or some Docker-specific restrictions). Maybe there is some hint in dmesg
output (unlikely)?
It would maybe help me the exact location of the logfile that is tried to be created
You can check the full path with strace, e.g. strace -e file q2proded
.
As someone mentioned, this is a bit strange as it is the only path that is not absolute. So I don't know currently if the file is tried to be created inside the user's home dir (and there in the mod dir?)
It should be created in ~/.q2pro/openffa/logs
. Printed path is not absolute because it's virtual Q2 filesystem path. It is converted to absolute path internally, and is not relative to current directory. In fact, current directory shouldn't matter at all for Q2PRO and OpenFFA (but may matter for older mods).
Actually full strace log with -e file
would be useful. Maybe it's not open
syscall that fails with EACCES, but mkdir
when it tries to create the path to file.
OK, I was now able to solve the problem. The issue occured because I mount directories from the host to some volumes of the container, for example the mod directory (openffa in this specific case).
By doing this the files and also the permissions of the host directory will be used inside the container. I did not change the permissions of the host folder before but now I changed them with the following commands:
chown -R 1001:1001 /path/to/mounted/directory # Based on UID/GID of 'quake2-server' inside the container
chmod -R 755 /path/to/mounted/directory
So they are now accessbile to the user of the container and can be written to.
Hi,
I try to setup a quake 2 server using a docker container. I wrote my own dockerfile so I can use a current q2pro version: https://github.com/TheShihan/docker-quake2server
The docker image can be found here: https://hub.docker.com/repository/docker/theshihan/quake2server/general
I encounter an issue during startup of the server: Couldn't open logs/console.log: Permission denied
Strange is also, that I set "logfile_name " to "console_openffa", so why does it talk about "console.log" - but maybe it's not this kind of log.
It seems that it is not able to write any files, as if the directory is write protected, but those dirs should all be inside the running users home directory or in a directory that have been chown-ed to the running user (+755 -R set).
Here is the full log:
And here is the full server config (game is set to "openffa" as startup parameter)
Any ideas why this could happen? I am not sure if the issue comes from q2pro or docker. But maybe you can help me narrow it down by telling me why this log entry appears anyway.