Download mods and headless server
till working on improvements to code this more like a savepoint.
This commit is contained in:
32
config.go
32
config.go
@@ -9,24 +9,6 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type GoConfig struct {
|
||||
Server struct { // server specific settings
|
||||
ServDir string `yaml:"serverFolder"`
|
||||
WorldFile string `yaml:"worldFile"`
|
||||
ServCfg string `yaml:"serverSettings"`
|
||||
ServExec string `yaml:"serverExec"`
|
||||
ServPort int `yaml:"port"`
|
||||
} `yaml:"server"`
|
||||
|
||||
Factoryman struct { // factoryman settings
|
||||
BackupDir string `yaml:"backupDir"`
|
||||
UseScreen bool `yaml:"screen"`
|
||||
ScreenName string `yaml:"screenName"`
|
||||
UserName string `yaml:"username"`
|
||||
ApiToken string `yaml:"apitoken"`
|
||||
} `yaml:"factoryman"`
|
||||
}
|
||||
|
||||
func readCfg(factCfg string) GoConfig {
|
||||
//read config file (YAML)
|
||||
fileBytes, err := os.ReadFile(factCfg)
|
||||
@@ -51,26 +33,30 @@ func isItReal(path string) bool { //check if path exists
|
||||
}
|
||||
}
|
||||
func verifyConfig(config GoConfig) bool { // check each file/dir to see if it exists
|
||||
if !isItReal(config.Server.ServDir) {
|
||||
if !isItReal(config.Server.ServDir) { //check for Server directory
|
||||
fmt.Printf("PATH NOT FOUND: %s", config.Server.ServDir)
|
||||
return false
|
||||
}
|
||||
if !isItReal(config.Server.WorldFile) {
|
||||
if !isItReal(config.Server.WorldFile) { // check for world file
|
||||
fmt.Printf("PATH NOT FOUND: %s", config.Server.WorldFile)
|
||||
return false
|
||||
}
|
||||
if !isItReal(config.Server.ServCfg) {
|
||||
if !isItReal(config.Server.ServCfg) { // check for server config
|
||||
fmt.Printf("PATH NOT FOUND: %s", config.Server.ServCfg)
|
||||
return false
|
||||
}
|
||||
if !isItReal(config.Server.ServExec) {
|
||||
if !isItReal(config.Server.ServExec) { // check for server exec file to lanch server
|
||||
fmt.Printf("PATH NOT FOUND: %s", config.Server.ServExec)
|
||||
return false
|
||||
}
|
||||
if !isItReal(config.Factoryman.BackupDir) {
|
||||
if !isItReal(config.Factoryman.BackupDir) { // check for backup directory
|
||||
fmt.Printf("PATH NOT FOUND: %s", config.Factoryman.BackupDir)
|
||||
return false
|
||||
}
|
||||
|
||||
if config.Factoryman.ApiToken == "" || config.Factoryman.UserName == "" {
|
||||
fmt.Printf("API Token/Username not set (to download mods add api token and username to config)")
|
||||
}
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user