Renegade-Master / zomboid-dedicated-server

Linux based Docker image containing a Dedicated Server for Project Zomboid.
https://hub.docker.com/r/renegademaster/zomboid-dedicated-server
Other
177 stars 60 forks source link

How to access server console to set admin #20

Closed Rumsfield closed 2 years ago

Rumsfield commented 2 years ago

I'm new to docker and I'm trying to figure out how to interact with the server console from an SSH terminal session. I'm using a VPS running Debian 10, and I've been able to run the docker compose file to bring up the container. The server works, I've played on it. But I just need to access the console.

When I run this command, I see the zomboid server print log messages during server startup.

$ docker-compose up --build
Building zomboid-server
Sending build context to Docker daemon   72.7kB
...
Starting zomboid-dedicated-server_zomboid-server_1 ... done
Attaching to zomboid-dedicated-server_zomboid-server_1
zomboid-server_1  |
zomboid-server_1  | ### Setting variables...
zomboid-server_1  |
...
zomboid-server_1  | LOG  : General     , 1648929464158> 315,397,620> LuaNet: Initialization [DONE], triggering events for 'LuaNet.onInitAdd'.
zomboid-server_1  | LOG  : Network     , 1648929464158> 315,397,620> DISCORD: token not configured
zomboid-server_1  | LOG  : Network     , 1648929464158> 315,397,620> *** DISCORD DISABLED ****
zomboid-server_1  | LOG  : General     , 1648929464164> 315,397,627> ##########
zomboid-server_1  | Server Steam ID [removed]
zomboid-server_1  | ##########
zomboid-server_1  | LOG  : Multiplayer , 1648929464184> 315,397,646> [MPStatistics] mem usage notification threshold=4,080,218,880
zomboid-server_1  | LOG  : General     , 1648929464192> 315,397,654> RCON: listening on port 27015
zomboid-server_1  | LOG  : General     , 1648929465442> 315,398,904> 1648929465442 znet: OnPolicyResponse
zomboid-server_1  | LOG  : General     , 1648929465442> 315,398,904> 1648929465442 znet: Zomboid Server is VAC Secure
zomboid-server_1  | LOG  : General     , 1648929465568> 315,399,030> Unknown command process-status@eof

But I'm not able to enter any commands. Sorry if I'm missing something obvious, but could you please help me understand what's wrong? image

Here is the content of my docker-compose.yml:

version: "3.8"

services:
  zomboid-server:
    build:
      context: .
      dockerfile: docker/zomboid-dedicated-server.Dockerfile
      args:
        USER_ID: 1000
        GROUP_ID: 1000
    restart: "no"
    user: "1000:1000"
    tty: true
    stdin_open: true
    environment:
      - "ADMIN_PASSWORD=[removed]"
      - "ADMIN_USERNAME=[removed]"
      - "AUTOSAVE_INTERVAL=15"
      - "BIND_IP=0.0.0.0"
      - "GAME_PORT=8766"
      - "GAME_VERSION=public"
      - "MAX_PLAYERS=16"
      - "MAX_RAM=4096m"
      - "MOD_NAMES="
      - "MOD_WORKSHOP_IDS="
      - "NO_CHOWN_CONFIG_DIR=false"
      - "NO_CHOWN_GAME_DIR=false"
      - "PAUSE_ON_EMPTY=true"
      - "PUBLIC_SERVER=true"
      - "QUERY_PORT=16261"
      - "RCON_PASSWORD=[removed]"
      - "RCON_PORT=27015"
      - "SERVER_NAME=[removed]"
      - "SERVER_PASSWORD=[removed]"
      - "STEAM_VAC=true"
      - "USE_STEAM=true"
    ports:
      - target: 8766
        published: 8766
        protocol: udp
      - target: 16261
        published: 16261
        protocol: udp
      - target: 27015
        published: 27015
        protocol: tcp
    volumes:
      - ./ZomboidDedicatedServer:/home/steam/ZomboidDedicatedServer
      - ./ZomboidConfig:/home/steam/Zomboid/
Rumsfield commented 2 years ago

As a follow up, this is all in the effort to give myself admin on the server. One path is to run the command setaccesslevel "Rumsfield" "admin" in the server console, which is why I made this issue.

The other path of using the environment variables ADMIN_PASSWORD and ADMIN_USERNAME in the docker-compose.yaml file doesn't work for me. I've tried setting it, and the console logs show the correct values, yet when I log into the server with those credentials, I don't have admin rights.

From the console log:

pz                | pzexe: using jvm "/home/steam/ZomboidDedicatedServer/jre64/lib/server/libjvm.so"
pz                | pzexe: arg: -cachedir=/home/steam/Zomboid
pz                | pzexe: arg: -adminusername
pz                | pzexe: arg: Rumsfield
pz                | pzexe: arg: -adminpassword
pz                | pzexe: arg: 123456

image

Is there some step I'm missing to get the environment variables to work?

Rumsfield commented 2 years ago

I was able to use the rcon terminal to run console commands, but I'm still not able to set admin access for myself. From the rcon:

> players
Players connected (1):
-Rumsfield
> setaccesslevel "Rumsfield" "admin"
User "Rumsfield" is not in the whitelist, use /adduser first
> adduser "Rumsfield" "XXXXXX"
User Rumsfield created with the password $2a$12$O/XXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXX
> setaccesslevel "Rumsfield" "admin"
User "Rumsfield" is not in the whitelist, use /adduser first

And the corresponding attached container console logs:

LOG  : General     , 1649006318040> 392,251,502> RCON: ID=0 Type=2 Body='adduser "Rumsfield" "XXXXXX"' Socket[removed]
ERROR: General     , 1649006318542> 392,252,004> org.sqlite.SQLiteException: [SQLITE_CONSTRAINT]  Abort due to constraint violation (UNIQUE constraint failed: whitelist.username)
ERROR: General     , 1649006318542> 392,252,004>        at org.sqlite.core.DB.newSQLException(DB.java:941)
ERROR: General     , 1649006318542> 392,252,004>        at org.sqlite.core.DB.newSQLException(DB.java:953)
ERROR: General     , 1649006318543> 392,252,005>        at org.sqlite.core.DB.execute(DB.java:854)
ERROR: General     , 1649006318543> 392,252,005>        at org.sqlite.core.DB.executeUpdate(DB.java:895)
ERROR: General     , 1649006318543> 392,252,005>        at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:102)
ERROR: General     , 1649006318543> 392,252,005>        at zombie.network.ServerWorldDatabase.addUser(ServerWorldDatabase.java:210)
ERROR: General     , 1649006318543> 392,252,005>        at zombie.commands.serverCommands.AddUserCommand.Command(AddUserCommand.java:42)
ERROR: General     , 1649006318543> 392,252,005>        at zombie.commands.CommandBase.Execute(CommandBase.java:131)
ERROR: General     , 1649006318543> 392,252,005>        at zombie.network.GameServer.handleServerCommand(GameServer.java:1165)
ERROR: General     , 1649006318544> 392,252,006>        at zombie.network.GameServer.rcon(GameServer.java:1136)
ERROR: General     , 1649006318544> 392,252,006>        at zombie.network.RCONServer$ExecCommand.update(RCONServer.java:344)
ERROR: General     , 1649006318544> 392,252,006>        at zombie.network.RCONServer.updateMain(RCONServer.java:386)
ERROR: General     , 1649006318544> 392,252,006>        at zombie.network.RCONServer.update(RCONServer.java:412)
ERROR: General     , 1649006318544> 392,252,006>        at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
ERROR: General     , 1649006318544> 392,252,006>        at zombie.network.GameServer.main(GameServer.java:916)
LOG  : General     , 1649006339108> 392,272,571> RCON: ID=0 Type=2 Body='setaccesslevel "Rumsfield" "admin"' Socket[removed]
ERROR: General     , 1649006339153> 392,272,615> org.sqlite.SQLiteException: [SQLITE_CONSTRAINT]  Abort due to constraint violation (UNIQUE constraint failed: whitelist.username)
ERROR: General     , 1649006339154> 392,272,616>        at org.sqlite.core.DB.newSQLException(DB.java:941)
ERROR: General     , 1649006339154> 392,272,617>        at org.sqlite.core.DB.newSQLException(DB.java:953)
ERROR: General     , 1649006339155> 392,272,617>        at org.sqlite.core.DB.execute(DB.java:854)
ERROR: General     , 1649006339155> 392,272,617>        at org.sqlite.core.DB.executeUpdate(DB.java:895)
ERROR: General     , 1649006339159> 392,272,621>        at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:102)
ERROR: General     , 1649006339159> 392,272,621>        at zombie.network.ServerWorldDatabase.addUser(ServerWorldDatabase.java:210)
ERROR: General     , 1649006339159> 392,272,621>        at zombie.network.ServerWorldDatabase.setAccessLevel(ServerWorldDatabase.java:909)
ERROR: General     , 1649006339160> 392,272,622>        at zombie.commands.serverCommands.SetAccessLevelCommand.update(SetAccessLevelCommand.java:97)
ERROR: General     , 1649006339160> 392,272,622>        at zombie.commands.serverCommands.SetAccessLevelCommand.Command(SetAccessLevelCommand.java:40)
ERROR: General     , 1649006339160> 392,272,622>        at zombie.commands.CommandBase.Execute(CommandBase.java:131)
ERROR: General     , 1649006339160> 392,272,622>        at zombie.network.GameServer.handleServerCommand(GameServer.java:1165)
ERROR: General     , 1649006339160> 392,272,622>        at zombie.network.GameServer.rcon(GameServer.java:1136)
ERROR: General     , 1649006339160> 392,272,622>        at zombie.network.RCONServer$ExecCommand.update(RCONServer.java:344)
ERROR: General     , 1649006339160> 392,272,622>        at zombie.network.RCONServer.updateMain(RCONServer.java:386)
ERROR: General     , 1649006339160> 392,272,623>        at zombie.network.RCONServer.update(RCONServer.java:412)
ERROR: General     , 1649006339161> 392,272,623>        at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
ERROR: General     , 1649006339161> 392,272,623>        at zombie.network.GameServer.main(GameServer.java:916)

My server config INI is set to open, so there shouldn't be a whitelist. This appears to be some sort of bug with the player SQL database?

Renegade-Master commented 2 years ago

Hi!

I was going to say that the recommendation for console access is the rcon binary.

Strange that you can't set yourself as Admin. It's always worked in my experience. Normally I can just login as the Admin as you are trying to do, and I can set other people up with Admin permissions from there.

Are you certain that you have restarted the server between attempts?

And is it out of the question to delete the contents of the ZomboidConfig directory to rule out data corruption?

Rumsfield commented 2 years ago

I do restart between attempts, and to do that I use commands docker container stop pz to stop the container, edit config files, then start with docker-compose up -d. I named my container "pz".

I guess I could try making a new container from scratch to see if the same admin login problem persists. One detail that may be relevant is that my server name includes spaces. Perhaps that introduces some kind of issue... I think I'll try making a new server without spaces in the name in a new container, to see if it works then.

Renegade-Master commented 2 years ago

A better way to stop them is

docker-compose down 

And then to do a proper rebuild, you can do

docker-compose up --build

Also everything is quoted in the script that runs the server, so spaces shouldn't be an issue.

Renegade-Master commented 2 years ago

@Rumsfield Is this still an issue?

Rumsfield commented 2 years ago

@Rumsfield Is this still an issue?

I remember that I was able to use rcon commands to temporarily give myself admin, but I couldn't figure out how to make it persist. That was a good enough workaround for what I needed. This is not an issue for me anymore. Feel free to close.

Renegade-Master commented 2 years ago

Thanks! It's very odd that persistence (specifically for admin status) isn't working though.

Maybe let me know if you ever figure it out, but I just can't replicate it.