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

Check for server.jar on startup of script #40

Closed
lubocode opened this issue Oct 9, 2020 · 3 comments
Closed

Check for server.jar on startup of script #40

lubocode opened this issue Oct 9, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@lubocode
Copy link
Contributor

lubocode commented Oct 9, 2020

Checking whether or not the server.jar can be found on script startup should be essential to avoid users setting up something incorrectly and thinking their setup is working, while the script cannot find the server when a users actually tries to connect.

This should be handled with OS independent functions/libraries.

@lubocode lubocode added the enhancement New feature or request label Oct 9, 2020
@gekigek99 gekigek99 self-assigned this Oct 9, 2020
@lubocode
Copy link
Contributor Author

lubocode commented Oct 14, 2020

I just quickly through something together because I needed this in the Docker branch for testing.
Has to be adjusted for usage of the config file and maybe cleaned up a bit.

	// Check if MC server file exists at chosen location
	if mcPath[len(mcPath)-1:] != "/" {
		logger("Path without last \"/\". Adding...")
		mcPath = mcPath + "/"
	}
	mcFilePath := mcPath + mcFile
	logger("mcFilePath: " + mcFilePath)
	if _, err := os.Stat(mcFilePath); err != nil {
		if os.IsNotExist(err) {
			logger("MC server file not found.")
                        os.Exit(1)
		}
	} else {
		logger("MC server file found.")
	}

Oh, and maybe this is Linux specific...
Gotta check the os.Stat() definition.

Also, adding / is definitely linux specific. For Windows one would need to add \

@gekigek99
Copy link
Member

added in bc373ba

@lubocode
Copy link
Contributor Author

lubocode commented Nov 3, 2020

Changed to encompass the file and not only the folder in 05c9958

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants