Download mods and headless server

till working on improvements to code this more like
a savepoint.
This commit is contained in:
2026-05-03 14:00:16 -06:00
parent aecc2162e7
commit 8fb2c2aeb2
10 changed files with 340 additions and 125 deletions

90
cli.go
View File

@@ -8,51 +8,55 @@ import (
func cliToolMode() {
var c = readCfg("config.yml")
modlist := string(c.Server.ServDir) + "/mods/mod-list.json"
if verifyConfig(c) {
if len(os.Args) > 1 {
switch os.Args[1] {
case "start":
if len(os.Args) > 1 {
switch os.Args[1] {
case "start":
if verifyConfig(c) {
startStopServer("start", c)
case "stop":
startStopServer("stop", c)
case "help", "h", "--help", "-h":
fmt.Printf("Start Server: %s start\nStop Server: %s stop\n", os.Args[0], os.Args[0])
fmt.Printf("Run backup\n\tFull backup: %s backup full", os.Args[0])
fmt.Printf("\n\tBackup saves: %s backup saves\n", os.Args[0])
case "mod":
if len(os.Args) > 2 {
switch os.Args[2] {
case "download":
if !findmodlist(modlist) {
fmt.Printf("FAILED TO FIND MOD LIST")
} else {
fmt.Printf("found %s\n", modlist)
downloadMods(modlist)
}
default:
fmt.Println("Invalid mod option: use 'update'")
}
} else {
fmt.Println("Missing mod option: use 'update'")
}
case "backup":
if len(os.Args) > 2 {
switch os.Args[2] {
case "full":
backUp("full", c)
case "saves":
backUp("saves", c)
default:
fmt.Println("Invalid backup type: use 'full' or 'saves'")
}
} else {
fmt.Println("Missing backup type: use 'full' or 'saves'")
}
default:
fmt.Printf("Unknown command: %s. Use 'start', 'stop', or 'backup'.\n", os.Args[1])
}
} else {
fmt.Println("Use 'start', 'stop', or 'backup' command\nex. factoryman start\nTo configure edit 'config.yml'")
case "stop":
if verifyConfig(c) {
startStopServer("stop", c)
}
case "help", "h", "--help", "-h":
fmt.Printf("Start Server: %s start\nStop Server: %s stop\n", os.Args[0], os.Args[0])
fmt.Printf("Run backup\n\tFull backup: %s backup full", os.Args[0])
fmt.Printf("\n\tBackup saves: %s backup saves\n", os.Args[0])
case "download":
if len(os.Args) > 2 {
switch os.Args[2] {
case "mods":
if !findmodlist(modlist) {
fmt.Printf("FAILED TO FIND MOD LIST")
} else {
fmt.Printf("found %s\n", modlist)
downloadMods(modlist)
}
case "server":
downloadHeadless()
default:
fmt.Println("Invalid mod option: use 'update'")
}
} else {
fmt.Println("Missing mod option: use 'update'")
}
case "backup":
if len(os.Args) > 2 {
switch os.Args[2] {
case "full":
backUp("full", c)
case "saves":
backUp("saves", c)
default:
fmt.Println("Invalid backup type: use 'full' or 'saves'")
}
} else {
fmt.Println("Missing backup type: use 'full' or 'saves'")
}
default:
fmt.Printf("Unknown command: %s. Use 'start', 'stop', or 'backup'.\n", os.Args[1])
}
} else {
fmt.Println("Use 'start', 'stop', or 'backup' command\nex. factoryman start\nTo configure edit 'config.yml'")
}
}