Skip to content

Commit 4b816e9

Browse files
committed
nfpms config for linux packages (apk,deb,rpm)
1 parent d05f5cc commit 4b816e9

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

.goreleaser.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,41 @@ brews:
125125
system "#{bin}/resticprofile", "backup", "testfile"
126126
system "#{bin}/resticprofile", "restore", "latest", "-t", "#{testpath}/restore"
127127
assert compare_file "testfile", "#{testpath}/restore/testfile"
128+
129+
nfpms:
130+
-
131+
builds:
132+
- resticprofile_targz
133+
formats:
134+
- apk
135+
- deb
136+
- rpm
137+
vendor: "creativeprojects"
138+
homepage: "https://github.com/creativeprojects"
139+
maintainer: "fred@creativeprojects.tech"
140+
description: "Configuration profiles for restic backup"
141+
license: "GPL-3.0-only"
142+
file_name_template: "{{.ProjectName}}_{{.Version}}-{{.Arch}}"
143+
replacements:
144+
amd64: 64bit
145+
386: 32bit
146+
arm: ARM
147+
arm64: ARM64
148+
linux: Linux
149+
dependencies:
150+
- restic
151+
bindir: "/usr/local/bin"
152+
scripts:
153+
postinstall: "contrib/posix/post-install.sh"
154+
contents:
155+
- { type: config, src: contrib/posix/profiles.conf, dst: /etc/resticprofile/profiles.conf.dist }
156+
- { type: config, src: contrib/posix/conf.d/check.conf, dst: /etc/resticprofile/conf.d/check.conf.dist }
157+
- { type: config, src: contrib/posix/conf.d/hooks.conf, dst: /etc/resticprofile/conf.d/hooks.conf.dist }
158+
- { type: config, src: contrib/posix/conf.d/metrics.conf, dst: /etc/resticprofile/conf.d/metrics.conf.dist }
159+
- { type: config, src: contrib/posix/conf.d/prune.conf, dst: /etc/resticprofile/conf.d/prune.conf.dist }
160+
- { type: config, src: contrib/posix/conf.d/repository.conf, dst: /etc/resticprofile/conf.d/repository.conf.dist }
161+
- { type: config, src: contrib/posix/profiles.d/fs-snapshot.yaml.sample, dst: /etc/resticprofile/profiles.d/fs-snapshot.yaml.sample }
162+
- { type: config, src: contrib/posix/profiles.d/system.toml, dst: /etc/resticprofile/profiles.d/system.toml.dist }
163+
- src: contrib/systemd/resticprofile-send-error.sh
164+
dst: /usr/local/bin/resticprofile-send-error
165+
file_info: { mode: 0640, owner: root, group: root }

contrib/posix/post-install.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
CONFIG_PATH="/etc/resticprofile"
5+
SECRET_FILE="${CONFIG_PATH}/conf.d/default-repository.secret"
6+
7+
# Fix permissions (only root may edit and read since password
8+
# & tokens can be in any of the files)
9+
if [ -d "${CONFIG_PATH}" ] ; then
10+
chown -R root:root "${CONFIG_PATH}"
11+
chmod -R 0640 "${CONFIG_PATH}"
12+
else
13+
echo "config path (${CONFIG_PATH}) not found"
14+
exit 1
15+
fi
16+
17+
# Check installation
18+
if [ ! -e "$(which resticprofile)" ] || ! resticprofile version ; then
19+
echo "resticprofile not found or not executable"
20+
exit 1
21+
fi
22+
23+
# Generate default-repo secret (if missing)
24+
if [ ! -f "${SECRET_FILE}" ] ; then
25+
echo "Generating ${SECRET_FILE}"
26+
resticprofile random-key > "${SECRET_FILE}"
27+
fi
28+
29+
# Unwrap dist files (if target is missing)
30+
cd "${CONFIG_PATH}"
31+
for file in conf.d/*.dist profiles.d/*.dist ; do
32+
target_file="$(dirname "${file}")/$(basename -s ".dist" "${file}")"
33+
if [ -e "${target_file}" ] ; then
34+
echo "Skipping ${target_file}. File already exists"
35+
else
36+
mv -f "${file}" "${target_file}"
37+
fi
38+
done

0 commit comments

Comments
 (0)