xetup/internal/config/config.go
X9 Dev be7a7236df feat: Dell Command | Update step (step 11) + download link on landing page
scripts/11-dell-update.ps1:
- Detects Dell via Win32_ComputerSystem.Manufacturer (skips silently on non-Dell)
- Installs Dell.CommandUpdate.Universal via winget (silent)
- Runs dcu-cli.exe /applyUpdates -silent -reboot=disable (all categories)
- BIOS/firmware staged, completes on restart after deployment
- Exit codes 0/1/5 all treated as success

Deploy-Windows.ps1:
- Added Step 11 - Dell Command | Update (dellUpdate=true default)

internal/runner/runner.go, internal/config/config.go:
- dellUpdate step registered in AllSteps() and DefaultConfig

web/spec/index.html:
- Step 11 card with flag-done rows, sidebar link, comment-widget issue #16
- STEP_SCRIPT map updated for step-dell

web/index.html:
- Dynamic download strip: fetches latest Forgejo release via API,
  shows Download xetup.exe with version + file size
- Updated Go TUI card text (no longer "zatim ve vyvoji")

web/data/descriptions.json: regenerated (13 scripts, 80 items)

Forgejo: issue #16 created, release v0.1.0 published with xetup.exe (5.2 MB)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 10:49:15 +02:00

116 lines
2.8 KiB
Go

package config
import (
"encoding/json"
"os"
"path/filepath"
)
// Config mirrors config.json structure.
type Config struct {
Deployment Deployment `json:"deployment"`
AdminAccount AdminAccount `json:"adminAccount"`
Activation Activation `json:"activation"`
Software Software `json:"software"`
Steps map[string]bool `json:"steps"`
}
type Deployment struct {
PCName string `json:"pcName"`
PCDescription string `json:"pcDescription"`
Timezone string `json:"timezone"`
ProfileType string `json:"profileType"` // default | admin | user
}
type AdminAccount struct {
Username string `json:"username"`
}
type Activation struct {
ProductKey string `json:"productKey"`
KMSServer string `json:"kmsServer"`
}
type SoftwareItem struct {
Name string `json:"name"`
WingetID string `json:"wingetId"`
}
type Software struct {
Install []SoftwareItem `json:"install"`
}
// DefaultConfig returns a config with sensible defaults.
func DefaultConfig() Config {
return Config{
Deployment: Deployment{
Timezone: "Central Europe Standard Time",
ProfileType: "default",
},
AdminAccount: AdminAccount{
Username: "adminx9",
},
Activation: Activation{
ProductKey: "",
},
Software: Software{
Install: []SoftwareItem{
{Name: "7-Zip", WingetID: "7zip.7zip"},
{Name: "Adobe Acrobat Reader 64-bit", WingetID: "Adobe.Acrobat.Reader.64-bit"},
{Name: "OpenVPN Connect", WingetID: "OpenVPNTechnologies.OpenVPNConnect"},
},
},
Steps: map[string]bool{
"adminAccount": true,
"bloatware": true,
"software": true,
"systemRegistry": true,
"defaultProfile": true,
"personalization": true,
"scheduledTasks": true,
"backinfo": true,
"activation": true,
"dellUpdate": true,
"network": true,
"pcIdentity": true,
},
}
}
// Load reads config.json from the given path.
// If the file does not exist, returns DefaultConfig without error.
func Load(path string) (Config, error) {
cfg := DefaultConfig()
data, err := os.ReadFile(path)
if os.IsNotExist(err) {
return cfg, nil
}
if err != nil {
return cfg, err
}
if err := json.Unmarshal(data, &cfg); err != nil {
return cfg, err
}
return cfg, nil
}
// Save writes config to the given path (creates directories if needed).
func Save(cfg Config, path string) error {
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
return err
}
data, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
return err
}
return os.WriteFile(path, data, 0644)
}
// ConfigPath returns the default config.json path (next to the executable).
func ConfigPath() string {
exe, err := os.Executable()
if err != nil {
return "config.json"
}
return filepath.Join(filepath.Dir(exe), "config.json")
}