summaryrefslogtreecommitdiff
path: root/post-install.d
diff options
context:
space:
mode:
Diffstat (limited to 'post-install.d')
-rwxr-xr-xpost-install.d/10vcs-test13
-rwxr-xr-xpost-install.d/30git-add8
-rwxr-xr-xpost-install.d/30hg-addremove8
-rwxr-xr-xpost-install.d/40git-rm12
-rwxr-xr-xpost-install.d/50vcs-commit11
-rw-r--r--post-install.d/README2
6 files changed, 54 insertions, 0 deletions
diff --git a/post-install.d/10vcs-test b/post-install.d/10vcs-test
new file mode 100755
index 0000000..ddd4448
--- /dev/null
+++ b/post-install.d/10vcs-test
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+
+not_enabled_warning() {
+ echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2
+ echo "etckeeper warning: run etckeeper init to enable it" >&2
+}
+
+if [ "$VCS" = git ] && [ ! -d .git ]; then
+ not_enabled_warning
+elif [ "$VCS" = hg ] && [ ! -d .hg ]; then
+ not_enabled_warning
+fi
diff --git a/post-install.d/30git-add b/post-install.d/30git-add
new file mode 100755
index 0000000..66d96a9
--- /dev/null
+++ b/post-install.d/30git-add
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = git ] && [ -d .git ]; then
+ if ! git add .; then
+ echo "etckeeper warning: git add failed" >&2
+ fi
+fi
diff --git a/post-install.d/30hg-addremove b/post-install.d/30hg-addremove
new file mode 100755
index 0000000..1b999bb
--- /dev/null
+++ b/post-install.d/30hg-addremove
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = hg ] && [ -d .hg ]; then
+ if ! hg addremove .; then
+ echo "etckeeper warning: hg addremove failed" >&2
+ fi
+fi
diff --git a/post-install.d/40git-rm b/post-install.d/40git-rm
new file mode 100755
index 0000000..3d5289a
--- /dev/null
+++ b/post-install.d/40git-rm
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+
+TAB=" "
+
+if [ "$VCS" = git ] && [ -d .git ]; then
+ for file in $(git ls-files --deleted); do
+ if [ ! -d "$file" ]; then
+ git rm --quiet "$file"
+ fi
+ done
+fi
diff --git a/post-install.d/50vcs-commit b/post-install.d/50vcs-commit
new file mode 100755
index 0000000..52c6c10
--- /dev/null
+++ b/post-install.d/50vcs-commit
@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+
+message="committing changes after $HIGHLEVEL_PACKAGE_MANAGER run"
+
+if [ "$VCS" = git ] && [ -d .git ]; then
+ # ignore exit code since it exits nonzero if there is nothing to do
+ git commit $GIT_COMMIT_OPTIONS -m "$message" || true
+elif [ "$VCS" = hg ] && [ -d .hg ]; then
+ hg commit $HG_COMMIT_OPTIONS -m "$message" || true
+fi
diff --git a/post-install.d/README b/post-install.d/README
new file mode 100644
index 0000000..62f4f9c
--- /dev/null
+++ b/post-install.d/README
@@ -0,0 +1,2 @@
+Files in this directory are run after packages are installed, upgraded, etc.
+They should commit changes and new files in /etc to repository.