look for config files in standard location on installation

This commit is contained in:
James Barnett
2017-06-03 20:22:59 -04:00
parent c4654b8859
commit 0dd0300a23
4 changed files with 19 additions and 16 deletions

View File

@@ -25,6 +25,6 @@ SYSTEMD_DIR = $(DESTDIR)$(PREFIX)/lib/systemd/system
.PHONY: install
install:
@sed -i 's@^SNAPPER_CONFIG.*@SNAPPER_CONFIG='$(SNAPPER_CONFIG)'@g' bin/$(PKGNAME)
@./find_snapper_config || sed -i 's@^SNAPPER_CONFIG.*@SNAPPER_CONFIG='$(SNAPPER_CONFIG)'@g' bin/$(PKGNAME)
@install -Dm755 bin/* -t $(BIN_DIR)/
@install -Dm644 systemd/* -t $(SYSTEMD_DIR)/

View File

@@ -22,21 +22,8 @@ snapper is required.
## Installation
Run:
# make install
By default it will look for the snapper configuration file at
`/etc/sysconfig/snapper`. To change this pass `SNAPPER_CONFIG` to make
with the location of the configuration file. For example, with Ubuntu
you will want to install:
# make SNAPPER_CONFIG=/etc/default/snapper install
For Arch Linux it would be:
# make SNAPPER_CONFIG=/etc/conf.d/snapper install
The package is available in the [AUR](https://aur.archlinux.org/packages/snap-sync/).
## Options

View File

@@ -29,8 +29,9 @@ set -o errtrace
version="0.4"
name="snap-sync"
# The following line is modified by the Makefile
SNAPPER_CONFIG=/etc/conf.d/snapper
# The following line is modified by the Makefile or
# find_snapper_config script
SNAPPER_CONFIG=/etc/sysconfig/snapper
TMPDIR=$(mktemp -d)
PIPE=$TMPDIR/$name.out

15
find_snapper_config Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
etcdirs="sysconfig default conf.d"
for x in $etcdirs; do
d=/etc/$x/snapper
if [[ -f $d ]]; then
sed -i 's@^SNAPPER_CONFIG.*@SNAPPER_CONFIG='$d'@g' bin/snap-sync
exit 0
fi
done
printf "==> Unable to find snapper configuration file in a standard location.\n"
printf "==> Using SNAPPER_CONFIG make variable.\n"
exit 1