Skip to content

Commit

Permalink
Added systemd templates to deb/rpm packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jkellerer committed Sep 29, 2021
1 parent 4740db7 commit 0f1bbb3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ nfpms:
- { type: config, src: contrib/posix/conf.d/repository.conf, dst: /etc/resticprofile/conf.d/repository.conf.dist }
- { type: config, src: contrib/posix/profiles.d/fs-snapshot.yaml.sample, dst: /etc/resticprofile/profiles.d/fs-snapshot.yaml.sample }
- { type: config, src: contrib/posix/profiles.d/system.toml, dst: /etc/resticprofile/profiles.d/system.toml.dist }
- { type: config, src: contrib/posix/templates/systemd.timer.in, dst: /etc/resticprofile/templates/systemd.timer.in.dist }
- { type: config, src: contrib/posix/templates/systemd.unit.in, dst: /etc/resticprofile/templates/systemd.unit.in.dist }
- src: contrib/systemd/resticprofile-send-error.sh
dst: /usr/local/bin/resticprofile-send-error
file_info: { mode: 0640, owner: root, group: root }
3 changes: 2 additions & 1 deletion contrib/posix/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ fi

# Unwrap dist files (if target is missing)
cd "${CONFIG_PATH}"
for file in conf.d/*.dist profiles.d/*.dist ; do
for file in conf.d/*.dist profiles.d/*.dist templates/*.dist ; do
target_file="$(dirname "${file}")/$(basename -s ".dist" "${file}")"
if [ -e "${target_file}" ] ; then
echo "Skipping ${target_file}. File already exists"
rm "${file}"
else
mv -f "${file}" "${target_file}"
fi
Expand Down
4 changes: 4 additions & 0 deletions contrib/posix/profiles.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ priority = "low"
# scheduler to use: "systemd" (default) or "crond"
#scheduler = "systemd"

# systemd unit & timer template
systemd-unit-template = "templates/systemd.unit.in"
systemd-timer-template = "templates/systemd.timer.in"

# what to run when no command is specified
default-command = "snapshots"

Expand Down
17 changes: 17 additions & 0 deletions contrib/posix/templates/systemd.timer.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{/*
# Template for generating systemd timers
# Used to schedule commands when "scheduler=systemd" (default)
*/}}

[Unit]
Description={{ .TimerDescription }}

[Timer]
{{ range .OnCalendar -}}
OnCalendar={{ . }}
{{ end -}}
Unit={{ .SystemdProfile }}
Persistent=true

[Install]
WantedBy=timers.target
19 changes: 19 additions & 0 deletions contrib/posix/templates/systemd.unit.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{/*
# Template for generating systemd units
# Used to schedule commands when "scheduler=systemd" (default)
*/}}

[Unit]
Description={{ .JobDescription }}

# Send mail when resticprofile fails (requires "unit-status-mail")
#OnFailure=unit-status-mail@%n.service

[Service]
Type=notify
WorkingDirectory={{ .WorkingDirectory }}
ExecStart={{ .CommandLine }}
{{ if .Nice }}Nice={{ .Nice }}{{ end }}
{{ range .Environment -}}
Environment="{{ . }}"
{{ end -}}

0 comments on commit 0f1bbb3

Please sign in to comment.