summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
Diffstat (limited to 'init.d')
-rwxr-xr-xinit.d/10restore-metadata5
-rwxr-xr-xinit.d/20git-init6
-rwxr-xr-xinit.d/30git-perm3
-rwxr-xr-xinit.d/40git-ignore14
-rwxr-xr-xinit.d/40git-pre-commit-hook16
-rwxr-xr-xinit.d/50git-add5
-rw-r--r--init.d/README13
7 files changed, 62 insertions, 0 deletions
diff --git a/init.d/10restore-metadata b/init.d/10restore-metadata
new file mode 100755
index 0000000..fdb1f8e
--- /dev/null
+++ b/init.d/10restore-metadata
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if [ -e .metadata ]; then
+ metastore --apply
+fi
diff --git a/init.d/20git-init b/init.d/20git-init
new file mode 100755
index 0000000..69867c4
--- /dev/null
+++ b/init.d/20git-init
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if [ ! -e .git ]; then
+ git-init
+ echo "$(hostname) /etc repository" > .git/description
+fi
diff --git a/init.d/30git-perm b/init.d/30git-perm
new file mode 100755
index 0000000..564e489
--- /dev/null
+++ b/init.d/30git-perm
@@ -0,0 +1,3 @@
+#!/bin/sh
+set -e
+chmod 700 .git
diff --git a/init.d/40git-ignore b/init.d/40git-ignore
new file mode 100755
index 0000000..88866cf
--- /dev/null
+++ b/init.d/40git-ignore
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+if [ ! -e .gitignore ]; then
+ cat >.gitignore <<EOF
+*~
+
+# new and old versions of conffiles, stored by dpkg
+*.dpkg-*
+
+# mount(8) records system state here, no need to keep these in git
+blkid.tab(|.old)
+mtab
+EOF
+fi
diff --git a/init.d/40git-pre-commit-hook b/init.d/40git-pre-commit-hook
new file mode 100755
index 0000000..88eb581
--- /dev/null
+++ b/init.d/40git-pre-commit-hook
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+if [ -x .git/hooks/pre-commit ]; then
+ if ! grep -q etckeeper-pre-commit .git/hooks/pre-commit; then
+ echo "etckeeper warning: .git/hooks/pre-commit needs to be manually modifed to run etckeeper-pre-commit" >&2
+ fi
+else
+ cat >.git/hooks/pre-commit <<EOF
+#!/bin/sh
+# pre-commit hook for etckeeper. Calls etckeeper-pre-commit to store metadata
+# and do sanity checks.
+set -e
+etckeeper-pre-commit `pwd`
+EOF
+ chmod +x .git/hooks/pre-commit
+fi
diff --git a/init.d/50git-add b/init.d/50git-add
new file mode 100755
index 0000000..06504b4
--- /dev/null
+++ b/init.d/50git-add
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if ! git-add .; then
+ echo "etckeeper warning: git-add failed" >&2
+fi
diff --git a/init.d/README b/init.d/README
new file mode 100644
index 0000000..90aec67
--- /dev/null
+++ b/init.d/README
@@ -0,0 +1,13 @@
+Executable files in this directory are run to initialise the working directory
+for use by etckeeper. If the working directory is not already in version
+control, that includes setting up the version control, but not actually
+committing anything. If the working directory is in version control,
+it includes applying stored metadata to the checked out files in the
+working directory.
+
+Please be careful to *never* overwrite existing files/directories
+in the working directory (or use absolute care when doing so). If a file
+you need to write already exists, check if its contents are sane, and
+if not, emit a warning on stderr.
+
+If initialisation fails, exit nonzero and no later files will be run.