Open Gazoo432 opened 4 years ago
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...
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.
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!
Actually did not know about that feature. Thanks for the update.
adding the above ExecStartPre worked but made su - minecraft -c "/usr/bin/screen -r" minecraft
fail saying "/run/screen needs 775"
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.
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 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?
@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]: minecraft@mc-1-16-4-pure.service: Main process exited, code=exited, status=123/n/a systemd[1]: minecraft@mc-1-16-4-pure.service: Failed with result 'exit-code'. so why this error appear?
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.
@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
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.