Both are official packages already on both workstations, started once by dex from an XDG autostart entry (the client's own, the package's). The modules declare the package, add no second start, own none of the apps' files, and give the mesh status, log, restart and check.
82 lines
3.3 KiB
Go
82 lines
3.3 KiB
Go
// The nextcloud-client module's Go tools bundle (novox/hq ADR 0188, ADR 0193, ADR 0208): the
|
|
// Nextcloud desktop sync client in the operator's session, served by the node's runtime as the
|
|
// operator account. The module holds no seat, so every tool is its own.
|
|
//
|
|
// The client's account configuration is the operator's: the tools read the client's own files and
|
|
// never write them, and no answer carries the server's address, the account's ids or a credential.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
|
)
|
|
|
|
func main() {
|
|
if err := stdio.Serve("", tools()); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
var machine = NewMachine()
|
|
|
|
func tools() []stdio.Tool {
|
|
return []stdio.Tool{
|
|
{
|
|
Name: "nextcloud_status",
|
|
Description: "The Nextcloud desktop client: whether it runs (pid, since, and the unit or session scope " +
|
|
"it runs in), the installed version, what starts it at login, each account by name (never the " +
|
|
"server's address or a credential) with its sync folders' local paths, remote paths, paused, and " +
|
|
"the last sync run (started, finished, items, errors and the first failing files), and the latest " +
|
|
"warnings in the client's log. (r)",
|
|
Run: func(map[string]any) (any, error) { return machine.Status() },
|
|
},
|
|
{
|
|
Name: "nextcloud_log",
|
|
Description: "The last lines of the client's log (source client, the default) or of the sync runs' " +
|
|
"log (source sync, file by file), newest last. With problems, only warnings and worse. The " +
|
|
"server's address and the account's ids are replaced by <server> and <account>. (r)",
|
|
Input: map[string]any{
|
|
"lines": map[string]any{"type": "integer", "description": "how many lines (default 100, at most 2000)"},
|
|
"source": map[string]any{"type": "string", "enum": []string{"client", "sync"}, "description": "client (default) or sync"},
|
|
"problems": map[string]any{"type": "boolean", "description": "only warning, critical and fatal lines of the client's log (default false)"},
|
|
},
|
|
Run: func(args map[string]any) (any, error) {
|
|
n, err := whole(args, "lines", 100, 1, 2000)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
source, err := text(args, "source", false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if source == "" {
|
|
source = "client"
|
|
}
|
|
problems, err := flag(args, "problems", false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return machine.Log(source, n, problems)
|
|
},
|
|
},
|
|
{
|
|
Name: "nextcloud_restart",
|
|
Description: "End the running client (asked first, then forced after 6 s) and start it again in the " +
|
|
"operator's desktop session, in the tray, under the account's service manager. Answers the pids " +
|
|
"ended and the new one. Needs someone logged in to the desktop. (a)",
|
|
Run: func(map[string]any) (any, error) { return machine.Restart() },
|
|
},
|
|
{
|
|
Name: "nextcloud_check",
|
|
Description: "Check what the module promises: the package is installed; the client has exactly one " +
|
|
"start (its own XDG autostart entry, which the session's dex runs; no window-manager exec, no " +
|
|
"enabled user unit); it runs once in a desktop session; it has an account and its folders exist " +
|
|
"and are not paused. Answers ok and each finding with what to do. (r)",
|
|
Run: func(map[string]any) (any, error) { return machine.Check() },
|
|
},
|
|
}
|
|
}
|