Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dag/extdeps/systemd/systemctl.dag
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ fn systemctl_disable_now_argv(unit: NonEmptyStr) -> List<String> {
["systemctl", "disable", "--now", unit as String]
}

fn systemctl_stop_argv(unit: NonEmptyStr) -> List<String> {
["systemctl", "stop", unit as String]
}

fn systemctl_set_property_argv(unit: NonEmptyStr, property: NonEmptyStr, value: NonEmptyStr) -> List<String> {
[
"systemctl",
Expand Down Expand Up @@ -132,6 +136,23 @@ service systemd.Systemctl {
}
}

operation Stop {
input { unit: NonEmptyStr }
output {
success: Bool from "exit_success"
stdout: String from "stdout"
stderr: String from "stderr"
}
transport shell { argv: ["systemctl", "stop", "{unit}"] }
exit {
0 => Unit
nonzero => String "systemctl stop failed"
}
mock_response {
0 => { success: true, stdout: "", stderr: "" } "hermetic systemd.Systemctl.Stop"
}
}

operation SetProperty {
input { unit: NonEmptyStr, property: NonEmptyStr, value: NonEmptyStr }
output {
Expand Down Expand Up @@ -190,6 +211,9 @@ service systemd.Systemctl {
3 => Unit "unit is not active"
nonzero => String "systemctl is-active failed"
}
mock_response {
0 => { state: "active", active: true } "hermetic systemd.Systemctl.IsActive active"
}
}

operation ShowProperty {
Expand Down
42 changes: 42 additions & 0 deletions dag/extdeps/systemd/systemd_run.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module extdeps.systemd.systemd_run

import std.types { NonEmptyStr, String, List, Bool }

import extdeps.external_authority { ExternalAuthority }
import extdeps.uri { Uri, Https }

data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority {
uri: Uri {
scheme: Https
locator: "www.freedesktop.org/software/systemd/man/latest/systemd-run.html"
}
}

data systemd_run_authority: ExternalAuthority = extdeps_external_authority_anchor

fn systemd_run_transient_unit_argv(unit: NonEmptyStr, command_argv: List<String>) -> List<String> {
fold(
command_argv,
init: ["systemd-run", concat("--unit=", unit as String), "--collect", "--"],
f: (acc, arg) => list_push(acc, arg),
)
}

service systemd.SystemdRun {
operation RunTransient {
input { unit: NonEmptyStr, command_argv: List<String> }
output {
success: Bool from "exit_success"
stdout: String from "stdout"
stderr: String from "stderr"
}
transport shell { argv: ["systemd-run", "--unit={unit}", "--collect", "--", command_argv] }
exit {
0 => Unit
nonzero => String "systemd-run transient unit start failed"
}
mock_response {
0 => { success: true, stdout: "Running as unit: demo.service", stderr: "" } "hermetic systemd.SystemdRun.RunTransient"
}
}
}
Loading