Compare commits
4
Commits
0c779bc970
..
v0.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b91a8a2a7 | ||
|
|
e41ffa6a14 | ||
|
|
5e7d693699 | ||
|
|
a913baa496 |
No files matched your search
@@ -6,6 +6,7 @@
|
|||||||
# Go build artifacts
|
# Go build artifacts
|
||||||
agent-lib
|
agent-lib
|
||||||
agent-lib.exe
|
agent-lib.exe
|
||||||
|
agent-libw.exe
|
||||||
dist/
|
dist/
|
||||||
*.test
|
*.test
|
||||||
*.out
|
*.out
|
||||||
|
|||||||
+29
-9
@@ -3,10 +3,21 @@ version: 2
|
|||||||
project_name: agent-lib
|
project_name: agent-lib
|
||||||
|
|
||||||
# Releases gehen an die eigene Gitea-Instanz (NICHT GitHub):
|
# Releases gehen an die eigene Gitea-Instanz (NICHT GitHub):
|
||||||
# GITEA_URL=https://code.m3ta.dev
|
# GITEA_TOKEN=<token mit repository-write> als Umgebungsvariable
|
||||||
# GITEA_TOKEN=<token mit repository-write>
|
# Owner/Name sind explizit gesetzt, weil das SCP-Stil-Remote
|
||||||
# Repo/Owner werden aus dem origin-Remote abgeleitet
|
# (gitea@code.m3ta.dev:m3tam3re/agent-lib.git) fuer die automatische
|
||||||
# (gitea@code.m3ta.dev:m3tam3re/agent-lib.git).
|
# Ableitung unzuverlaessig ist.
|
||||||
|
gitea_urls:
|
||||||
|
api: https://code.m3ta.dev/api/v1
|
||||||
|
download: https://code.m3ta.dev
|
||||||
|
|
||||||
|
release:
|
||||||
|
draft: false
|
||||||
|
prerelease: auto
|
||||||
|
mode: append
|
||||||
|
gitea:
|
||||||
|
owner: m3tam3re
|
||||||
|
name: agent-lib
|
||||||
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
@@ -29,6 +40,18 @@ builds:
|
|||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X github.com/m3tam3re/agent-lib/internal/version.Version={{.Version}}
|
- -s -w -X github.com/m3tam3re/agent-lib/internal/version.Version={{.Version}}
|
||||||
binary: agent-lib
|
binary: agent-lib
|
||||||
|
# GUI-Subsystem-Variante fuer die Aufgabenplanung: oeffnet kein
|
||||||
|
# Konsolenfenster, dafuer auch keine Ausgabe auf stdout/stderr.
|
||||||
|
- id: agent-libw
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- windows
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
ldflags:
|
||||||
|
- -s -w -H=windowsgui -X github.com/m3tam3re/agent-lib/internal/version.Version={{.Version}}
|
||||||
|
binary: agent-libw
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: "checksums.txt"
|
name_template: "checksums.txt"
|
||||||
@@ -42,11 +65,8 @@ archives:
|
|||||||
# Explizit stabil, damit Fleet-Download-URLs vorhersehbar bleiben:
|
# Explizit stabil, damit Fleet-Download-URLs vorhersehbar bleiben:
|
||||||
# .../releases/download/<tag>/agent-lib_<os>_<arch>.<ext>
|
# .../releases/download/<tag>/agent-lib_<os>_<arch>.<ext>
|
||||||
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
|
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
|
||||||
|
# Das Windows-Zip enthaelt zusaetzlich agent-libw.exe.
|
||||||
release:
|
allow_different_binary_count: true
|
||||||
draft: false
|
|
||||||
prerelease: auto
|
|
||||||
mode: append
|
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
sort: asc
|
sort: asc
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ flag that drives the non-zero exit code — suitable for headless drift checks.
|
|||||||
| `status` exits 1 | Local modifications block repository updates (or occupy names the repo needs). See `status` output for the item list. |
|
| `status` exits 1 | Local modifications block repository updates (or occupy names the repo needs). See `status` output for the item list. |
|
||||||
| Sync fails with clone/fetch error | Work repository unreachable, or token expired. Previous local state remains intact; fix config/network and re-run. |
|
| Sync fails with clone/fetch error | Work repository unreachable, or token expired. Previous local state remains intact; fix config/network and re-run. |
|
||||||
| No toast on Windows | Toasts need an interactive user session — the scheduled task must run as the logged-in user, not SYSTEM. |
|
| No toast on Windows | Toasts need an interactive user session — the scheduled task must run as the logged-in user, not SYSTEM. |
|
||||||
|
| Terminal window flashes on scheduled sync (Windows) | The task runs the console program `agent-lib.exe`. Point it at `agent-libw.exe sync` from the same zip: same commands, no window, no output. |
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -27,7 +27,8 @@ the external areas).
|
|||||||
|
|
||||||
- Source of truth: GitHub releases of `m3tam3re/agent-lib`.
|
- Source of truth: GitHub releases of `m3tam3re/agent-lib`.
|
||||||
- Artifacts: `agent-lib_{windows_amd64,linux_amd64,linux_arm64,darwin_amd64,darwin_arm64}`
|
- Artifacts: `agent-lib_{windows_amd64,linux_amd64,linux_arm64,darwin_amd64,darwin_arm64}`
|
||||||
plus `checksums.txt` (tar.gz archives; windows is a zip).
|
plus `checksums.txt` (tar.gz archives; windows is a zip containing
|
||||||
|
`agent-lib.exe` and the windowless `agent-libw.exe`).
|
||||||
- Fleet pins an exact release tag (installer-pin pattern already used for
|
- Fleet pins an exact release tag (installer-pin pattern already used for
|
||||||
other tools). **No self-update exists in the binary** — binary updates are
|
other tools). **No self-update exists in the binary** — binary updates are
|
||||||
exclusively fleet rollouts. Content updates are pulled by the binary itself.
|
exclusively fleet rollouts. Content updates are pulled by the binary itself.
|
||||||
@@ -68,6 +69,12 @@ Local state (manifest, cached bare repo, sync log) lives per-user:
|
|||||||
against the user's profile.
|
against the user's profile.
|
||||||
2. Windows toast notifications require an interactive user session. A task
|
2. Windows toast notifications require an interactive user session. A task
|
||||||
running as SYSTEM produces no visible toasts.
|
running as SYSTEM produces no visible toasts.
|
||||||
|
- On Windows, the task action must run `agent-libw.exe sync`, not
|
||||||
|
`agent-lib.exe sync`. `agent-lib.exe` is a console program, so Windows opens
|
||||||
|
a terminal window for it on every run. `agent-libw.exe` is the same program
|
||||||
|
without a console. It prints nothing, so check the task's last run result
|
||||||
|
(`0` = success, `1` = failed), and run `agent-lib.exe sync` by hand to see
|
||||||
|
the error.
|
||||||
- Suggested cadence: every 1–4 hours plus/except at logon. Sync is idempotent
|
- Suggested cadence: every 1–4 hours plus/except at logon. Sync is idempotent
|
||||||
and cheap when unchanged.
|
and cheap when unchanged.
|
||||||
- Optional companion: a drift check running `agent-lib status --json`
|
- Optional companion: a drift check running `agent-lib status --json`
|
||||||
@@ -132,6 +139,8 @@ Local state (manifest, cached bare repo, sync log) lives per-user:
|
|||||||
admins; token present.
|
admins; token present.
|
||||||
- [ ] Scheduled task runs as the logged-in user; toast appears when a
|
- [ ] Scheduled task runs as the logged-in user; toast appears when a
|
||||||
modified item is skipped (manual visual check on a Windows client).
|
modified item is skipped (manual visual check on a Windows client).
|
||||||
|
- [ ] Windows task action uses `agent-libw.exe`; no terminal window appears
|
||||||
|
when the task runs.
|
||||||
- [ ] `agent-lib status` exits 0 on a clean machine, non-zero after editing a
|
- [ ] `agent-lib status` exits 0 on a clean machine, non-zero after editing a
|
||||||
deployed file (self-test).
|
deployed file (self-test).
|
||||||
- [ ] Drift monitoring consumes `status --json` → `problematic_drift`.
|
- [ ] Drift monitoring consumes `status --json` → `problematic_drift`.
|
||||||
@@ -6,8 +6,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// createNoWindow is the Win32 CREATE_NO_WINDOW process creation flag.
|
||||||
|
const createNoWindow = 0x08000000
|
||||||
|
|
||||||
// PowerShellToast raises a Windows toast notification by invoking
|
// PowerShellToast raises a Windows toast notification by invoking
|
||||||
// PowerShell with an AppId-tagged script — the same mechanism go-toast
|
// PowerShell with an AppId-tagged script — the same mechanism go-toast
|
||||||
// uses, without the dependency.
|
// uses, without the dependency.
|
||||||
@@ -36,6 +40,8 @@ func (p PowerShellToast) Send(title, body string) error {
|
|||||||
}
|
}
|
||||||
script := fmt.Sprintf(toastScript, escape(appID), escape(title), escape(body))
|
script := fmt.Sprintf(toastScript, escape(appID), escape(title), escape(body))
|
||||||
cmd := exec.Command("powershell", "-NoProfile", "-NonInteractive", "-Command", script)
|
cmd := exec.Command("powershell", "-NoProfile", "-NonInteractive", "-Command", script)
|
||||||
|
// agent-libw has no console to inherit, so PowerShell would open its own.
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: createNoWindow}
|
||||||
if out, err := cmd.CombinedOutput(); err != nil {
|
if out, err := cmd.CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("toast failed: %v: %s", err, strings.TrimSpace(string(out)))
|
return fmt.Errorf("toast failed: %v: %s", err, strings.TrimSpace(string(out)))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user