Merge commit 'origin/template' into login
authorroot <root@login.drsnuggles.stderr.nl>
Tue, 3 Aug 2010 15:15:32 +0000 (17:15 +0200)
committerroot <root@login.drsnuggles.stderr.nl>
Tue, 3 Aug 2010 15:15:32 +0000 (17:15 +0200)
* commit 'origin/template':
  oidentd: Allow the vserver host to forward connections.
  oidentd: Add default configuration.

etc/hostname [new file with mode: 0644]
etc/mailname [new file with mode: 0644]
usr/local/bin/git-receive-pack [new symlink]
usr/local/bin/git-upload-pack [new symlink]
usr/local/bin/git-wrapper [new file with mode: 0755]

diff --git a/etc/hostname b/etc/hostname
new file mode 100644 (file)
index 0000000..b4fb918
--- /dev/null
@@ -0,0 +1 @@
+login.drsnuggles.stderr.nl
diff --git a/etc/mailname b/etc/mailname
new file mode 100644 (file)
index 0000000..b4fb918
--- /dev/null
@@ -0,0 +1 @@
+login.drsnuggles.stderr.nl
diff --git a/usr/local/bin/git-receive-pack b/usr/local/bin/git-receive-pack
new file mode 120000 (symlink)
index 0000000..b37e17d
--- /dev/null
@@ -0,0 +1 @@
+git-wrapper
\ No newline at end of file
diff --git a/usr/local/bin/git-upload-pack b/usr/local/bin/git-upload-pack
new file mode 120000 (symlink)
index 0000000..b37e17d
--- /dev/null
@@ -0,0 +1 @@
+git-wrapper
\ No newline at end of file
diff --git a/usr/local/bin/git-wrapper b/usr/local/bin/git-wrapper
new file mode 100755 (executable)
index 0000000..570a47d
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# This script prepends BASE_PATH to any arguments that are not options (start
+# with --) and do not start with BASE_PATH already.
+# It then executes its equivalent in /usr/bin with those updated arguments.
+#
+# This script is meant to provide a base path for accessing git repositories
+# through ssh. This is similar to running git-daemon(1) with --base-path and
+# --base-path-relaxed. 
+
+BASE_PATH='/data/vcs/git'
+POST_UPDATE_HOOK="$BASE_PATH/hooks/post-update"
+
+function init_repos() {
+       mkdir "$1" &> /dev/null  || return 1 
+       (cd $1 && git --bare init &> /dev/null) || return 1
+       cp -P "$POST_UPDATE_HOOK" "$1/hooks/" || return 1
+}
+
+# We keep an array of arguments, so we can handle quoting an spaces in
+# arguments properly.
+ARGS=()
+i=0
+until [ "$#" -eq 0 ]
+do
+       if echo $1 | egrep "^--" &>/dev/null; then
+               # This is an option argument, leave it untouched
+               ARGS[$i]="$1"
+       elif echo $1 | egrep ".git$" &>/dev/null; then
+               # This is a path to a git repository
+               DIR="$1"
+               # Prepend BASE_PATH if the path does not start with it already.
+               if ! echo $DIR | egrep "^$BASE_PATH" &>/dev/null; then
+                       DIR="$BASE_PATH/$DIR"
+               fi
+       
+               # When the client wants us to receive a pack, create the git
+               # repository if it does not exist yet   
+               if [ "`basename $0`" = "git-receive-pack" -a ! -e "$DIR" ]; then
+                       init_repos "$DIR" || exit 1
+               fi
+               ARGS[$i]="$DIR"
+       else
+               # Not a path to a git repository, leave untouched.
+               ARGS[$i]="$1"
+       fi
+       ((i++))
+       shift
+done
+
+exec /usr/bin/`basename $0` "${ARGS[@]}"