summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rwxr-xr-xdaily17
-rw-r--r--debian/changelog8
-rw-r--r--debian/cron.daily15
-rwxr-xr-xetckeeper2
-rw-r--r--etckeeper.conf8
-rw-r--r--etckeeper.spec2
-rw-r--r--pacman-post-install.hook4
-rw-r--r--pacman-pre-install.hook4
-rw-r--r--systemd/etckeeper.service12
-rw-r--r--systemd/etckeeper.timer10
11 files changed, 64 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index b1154cf..eeece8b 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ build: etckeeper.spec etckeeper.version
install: etckeeper.version
mkdir -p $(DESTDIR)$(etcdir)/etckeeper/ $(DESTDIR)$(vardir)/cache/etckeeper/
$(CP) *.d $(DESTDIR)$(etcdir)/etckeeper/
+ $(INSTALL_EXE) daily $(DESTDIR)$(etcdir)/etckeeper/daily
$(INSTALL_DATA) $(CONFFILE) $(DESTDIR)$(etcdir)/etckeeper/etckeeper.conf
mkdir -p $(DESTDIR)$(bindir)
$(INSTALL_EXE) etckeeper $(DESTDIR)$(bindir)/etckeeper
@@ -30,6 +31,9 @@ install: etckeeper.version
$(INSTALL_DATA) etckeeper.8 $(DESTDIR)$(mandir)/man8/etckeeper.8
mkdir -p $(DESTDIR)$(completiondir)
$(INSTALL_DATA) bash_completion $(DESTDIR)$(completiondir)/etckeeper
+ mkdir -p $(DESTDIR)$(prefix)/lib/systemd/system/ $(DESTDIR)$(prefix)/lib/systemd/scripts/
+ $(INSTALL_DATA) systemd/etckeeper.service $(DESTDIR)$(prefix)/lib/systemd/system/etckeeper.service
+ $(INSTALL_DATA) systemd/etckeeper.timer $(DESTDIR)$(prefix)/lib/systemd/system/etckeeper.timer
ifeq ($(HIGHLEVEL_PACKAGE_MANAGER),apt)
mkdir -p $(DESTDIR)$(etcdir)/apt/apt.conf.d
$(INSTALL_DATA) apt.conf $(DESTDIR)$(etcdir)/apt/apt.conf.d/05etckeeper
@@ -39,7 +43,7 @@ endif
ifeq ($(LOWLEVEL_PACKAGE_MANAGER),pacman)
mkdir -p $(DESTDIR)$(prefix)/share/libalpm/hooks
$(INSTALL_DATA) ./pacman-pre-install.hook $(DESTDIR)$(prefix)/share/libalpm/hooks/05-etckeeper-pre-install.hook
- $(INSTALL_DATA) ./pacman-post-install.hook $(DESTDIR)$(prefix)/share/libalpm/hooks/95-etckeeper-post-install.hook
+ $(INSTALL_DATA) ./pacman-post-install.hook $(DESTDIR)$(prefix)/share/libalpm/hooks/zz-etckeeper-post-install.hook
endif
ifeq ($(LOWLEVEL_PACKAGE_MANAGER),pacman-g2)
mkdir -p $(DESTDIR)$(etcdir)/pacman-g2/hooks
diff --git a/daily b/daily
new file mode 100755
index 0000000..f98c6ad
--- /dev/null
+++ b/daily
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Script that can be run daily to autocommit /etc changes.
+set -e
+if [ -x /usr/bin/etckeeper ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
+ # avoid autocommit if an install run is in progress
+ lockfile=/var/cache/etckeeper/packagelist.pre-install
+ if [ -e "$lockfile" ] && [ -n "$(find "$lockfile" -mtime +1)" ]; then
+ rm -f "$lockfile" # stale
+ fi
+ if [ ! -e "$lockfile" ]; then
+ AVOID_SPECIAL_FILE_WARNING=1
+ export AVOID_SPECIAL_FILE_WARNING
+ if etckeeper unclean; then
+ etckeeper commit "daily autocommit" >/dev/null
+ fi
+ fi
+fi
diff --git a/debian/changelog b/debian/changelog
index 5ffa2f6..ce34061 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,7 +3,13 @@ etckeeper (1.18.4) UNRELEASED; urgency=medium
* Optimised find for special and hard linked files.
Thanks, Rike-Benjamin Schuppner.
* Adjust when Pacman 5 calls etckeeper hooks.
- Thanks, Tilman Blumenbach.
+ Thanks, Tilman Blumenbach and Christian Hesse.
+ * Only run Pacman hooks when files in /etc have changed.
+ Thanks, Christian Hesse.
+ * Added systemd timer that can run etckeeper 10 minutes after boot, and also
+ daily. It's not enabled by default, partly because of overlap with the
+ cron job.
+ Thanks, Christian Hesse.
-- Joey Hess <id@joeyh.name> Mon, 29 Feb 2016 11:12:08 -0400
diff --git a/debian/cron.daily b/debian/cron.daily
index 5255691..eb74401 100644
--- a/debian/cron.daily
+++ b/debian/cron.daily
@@ -1,19 +1,8 @@
#!/bin/sh
set -e
-if [ -x /usr/bin/etckeeper ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
+if [ -e /etc/etckeeper/daily ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
. /etc/etckeeper/etckeeper.conf
if [ "$AVOID_DAILY_AUTOCOMMITS" != "1" ]; then
- # avoid autocommit if an install run is in progress
- lockfile=/var/cache/etckeeper/packagelist.pre-install
- if [ -e "$lockfile" ] && [ -n "$(find "$lockfile" -mtime +1)" ]; then
- rm -f "$lockfile" # stale
- fi
- if [ ! -e "$lockfile" ]; then
- AVOID_SPECIAL_FILE_WARNING=1
- export AVOID_SPECIAL_FILE_WARNING
- if etckeeper unclean; then
- etckeeper commit "daily autocommit" >/dev/null
- fi
- fi
+ /etc/etckeeper/daily
fi
fi
diff --git a/etckeeper b/etckeeper
index 93f2b00..70ad797 100755
--- a/etckeeper
+++ b/etckeeper
@@ -71,7 +71,7 @@ elif [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ]; then
exit 0
elif [ "x$1" = "x-v" ] || [ "x$1" = "x--version" ]; then
# This is automatically updated by the Makefile.
- echo "Version: 1.18.3"
+ echo "Version: 1.18.4"
exit 0
fi
command="$1"
diff --git a/etckeeper.conf b/etckeeper.conf
index 0d268bd..0fb660b 100644
--- a/etckeeper.conf
+++ b/etckeeper.conf
@@ -16,12 +16,14 @@ BZR_COMMIT_OPTIONS=""
# Options passed to darcs record when run by etckeeper.
DARCS_COMMIT_OPTIONS="-a"
-# Uncomment to avoid etckeeper committing existing changes
-# to /etc automatically once per day.
+# Etckeeper includes both a cron job and a systemd timer, which each
+# can commit exiting changes to /etc automatically once per day.
+# To enable the systemd timer, run: systemctl enable etckeeper.timer
+# The cron job is enabled by default; to disable it, uncomment this next line.
#AVOID_DAILY_AUTOCOMMITS=1
# Uncomment the following to avoid special file warning
-# (the option is enabled automatically by cronjob regardless).
+# (the option is enabled automatically for daily autocommits regardless).
#AVOID_SPECIAL_FILE_WARNING=1
# Uncomment to avoid etckeeper committing existing changes to
diff --git a/etckeeper.spec b/etckeeper.spec
index b1e34fd..0830064 100644
--- a/etckeeper.spec
+++ b/etckeeper.spec
@@ -1,5 +1,5 @@
Name: etckeeper
-Version: 1.18.3
+Version: 1.18.4
Release: 4%{?dist}
Summary: store /etc in git, mercurial, bzr or darcs
diff --git a/pacman-post-install.hook b/pacman-post-install.hook
index 79d1945..b0f1816 100644
--- a/pacman-post-install.hook
+++ b/pacman-post-install.hook
@@ -4,8 +4,8 @@
Operation = Install
Operation = Upgrade
Operation = Remove
-Type = Package
-Target = *
+Type = File
+Target = /etc/*
[Action]
Description = etckeeper: post-transaction commit
diff --git a/pacman-pre-install.hook b/pacman-pre-install.hook
index 5ef52eb..35bf7df 100644
--- a/pacman-pre-install.hook
+++ b/pacman-pre-install.hook
@@ -4,8 +4,8 @@
Operation = Install
Operation = Upgrade
Operation = Remove
-Type = Package
-Target = *
+Type = File
+Target = /etc/*
[Action]
Description = etckeeper: pre-transaction commit
diff --git a/systemd/etckeeper.service b/systemd/etckeeper.service
new file mode 100644
index 0000000..faf1119
--- /dev/null
+++ b/systemd/etckeeper.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Autocommit of changes in /etc directory
+Documentation=man:etckeeper(8)
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=local-fs.target time-sync.target
+Before=shutdown.target
+
+[Service]
+Type=oneshot
+ExecStart=/etc/etckeeper/daily
+IOSchedulingClass=idle
diff --git a/systemd/etckeeper.timer b/systemd/etckeeper.timer
new file mode 100644
index 0000000..364c089
--- /dev/null
+++ b/systemd/etckeeper.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Daily autocommit of changes in /etc directory
+Documentation=man:etckeeper(8)
+
+[Timer]
+OnBootSec=15min
+OnUnitActiveSec=1d
+
+[Install]
+WantedBy=multi-user.target