Skip to content

Commit

Permalink
Enhanced and fixed file check on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
lubocode committed Nov 3, 2020
1 parent 1594917 commit 05c9958
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion go-script/minecraft-server-hibernation.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,28 @@ func checkConfig() string {
os.Exit(1)
}

// check if serverFile exists
// check if serverFolder exists
logger("Checking for " + config.Basic.ServerDirPath)
_, err := os.Stat(config.Basic.ServerDirPath)
if os.IsNotExist(err) {
return fmt.Sprintf("specified server directory does not exist: %s", config.Basic.ServerDirPath)
}

// check if serverFile exists
var serverFileName string = ""
if runtime.GOOS == "linux" {
var startString []string = strings.Split(config.Basic.StartMinecraftServerLin, " ")
serverFileName = startString[len(startString)-2]
} else if runtime.GOOS == "windows" {
var startString []string = strings.Split(config.Basic.StartMinecraftServerWin, " ")
serverFileName = startString[len(startString)-2]
}
logger("Checking for " + config.Basic.ServerDirPath + serverFileName)
_, err = os.Stat(config.Basic.ServerDirPath + serverFileName)
if os.IsNotExist(err) {
return fmt.Sprintf("specified server file does not exist: %s", serverFileName)
}

// check if java is installed
err = exec.Command("java", "-version").Run()
if err != nil {
Expand Down

0 comments on commit 05c9958

Please sign in to comment.