MinecraftSystemdUnit icon indicating copy to clipboard operation
MinecraftSystemdUnit copied to clipboard

Issues with screen and RHEL 8

Open Gazoo432 opened this issue 5 years ago • 11 comments

I'm trying to use this systemd unit on a RHEL 8 server. It looks like screen is no longer officially supported in RHEL 8. I installed it via yum (through sudo). I get this error when trying to start the server: directory '/run/screen' must have mode 777

I can chmod /run/screen 777 but it does not survive a reboot.

I know not strictly related to this systemd unit but hoping I am not the only one with this issue or you already have a fix for it. As I am typing this I am wondering if just adding a chmod to the unit that executes before the screen command would work.

Gazoo432 avatar Jul 31 '20 03:07 Gazoo432

As a workaround you could add ExecStartPre=/bin/sh -c 'chmod /run/screen 777' to the unit.

I'll leave this issue open as a reminder to move from screen to e.g. tmux...

agowa avatar Jul 31 '20 18:07 agowa

Thanks, I'll give that a try. I tried to transition it to tmux myself and ended up trashing the VM so much I had to roll back the snapshot.

Gazoo432 avatar Jul 31 '20 19:07 Gazoo432

For anyone that finds this in the future, after some more research there are actually 2 lines that need to be added to get around the "/run/screen needs 777" error since chmod needs to be run as 'root' :

PermissionsStartOnly=true ExecStartPre=/bin/sh -c 'chmod 777 /run/screen'

Although the "PermissionsStartOnly" directive has been depreciated so this one should work on RHEL 8 and newer:

ExecStartPre=+/bin/sh -c 'chmod 777 /run/screen'

the "+" is what allows the command to run at elevated (root) permissions.

Thanks again for the module agowa338!

Gazoo432 avatar Jul 31 '20 23:07 Gazoo432

Actually did not know about that feature. Thanks for the update.

agowa avatar Aug 01 '20 06:08 agowa

adding the above ExecStartPre worked but made su - minecraft -c "/usr/bin/screen -r" minecraft fail saying "/run/screen needs 775"

dobbleg1000 avatar Aug 07 '20 03:08 dobbleg1000

Got that also, seems that screen in RHEL 8 is just total crap since it is no longer supported. After a day or so of trying all the different combinations I just ended up using rcon to perform server functions instead of the screen console. At least that way the service starts on boot or crash.

Gazoo432 avatar Aug 07 '20 03:08 Gazoo432

I'll leave this issue open as a reminder to move from screen to e.g. tmux...

I tried to use tmux,but tmux does't recognize minecraft server as a "terminal" my config

jingkaimori avatar Dec 20 '20 04:12 jingkaimori

@jingkaimori Starting with L40 it is wrong. The /bin/sh is there in order to get shell evaluation and therefore to be able to pipe stuff aka. for line 47 to work as expected as systemd treats the commands literally and doesn't do evaluation. Therefore the change you did in L40 should really be after the pipe in L48.

Also the ordering of your tmux commands looks off, you're first sending keys, but afterwards selecting the pane and window as well as attaching to the session. Maybe you want to invert the ordering? But I'm not that used to tmux syntax, so I'm not sure what you're trying to archive with these commands.

Also could you make a merge request once you've it all up and running?

agowa avatar Dec 20 '20 07:12 agowa

@jingkaimori Starting with L40 it is wrong. The /bin/sh is there in order to get shell evaluation and therefore to be able to pipe stuff aka. for line 47 to work as expected as systemd treats the commands literally and doesn't do evaluation. Therefore the change you did in L40 should really be after the pipe in L48.

changed as you said,but it still not work.error is shown below:

systemd[1]: Started Minecraft Server mc-1-16-4-pure. sh[17346]: open terminal failed: not a terminal systemd[1]: [email protected]: Main process exited, code=exited, status=123/n/a systemd[1]: [email protected]: Failed with result 'exit-code'.

so why this error appear?

jingkaimori avatar Dec 22 '20 02:12 jingkaimori

That looks like an error with you tmux command. But from what stackoverflow says to that error https://stackoverflow.com/questions/25207909/tmux-open-terminal-failed-not-a-terminal You need to add -d to the new-session command.

agowa avatar Dec 22 '20 05:12 agowa

@agowa338 I changed the profile and there is no literial error,but the server cannot be attached by tmux,and the stop config can't work.When I tried to attach the tmux,error appeared like this:

no server running on /tmp/tmux-113/default

new config is in my repo

jingkaimori avatar Dec 22 '20 08:12 jingkaimori