Skip to content

Commit

Permalink
add pre start command
Browse files Browse the repository at this point in the history
  • Loading branch information
Cormoran96 committed Mar 28, 2023
1 parent dd2dee4 commit f3b908d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Here is an example for my 1337 Telegram Bot. The Timer "calls" a script which se
```
timers:
1337TelegramBot:
timer_precommand: /bin/bash -c '! /usr/bin/systemctl is-active --quiet other-service.service'
timer_command: /home/telegrambot/sendMessage.pl
timer_user: telegrambot
timer_OnCalendar: "*-*-* 13:37:00 CET"
Expand All @@ -26,6 +27,7 @@ That's all the magic.

| Variable | Required | Default value / Explanation |
|----------|----------|------------------------------|
| timer_precommand | no | Pre-command before command |
| timer_command | yes | Which command or script to execute |
| timer_user | no | Under which users the timer_command is executed. Default: root |
| timer_persistent | no | Takes a boolean argument. If true, the time when the service unit was last triggered is stored on disk. When the timer is activated, the service unit is triggered immediately if it would have been triggered at least once during the time when the timer was inactive. This is useful to catch up on missed runs of the service when the machine was off. Note that this setting only has an effect on timers configured with OnCalendar=. Defaults to false. [Source](https://www.freedesktop.org/software/systemd/man/systemd.timer.html) |
Expand Down
3 changes: 3 additions & 0 deletions templates/service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Description={{ item.key }} Service

[Service]
Type=oneshot
{% if item.value.timer_precommand is defined %}
ExecStartPre={{ item.value.timer_precommand }}
{% endif %}
ExecStart={{ item.value.timer_command }}
{% if item.value.timer_user is defined %}
User={{ item.value.timer_user }}
Expand Down

0 comments on commit f3b908d

Please sign in to comment.