Skip to content

Commit

Permalink
nfpms config for linux packages (apk,deb,rpm)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkellerer committed Aug 22, 2021
1 parent d05f5cc commit 35b836b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,41 @@ brews:
system "#{bin}/resticprofile", "backup", "testfile"
system "#{bin}/resticprofile", "restore", "latest", "-t", "#{testpath}/restore"
assert compare_file "testfile", "#{testpath}/restore/testfile"
nfpms:
-
builds:
- resticprofile_targz
formats:
- apk
- deb
- rpm
vendor: "creativeprojects"
homepage: "https://github.com/creativeprojects"
maintainer: "[email protected]"
description: "Configuration profiles for restic backup"
license: "GPL-3.0-only"
file_name_template: "{{.ProjectName}}_{{.Version}}-{{.Arch}}"
replacements:
amd64: 64bit
386: 32bit
arm: ARM
arm64: ARM64
linux: Linux
dependencies:
- restic
bindir: "/usr/local/bin"
scripts:
postinstall: "contrib/posix/post-install.sh"
contents:
- { type: config, src: contrib/posix/profiles.conf, dst: /etc/resticprofile/profiles.conf.dist }
- { type: config, src: contrib/posix/conf.d/check.conf, dst: /etc/resticprofile/conf.d/check.conf.dist }
- { type: config, src: contrib/posix/conf.d/hooks.conf, dst: /etc/resticprofile/conf.d/hooks.conf.dist }
- { type: config, src: contrib/posix/conf.d/metrics.conf, dst: /etc/resticprofile/conf.d/metrics.conf.dist }
- { type: config, src: contrib/posix/conf.d/prune.conf, dst: /etc/resticprofile/conf.d/prune.conf.dist }
- { 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 }
- src: contrib/systemd/resticprofile-send-error.sh
dst: /usr/local/bin/resticprofile-send-error
file_info: { mode: 0640, owner: root, group: root }
38 changes: 38 additions & 0 deletions contrib/posix/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env sh
set -e

CONFIG_PATH="/etc/resticprofile"
SECRET_FILE="${CONFIG_PATH}/conf.d/default-repository.secret"

# Fix permissions (only root may edit and read since password
# & tokens can be in any of the files)
if [ -d "${CONFIG_PATH}" ] ; then
chown -R root:root "${CONFIG_PATH}"
chmod -R 0640 "${CONFIG_PATH}"
else
echo "config path (${CONFIG_PATH}) not found"
exit 1
fi

# Check installation
if [ ! -e "$(which resticprofile)" ] || ! resticprofile version ; then
echo "resticprofile not found or not executable"
exit 1
fi

# Generate default-repo secret (if missing)
if [ ! -f "${SECRET_FILE}" ] ; then
echo "Generating ${SECRET_FILE}"
resticprofile random-key > "${SECRET_FILE}"
fi

# Unwrap dist files (if target is missing)
cd "${CONFIG_PATH}"
for file in conf.d/*.dist profiles.d/*.dist ; do
target_file="$(dirname "${file}")/$(basename -s ".dist" "${file}")"
if [ -e "${target_file}" ] ; then
echo "Skipping ${target_file}. File already exists"
else
mv -f "${file}" "${target_file}"
fi
done
2 changes: 1 addition & 1 deletion contrib/posix/profiles.conf
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ inherit = "default"
[base.mount]
# Copying "host" and "tags" block to identify snapshots to mount
{{template "conf:default-backup-host" .}}
{{template "conf:default-backup-tags" .}}
{{template "conf:default-backup-tags" .}}

0 comments on commit 35b836b

Please sign in to comment.