TheRemote / MinecraftBedrockServer

Sets up a Minecraft Bedrock dedicated server on Ubuntu with options for automatic updates and running at startup
https://jamesachambers.com/minecraft-bedrock-edition-ubuntu-dedicated-server-guide/
MIT License
812 stars 173 forks source link

Failed to create service while installing #104

Closed Josefant closed 3 years ago

Josefant commented 3 years ago

Installed fresh Ubuntu 20.04.02 LTS and trying to install Minecraft server. Using default location, and non-root user.

  inflating: whitelist.json
rm: cannot remove 'start.sh': No such file or directory
rm: cannot remove 'stop.sh': No such file or directory
rm: cannot remove 'restart.sh': No such file or directory
rm: cannot remove 'fixpermissions.sh': No such file or directory
Grabbing start.sh from repository...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4609  100  4609    0     0  20958      0 --:--:-- --:--:-- --:--:-- 21045
Grabbing stop.sh from repository...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2770  100  2770    0     0   9892      0 --:--:-- --:--:-- --:--:--  9928
Grabbing restart.sh from repository...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2866  100  2866    0     0   8772      0 --:--:-- --:--:-- --:--:--  8791
Grabbing fixpermissions.sh from repository...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1979  100  1979    0     0   8953      0 --:--:-- --:--:-- --:--:--  8954
Grabbing update.sh from repository...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   497  100   497    0     0   2248      0 --:--:-- --:--:-- --:--:--  2259
Configuring Minecraft Test service...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file /etc/systemd/system/Test.service:
Warning: Permission denied
100   361  100   361    0     0   1202      0 --:--:-- --:--:-- --:--:--  1203
curl: (23) Failure writing output to destination
chmod: cannot access '/etc/systemd/system/Test.service': No such file or directory
sed: can't read /etc/systemd/system/Test.service: No such file or directory
sed: can't read /etc/systemd/system/Test.service: No such file or directory
sed: can't read /etc/systemd/system/Test.service: No such file or directory
Start Minecraft server at startup automatically (y/n)?y
Failed to enable unit: Unit file Test.service does not exist.
Your time zone is currently set to Europe/Oslo.  Current system time: ma. 16. aug. 13:51:18 +0200 2021
You can adjust/remove the selected reboot time later by typing crontab -e or running SetupMinecraft.sh again.
Automatically restart and backup server at 4am daily (y/n)?y
Daily restart scheduled.  To change time or remove automatic restart type crontab -e
Setting server file permissions...
tail: cannot open '' for reading: No such file or directory
Setup is complete.  Starting Minecraft server. To view the console use the command screen -r or check the logs folder if the server fails to start.
Failed to start Test.service: Unit Test.service not found.
Minecraft server failed to start after 20 seconds.

Any suggestions on how to resolve this?

TheRemote commented 3 years ago

Does the user you are installing on not have sudo rights? You're getting permissions errors to /etc/systemd/system/Test.service but a user with sudo rights should be able to write there (and one without sudo rights will not be able to).

It doesn't seem like curl can write the scripts either which shouldn't even be in a protected location. Is this install mounted in read-only or something like that? Can you write any files to the disk? Something is highly unusual here for sure but hopefully that points you toward the right direction here!

Josefant commented 3 years ago

I do have sudo rights, but there is a problem when running "sudo curl ...", or actually: the "curl to file" itself...

This is a fresh Ubuntu 20.04.02 LTS running on a VM in an ESXi server. Seems to be a problem with the "curl to file" part:

root@minecraft:/etc/systemd/system# curl -H "Accept-Encoding: identity" -L -o test.test https://raw.githubusercontent.com/TheRemote/MinecraftBedrockServer/master/minecraftbe.service
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0Warning: Failed to create the file test.test: Permission denied
100   361  100   361    0     0    200      0  0:00:01  0:00:01 --:--:--   200
curl: (23) Failure writing output to destination
Josefant commented 3 years ago

Hmm... Could this be the reason?...

root@minecraft:/tmp# which curl
/snap/bin/curl
Josefant commented 3 years ago

Yup. The snap version of the curl was the reason for this problem. Removed and reinstalled curl with:

sudo snap remove curl
sudo apt install curl

Then download of file seems to work fine.

TheRemote commented 3 years ago

Hey Josefant,

Glad you were able to get it! That's interesting it's a snap version of curl on there. Thanks for posting the solution!

Josefant commented 3 years ago

Maybe add a check in the installation script? Pseudo: If which curl contains snap, then give message that this could be a potential problem (curl could have problems writing certain files) - suggest to replace with apt version - and wait for user to continue.

Or: Research and circumvent it. I suspect that snap have some kind of sandboxing which disallows writing data to certain places. E.g. if you install the curl snap version and download to /tmp/... the file ends up in /tmp/snap./tmp/ or something similar... So a possible solution could might be to download all files to "secure" locations (maybe the tmp folder) and then use other command to have the file moved to the final location.