summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2008-12-27 14:31:47 -0500
committerJoey Hess <joey@gnu.kitenet.net>2008-12-27 14:31:47 -0500
commit82b8b65128ee45da3cc284623fa6e250509e8adc (patch)
tree50d3a354752613210e1ec71215e652e0d1c03130 /init.d
parent6325e8bad3997a5860911b8ccb6b57065c0b5ed3 (diff)
Make .etckeeper test that files actually exist before acting on them. Closes: #509888
Diffstat (limited to 'init.d')
-rwxr-xr-xinit.d/20restore-etckeeper11
1 files changed, 11 insertions, 0 deletions
diff --git a/init.d/20restore-etckeeper b/init.d/20restore-etckeeper
index 984d521..69cbc3d 100755
--- a/init.d/20restore-etckeeper
+++ b/init.d/20restore-etckeeper
@@ -1,6 +1,17 @@
#!/bin/sh
set -e
+# Used by .etckeeper to run a command if the file it acts on
+# (the last parameter) exists.
+maybe () {
+ command="$1"
+ shift 1
+
+ if [ -e "$(eval echo \$$#)" ]; then
+ "$command" "$@"
+ fi
+}
+
# Yes, this runs code from the repository. As documented, etckeeper-init
# should only be run on repositories you trust.
if [ -e .etckeeper ]; then