Skip to content

Commit 0f1bbb3

Browse files
committed
Added systemd templates to deb/rpm packages
1 parent 4740db7 commit 0f1bbb3

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

.goreleaser.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ nfpms:
160160
- { type: config, src: contrib/posix/conf.d/repository.conf, dst: /etc/resticprofile/conf.d/repository.conf.dist }
161161
- { type: config, src: contrib/posix/profiles.d/fs-snapshot.yaml.sample, dst: /etc/resticprofile/profiles.d/fs-snapshot.yaml.sample }
162162
- { type: config, src: contrib/posix/profiles.d/system.toml, dst: /etc/resticprofile/profiles.d/system.toml.dist }
163+
- { type: config, src: contrib/posix/templates/systemd.timer.in, dst: /etc/resticprofile/templates/systemd.timer.in.dist }
164+
- { type: config, src: contrib/posix/templates/systemd.unit.in, dst: /etc/resticprofile/templates/systemd.unit.in.dist }
163165
- src: contrib/systemd/resticprofile-send-error.sh
164166
dst: /usr/local/bin/resticprofile-send-error
165167
file_info: { mode: 0640, owner: root, group: root }

contrib/posix/post-install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ fi
2828

2929
# Unwrap dist files (if target is missing)
3030
cd "${CONFIG_PATH}"
31-
for file in conf.d/*.dist profiles.d/*.dist ; do
31+
for file in conf.d/*.dist profiles.d/*.dist templates/*.dist ; do
3232
target_file="$(dirname "${file}")/$(basename -s ".dist" "${file}")"
3333
if [ -e "${target_file}" ] ; then
3434
echo "Skipping ${target_file}. File already exists"
35+
rm "${file}"
3536
else
3637
mv -f "${file}" "${target_file}"
3738
fi

contrib/posix/profiles.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ priority = "low"
3434
# scheduler to use: "systemd" (default) or "crond"
3535
#scheduler = "systemd"
3636

37+
# systemd unit & timer template
38+
systemd-unit-template = "templates/systemd.unit.in"
39+
systemd-timer-template = "templates/systemd.timer.in"
40+
3741
# what to run when no command is specified
3842
default-command = "snapshots"
3943

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{/*
2+
# Template for generating systemd timers
3+
# Used to schedule commands when "scheduler=systemd" (default)
4+
*/}}
5+
6+
[Unit]
7+
Description={{ .TimerDescription }}
8+
9+
[Timer]
10+
{{ range .OnCalendar -}}
11+
OnCalendar={{ . }}
12+
{{ end -}}
13+
Unit={{ .SystemdProfile }}
14+
Persistent=true
15+
16+
[Install]
17+
WantedBy=timers.target
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{/*
2+
# Template for generating systemd units
3+
# Used to schedule commands when "scheduler=systemd" (default)
4+
*/}}
5+
6+
[Unit]
7+
Description={{ .JobDescription }}
8+
9+
# Send mail when resticprofile fails (requires "unit-status-mail")
10+
#OnFailure=unit-status-mail@%n.service
11+
12+
[Service]
13+
Type=notify
14+
WorkingDirectory={{ .WorkingDirectory }}
15+
ExecStart={{ .CommandLine }}
16+
{{ if .Nice }}Nice={{ .Nice }}{{ end }}
17+
{{ range .Environment -}}
18+
Environment="{{ . }}"
19+
{{ end -}}

0 commit comments

Comments
 (0)