From 0dd0300a2333632b3bcc5e42326987d023f7dd66 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sat, 3 Jun 2017 20:22:59 -0400 Subject: [PATCH] look for config files in standard location on installation --- Makefile | 2 +- README.md | 13 ------------- bin/snap-sync | 5 +++-- find_snapper_config | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100755 find_snapper_config diff --git a/Makefile b/Makefile index 1bef737..0324453 100644 --- a/Makefile +++ b/Makefile @@ -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)/ diff --git a/README.md b/README.md index 2e5ca02..c133888 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/snap-sync b/bin/snap-sync index 9077ed0..fcfcf81 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -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 diff --git a/find_snapper_config b/find_snapper_config new file mode 100755 index 0000000..a04fae3 --- /dev/null +++ b/find_snapper_config @@ -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