Skip to content

Commit

Permalink
make the user configurable a systemd timer runs as
Browse files Browse the repository at this point in the history
  • Loading branch information
zagy committed Aug 16, 2023
1 parent a4b82e0 commit 0f5ebfa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/batou_ext/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,19 @@ class SystemdTimer(batou.component.Component):
"""

_required_params_ = {"command": "/bin/true", "onCalendar": "*/4 * * * * "}
_required_params_ = {"command": "/bin/true", "onCalendar": "02:00:00"}

namevar = "tag"
command = batou.component.Attribute(str)
onCalendar = batou.component.Attribute(str)
timeout = "1h"
description = None
run_as = batou.component.Attribute(
str,
default=batou.component.ConfigString(
"{{component.environment.service_user}}"
),
)

def configure(self):
if self.description is None:
Expand Down Expand Up @@ -177,7 +183,7 @@ def configure(self):
description = "{{component.description}}";
serviceConfig = {
Type = "oneshot";
User = "{{component.environment.service_user}}";
User = "{{component.run_as}}";
ExecStart = "{{component.wrapped_command}}";
TimeoutStartSec = "{{component.timeout}}";
};
Expand Down

0 comments on commit 0f5ebfa

Please sign in to comment.