Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folders created in wrong directory #93

Closed
cstreit03 opened this issue Jun 23, 2021 · 5 comments
Closed

Folders created in wrong directory #93

cstreit03 opened this issue Jun 23, 2021 · 5 comments
Assignees

Comments

@cstreit03
Copy link

cstreit03 commented Jun 23, 2021

At the beginning of the start.sh script, the if statements check for if the logs, downloads, and backups folders exist. If they don't exist, it creates them. I noticed that the script decides to save the folders in the home directory (one folder above the minecraftbe folder). Maybe add something like the following:

path="/home/$USER/minecraftbe" #<-- this is new
if [ ! -d "logs" ]; then
mkdir $path/logs #<-- add the $path variable so it makes it in the right directory
fi

#Then do the same thing for each of the other folders

You could also do this before checking for if the directories exist:

cd /home/$USER/minecraftbe

if [ ! -d "logs" ]; then
mkdir logs
fi

#This method is so much simpler (make sure to cd back to home afterwards though

cd ~
@da99Beast
Copy link

I would like to point out that some of us may install to a path outside of the /home structure so hard coding to that would be bad. With the setup we specified the install path (mine was /opt) so we should have a record of where the Minecraft is installed to and where the start/stop/restart files are and where the logs/downloads/backups folders should be.

Just looked, line 45-46 (comment and cd commands) we switch to the proper folder. We should probably move the checks for the logs/downloads/backups folder to after this or move lines 45-46 above the folder check to resolve properly.

@cstreit03
Copy link
Author

I would like to point out that some of us may install to a path outside of the /home structure so hard coding to that would be bad. With the setup we specified the install path (mine was /opt) so we should have a record of where the Minecraft is installed to and where the start/stop/restart files are and where the logs/downloads/backups folders should be.

Just looked, line 45-46 (comment and cd commands) we switch to the proper folder. We should probably move the checks for the logs/downloads/backups folder to after this or move lines 45-46 above the folder check to resolve properly.

True! I’ve always installed it to my home directory for convenience. I suppose that it would be easier to ask the user for a specific path in the setup script then save the variable to a file (then import with the source command). I was working on some scripts to account for variables but it’s going to take a while with my busy schedule.

@starkey-01
Copy link

@CobraBitYou are you running this as a service or manually executing start.sh when you need to?

The logs, downloads and backups folder are inside the server name folder for me. I believe the reason for that is the service runs start.sh from inside the server folder.

Noting that I am installing to a custom directory outside of the home directory too.

minecraftbe/
└── servername
    ├── backups
    ├── behavior_packs
    ├── definitions
    ├── development_behavior_packs
    ├── development_resource_packs
    ├── development_skin_packs
    ├── downloads
    ├── logs
    ├── minecraftpe
    ├── premium_cache
    ├── resource_packs
    ├── structures
    ├── treatments
    ├── world_templates
    └── worlds

@cstreit03
Copy link
Author

cstreit03 commented Jun 26, 2021

@CobraBitYou are you running this as a service or manually executing start.sh when you need to?

The logs, downloads and backups folder are inside the server name folder for me. I believe the reason for that is the service runs start.sh from inside the server folder.

Noting that I am installing to a custom directory outside of the home directory too.

minecraftbe/
└── servername
    ├── backups
    ├── behavior_packs
    ├── definitions
    ├── development_behavior_packs
    ├── development_resource_packs
    ├── development_skin_packs
    ├── downloads
    ├── logs
    ├── minecraftpe
    ├── premium_cache
    ├── resource_packs
    ├── structures
    ├── treatments
    ├── world_templates
    └── worlds

I usually run it with sudo systemctl start mcpe. The folders on my device also show up within the minecraftbe/$servername directory (probably from the original setup). However, when I delete the folders in my home directory, they reappear after I restart my server.

So, it sounds like you use start.sh to start the server and it creates the folders in the right directory. I assume it has something to do with the permissions and method of executing start.sh.

For example, I have a reboot.sh script that starts the server at reboot, schedules a shutdown and startup (which loops it continuously for an entire week), and tells the Minecraft server to stop at a specific time. It starts this script at reboot through the sudo crontab. Maybe running using sudo is causing the issue?

Edit: These folders aren’t being used since they don’t contain backups or logs.

@TheRemote
Copy link
Owner

TheRemote commented Jul 2, 2021

It sounds like you may have a mix of using an old SetupMinecraft.sh (it has been changing almost every week) that is downloading newer versions of start.sh from the repository.

The new version of the scripts you choose where to install it (~ is the default, and how the old script always used to work until very recently). This sounds like it may be a case of mixing and matching SetupMinecraft.sh and the latest repository scripts.

I've actually changed my recommended way of running the script to:

curl https://raw.githubusercontent.com/TheRemote/MinecraftBedrockServer/master/SetupMinecraft.sh | bash

This way doesn't save any copy of SetupMinecraft.sh at all since that has caused nothing but trouble. Can you verify all this and try with the latest version and see if this behavior is gone?

EDIT: Actually, I do see it here. This would only happen if you ran start.sh from outside the server folder without changing directories into it first as others have pointed out here in the thread (the systemd services already change to the correct directory). I'm going to just move the cd to above where the folders are created so it will always work. I've committed this fix to GitHub, thanks!

TheRemote added a commit that referenced this issue Jul 2, 2021
TheRemote added a commit that referenced this issue Jul 3, 2021
@TheRemote TheRemote self-assigned this May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants