feat: add automation features (auto-update, auto-start, scheduled updates)

This commit is contained in:
MrFastwind
2026-07-06 16:10:17 +02:00
parent b853aead8c
commit 149a60c6fb
12 changed files with 325 additions and 30 deletions

View File

@@ -12,6 +12,7 @@ type Handler struct {
modlists *services.ModlistManager
process *services.ProcessManager
steamcmd *services.SteamCmdManager
scheduler *services.Scheduler
streamer *services.LogStreamer
serverfileDir string
modsDir string
@@ -25,6 +26,7 @@ func New(
modlists *services.ModlistManager,
process *services.ProcessManager,
steamcmd *services.SteamCmdManager,
scheduler *services.Scheduler,
streamer *services.LogStreamer,
serverfileDir, modsDir, cfgDir, profilesDir string,
) *Handler {
@@ -34,6 +36,7 @@ func New(
modlists: modlists,
process: process,
steamcmd: steamcmd,
scheduler: scheduler,
streamer: streamer,
serverfileDir: serverfileDir,
modsDir: modsDir,

View File

@@ -7,16 +7,20 @@ import (
)
type updateSettingsInput struct {
IPPort *string `json:"ip_port"`
ServerParameters *string `json:"server_parameters"`
SteamBranch *string `json:"steam_branch"`
SteamUser *string `json:"steam_user"`
Platform *string `json:"platform"`
CBASettings *string `json:"cba_settings"`
AILevelPresets *string `json:"ai_level_presets"`
DifficultyPresets *string `json:"difficulty_presets"`
ActiveConfig *string `json:"active_config"`
ActiveModlist *string `json:"active_modlist"`
IPPort *string `json:"ip_port"`
ServerParameters *string `json:"server_parameters"`
SteamBranch *string `json:"steam_branch"`
SteamUser *string `json:"steam_user"`
Platform *string `json:"platform"`
CBASettings *string `json:"cba_settings"`
AILevelPresets *string `json:"ai_level_presets"`
DifficultyPresets *string `json:"difficulty_presets"`
ActiveConfig *string `json:"active_config"`
ActiveModlist *string `json:"active_modlist"`
AutoUpdateOnStartup *bool `json:"auto_update_on_startup"`
AutoStartOnStartup *bool `json:"auto_start_on_startup"`
AutoUpdateModsOnStartup *bool `json:"auto_update_mods_on_startup"`
ScheduledUpdate *string `json:"scheduled_update"`
}
func (h *Handler) GetSettings(c *gin.Context) {
@@ -51,6 +55,10 @@ func (h *Handler) UpdateSettings(c *gin.Context) {
if input.DifficultyPresets != nil { s.DifficultyPresets = *input.DifficultyPresets }
if input.ActiveConfig != nil { s.ActiveConfig = *input.ActiveConfig }
if input.ActiveModlist != nil { s.ActiveModlist = *input.ActiveModlist }
if input.AutoUpdateOnStartup != nil { s.AutoUpdateOnStartup = *input.AutoUpdateOnStartup }
if input.AutoStartOnStartup != nil { s.AutoStartOnStartup = *input.AutoStartOnStartup }
if input.AutoUpdateModsOnStartup != nil { s.AutoUpdateModsOnStartup = *input.AutoUpdateModsOnStartup }
if input.ScheduledUpdate != nil { s.ScheduledUpdate = *input.ScheduledUpdate }
if err := h.process.WriteUserconfigFiles(s); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "write userconfig: " + err.Error()})
@@ -61,6 +69,11 @@ func (h *Handler) UpdateSettings(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
if h.scheduler != nil {
h.scheduler.Refresh()
}
c.JSON(http.StatusOK, s)
}