1 use serde
::{Serialize, Deserialize}
;
4 use pbs_api_types
::SINGLE_LINE_COMMENT_FORMAT
;
6 pub const SYSTEMD_SECTION_NAME_SCHEMA
: Schema
= StringSchema
::new(
8 .format(&ApiStringFormat
::Enum(&[
9 EnumEntry
::new("Unit", "Unit"),
10 EnumEntry
::new("Timer", "Timer"),
11 EnumEntry
::new("Install", "Install"),
12 EnumEntry
::new("Mount", "Mount"),
13 EnumEntry
::new("Service", "Service")]))
16 pub const SYSTEMD_STRING_SCHEMA
: Schema
=
17 StringSchema
::new("Systemd configuration value.")
18 .format(&SINGLE_LINE_COMMENT_FORMAT
)
21 pub const SYSTEMD_STRING_ARRAY_SCHEMA
: Schema
= ArraySchema
::new(
22 "Array of Strings", &SYSTEMD_STRING_SCHEMA
)
25 pub const SYSTEMD_TIMESPAN_ARRAY_SCHEMA
: Schema
= ArraySchema
::new(
26 "Array of time spans", &SYSTEMD_TIMESPAN_SCHEMA
)
29 pub const SYSTEMD_CALENDAR_EVENT_ARRAY_SCHEMA
: Schema
= ArraySchema
::new(
30 "Array of calendar events", &SYSTEMD_CALENDAR_EVENT_SCHEMA
)
36 schema
: SYSTEMD_CALENDAR_EVENT_ARRAY_SCHEMA
,
40 schema
: SYSTEMD_TIMESPAN_ARRAY_SCHEMA
,
44 schema
: SYSTEMD_TIMESPAN_ARRAY_SCHEMA
,
48 schema
: SYSTEMD_TIMESPAN_ARRAY_SCHEMA
,
52 schema
: SYSTEMD_TIMESPAN_ARRAY_SCHEMA
,
55 "OnUnitInactiveSec": {
56 schema
: SYSTEMD_TIMESPAN_ARRAY_SCHEMA
,
59 "RandomizedDelaySec": {
60 schema
: SYSTEMD_TIMESPAN_SCHEMA
,
64 schema
: SYSTEMD_TIMESPAN_SCHEMA
,
69 #[derive(Serialize, Deserialize, Default)]
70 #[allow(non_snake_case)]
71 /// Systemd Timer Section
72 pub struct SystemdTimerSection
{
73 #[serde(skip_serializing_if="Option::is_none")]
74 pub OnCalendar
: Option
<Vec
<String
>>,
75 /// If true, the time when the service unit was last triggered is stored on disk.
76 #[serde(skip_serializing_if="Option::is_none")]
77 pub Persistent
: Option
<bool
>,
78 #[serde(skip_serializing_if="Option::is_none")]
79 pub OnActiveSec
: Option
<Vec
<String
>>,
80 #[serde(skip_serializing_if="Option::is_none")]
81 pub OnBootSec
: Option
<Vec
<String
>>,
82 #[serde(skip_serializing_if="Option::is_none")]
83 pub OnStartupSec
: Option
<Vec
<String
>>,
84 #[serde(skip_serializing_if="Option::is_none")]
85 pub OnUnitActiveSec
: Option
<Vec
<String
>>,
86 #[serde(skip_serializing_if="Option::is_none")]
87 pub OnUnitInactiveSec
: Option
<Vec
<String
>>,
88 #[serde(skip_serializing_if="Option::is_none")]
89 pub RandomizedDelaySec
: Option
<String
>,
90 #[serde(skip_serializing_if="Option::is_none")]
91 pub AccuracySec
: Option
<String
>,
93 /// Trigger when system clock jumps.
94 #[serde(skip_serializing_if="Option::is_none")]
95 pub OnClockChange
: Option
<bool
>,
97 /// Trigger when time zone changes.
98 #[serde(skip_serializing_if="Option::is_none")]
99 pub OnTimezomeChange
: Option
<bool
>,
101 /// The unit to activate when this timer elapses.
102 #[serde(skip_serializing_if="Option::is_none")]
103 pub Unit
: Option
<String
>,
105 /// If true, an elapsing timer will cause the system to resume from suspend.
106 #[serde(skip_serializing_if="Option::is_none")]
107 pub WakeSystem
: Option
<bool
>,
109 /// If true, an elapsed timer will stay loaded, and its state remains queryable.
110 #[serde(skip_serializing_if="Option::is_none")]
111 pub RemainAfterElapse
: Option
<bool
>,
117 type: ServiceStartup
,
121 schema
: SYSTEMD_STRING_ARRAY_SCHEMA
,
126 #[derive(Serialize, Deserialize, Default)]
127 #[allow(non_snake_case)]
128 /// Systemd Service Section
129 pub struct SystemdServiceSection
{
130 /// The process start-up type for this service unit.
131 #[serde(skip_serializing_if="Option::is_none")]
132 pub Type
: Option
<ServiceStartup
>,
133 #[serde(skip_serializing_if="Option::is_none")]
134 pub ExecStart
: Option
<Vec
<String
>>,
138 #[derive(Serialize, Deserialize, Default)]
139 #[allow(non_snake_case)]
140 /// Systemd Unit Section
141 pub struct SystemdUnitSection
{
142 /// A human readable name for the unit.
143 pub Description
: String
,
144 /// Check whether the system has AC power.
145 #[serde(skip_serializing_if="Option::is_none")]
146 pub ConditionACPower
: Option
<bool
>,
152 schema
: SYSTEMD_STRING_ARRAY_SCHEMA
,
156 schema
: SYSTEMD_STRING_ARRAY_SCHEMA
,
163 schema
: SYSTEMD_STRING_ARRAY_SCHEMA
,
167 schema
: SYSTEMD_STRING_ARRAY_SCHEMA
,
172 #[derive(Serialize, Deserialize, Default)]
173 #[allow(non_snake_case)]
174 /// Systemd Install Section
175 pub struct SystemdInstallSection
{
176 #[serde(skip_serializing_if="Option::is_none")]
177 pub Alias
: Option
<Vec
<String
>>,
178 #[serde(skip_serializing_if="Option::is_none")]
179 pub Also
: Option
<Vec
<String
>>,
180 /// DefaultInstance for template unit.
181 #[serde(skip_serializing_if="Option::is_none")]
182 pub DefaultInstance
: Option
<String
>,
183 #[serde(skip_serializing_if="Option::is_none")]
184 pub WantedBy
: Option
<Vec
<String
>>,
185 #[serde(skip_serializing_if="Option::is_none")]
186 pub RequiredBy
: Option
<Vec
<String
>>,
192 schema
: SYSTEMD_TIMESPAN_ARRAY_SCHEMA
,
197 #[derive(Serialize, Deserialize, Default)]
198 #[allow(non_snake_case)]
199 /// Systemd Service Section
200 pub struct SystemdMountSection
{
201 /// absolute path of a device node, file or other resource to mount
203 /// absolute path of a file or directory for the mount point
205 /// Takes a string for the file system type. See mount(8) for details.
206 #[serde(skip_serializing_if="Option::is_none")]
207 pub Type
: Option
<String
>,
208 /// Mount options to use when mounting. This takes a comma-separated list of options.
209 #[serde(skip_serializing_if="Option::is_none")]
210 pub Options
: Option
<String
>,
211 /// If true, parsing of the options specified in Options= is relaxed, and unknown mount options are tolerated.
212 #[serde(skip_serializing_if="Option::is_none")]
213 pub SloppyOptions
: Option
<bool
>,
215 #[serde(skip_serializing_if="Option::is_none")]
216 pub LazyUnmount
: Option
<bool
>,
217 /// Use forces unmount
218 #[serde(skip_serializing_if="Option::is_none")]
219 pub ForceUnmount
: Option
<bool
>,
220 /// Directories of mount points (and any parent directories) are
221 /// automatically created if needed. Takes an access mode in octal
222 /// notation. Defaults to 0755.
223 #[serde(skip_serializing_if="Option::is_none")]
224 pub DirectoryMode
: Option
<String
>,
225 /// Configures the time to wait for the mount command to finish.
226 #[serde(skip_serializing_if="Option::is_none")]
227 pub TimeoutSec
: Option
<String
>,
231 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
232 #[serde(rename_all = "lowercase")]
233 /// Node Power command type.
234 pub enum ServiceStartup
{
237 /// Like fork, but wait until exec succeeds
241 /// Like 'simple', but consider the unit up after the process exits.
243 /// Like 'simple', but use DBUS to synchronize startup.
245 /// Like 'simple', but use sd_notify to synchronize startup.
249 pub const SYSTEMD_TIMESPAN_SCHEMA
: Schema
= StringSchema
::new(
251 .format(&ApiStringFormat
::VerifyFn(proxmox_systemd
::time
::verify_time_span
))
254 pub const SYSTEMD_CALENDAR_EVENT_SCHEMA
: Schema
= StringSchema
::new(
255 "systemd calendar event")
256 .format(&ApiStringFormat
::VerifyFn(proxmox_systemd
::time
::verify_calendar_event
))