summaryrefslogtreecommitdiff
path: root/git/init.d
diff options
context:
space:
mode:
authorMathieu Clabaut <mathieu.clabaut@gmail.com>2007-12-21 15:47:30 -0600
committerJoey Hess <joey@kodama.kitenet.net>2008-01-03 19:53:46 -0500
commitf82235032f162aae0bb08828d45c6306e60dcd29 (patch)
treea4479471b8b8c91903e1ceaf54dfea42e3457a4a /git/init.d
parent631af60701ca747861d67a19d431005c7d45d6be (diff)
hg and git subrepo creation (hg is for now a copy of git)
Diffstat (limited to 'git/init.d')
-rw-r--r--git/init.d/10restore-etckeeper8
-rw-r--r--git/init.d/20restore-metadata10
-rw-r--r--git/init.d/40git-init6
-rw-r--r--git/init.d/50git-ignore22
-rw-r--r--git/init.d/50git-perm3
-rw-r--r--git/init.d/50git-pre-commit-hook15
-rw-r--r--git/init.d/70git-add5
-rw-r--r--git/init.d/README13
8 files changed, 82 insertions, 0 deletions
diff --git a/git/init.d/10restore-etckeeper b/git/init.d/10restore-etckeeper
new file mode 100644
index 0000000..376524c
--- /dev/null
+++ b/git/init.d/10restore-etckeeper
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+# Yes, this runs code from the repository. As documented, etckeeper-init
+# should only be run on repositories you trust.
+if [ -e .etckeeper ]; then
+ . ./.etckeeper
+fi
diff --git a/git/init.d/20restore-metadata b/git/init.d/20restore-metadata
new file mode 100644
index 0000000..01c45e4
--- /dev/null
+++ b/git/init.d/20restore-metadata
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+# Note that metastore doesn't check that the .metastore file only changes
+# perms of files in the current directory. It's ok to trust the .metastore
+# file won't do anything shady, because, as documented, etckeeper-init
+# should only be run on repositories you trust.
+if [ -e .metadata ]; then
+ metastore --apply --mtime
+fi
diff --git a/git/init.d/40git-init b/git/init.d/40git-init
new file mode 100644
index 0000000..69867c4
--- /dev/null
+++ b/git/init.d/40git-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/git/init.d/50git-ignore b/git/init.d/50git-ignore
new file mode 100644
index 0000000..f931592
--- /dev/null
+++ b/git/init.d/50git-ignore
@@ -0,0 +1,22 @@
+#!/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
+blkid.tab.old
+
+# some other files in /etc that typically do not need to be tracked
+ld.so.cache
+mtab
+.pwd.lock
+network/run
+adjtime
+
+EOF
+fi
diff --git a/git/init.d/50git-perm b/git/init.d/50git-perm
new file mode 100644
index 0000000..564e489
--- /dev/null
+++ b/git/init.d/50git-perm
@@ -0,0 +1,3 @@
+#!/bin/sh
+set -e
+chmod 700 .git
diff --git a/git/init.d/50git-pre-commit-hook b/git/init.d/50git-pre-commit-hook
new file mode 100644
index 0000000..0efd5e4
--- /dev/null
+++ b/git/init.d/50git-pre-commit-hook
@@ -0,0 +1,15 @@
+#!/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 `pwd`" >&2
+ fi
+else
+ cat >.git/hooks/pre-commit <<EOF
+#!/bin/sh
+# pre-commit hook for etckeeper, to store metadata and do sanity checks
+set -e
+etckeeper pre-commit `pwd`
+EOF
+ chmod +x .git/hooks/pre-commit
+fi
diff --git a/git/init.d/70git-add b/git/init.d/70git-add
new file mode 100644
index 0000000..06504b4
--- /dev/null
+++ b/git/init.d/70git-add
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if ! git-add .; then
+ echo "etckeeper warning: git-add failed" >&2
+fi
diff --git a/git/init.d/README b/git/init.d/README
new file mode 100644
index 0000000..90aec67
--- /dev/null
+++ b/git/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.