summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SETUP.md78
-rwxr-xr-xlib/gitolite3/hooks/common/post-receive19
2 files changed, 81 insertions, 16 deletions
diff --git a/SETUP.md b/SETUP.md
index 25b7508..6ec5e2a 100644
--- a/SETUP.md
+++ b/SETUP.md
@@ -1,3 +1,5 @@
+# Setting up source hosting
+
NB! Some system-specific strings are used
which you may need to adapt depending on your local setup:
@@ -12,35 +14,83 @@ Gitolite service need to know the public SSH key of its administrator.
You can let it ask during install,
but it may be more convenient to preconfigure that information instead.
-One way to preconfigure the needed SSH public key
-is to run this command
+**On your local host**,
+print your SSH public key
+e.g. with this command
**from your personal system**
-which then **logs into the server system** using ssh
(adapt to replace ed25519 if your SSH keypair use a different algorithm):
- printf 'gitolite3 gitolite3/adminkey select "%q"' $(cat ~/.ssh/id_ed25519.pub) | ssh {{githost}} sudo debconf-set-selections
-
-Another way is to somehow locate your public SSH key
-and run this command
-(adapt to replace $YOURKEY with your actual key):
-
- echo gitolite3 gitolite3/adminkey select "$YOURKEY" | sudo debconf-set-selections
+ cat ~/.ssh/id_ed25519.pub
-Then preconfigure git user,
+**On the server**,
+preconfigure git user
+with above public key (the whole line without newline) as $YOURKEY,
and install needed packages:
+ echo gitolite3 gitolite3/adminkey select "$YOURKEY" | sudo debconf-set-selections
echo gitolite3 gitolite3/gituser select git | sudo debconf-set-selections
- sudo apt install gitolite3 git-daemon-sysvinit cgit cmark highlight
+ sudo apt install gitolite3 myrepos git-daemon-sysvinit cgit cmark highlight
## Configure git access
-FIXME
+**On your local host**,
+Clone the gitolite3 settings repository:
+
+ git clone git@{{githost}}:gitolite-admin
+
+**On your local host**,
+edit the file gitolite.conf,
+e.g. add these likes to add repository "foobar":
+
+ FIXME
+
+
+## Enable hook
+
+**On the server**,
+clone the redpill feature project for source-hosting
+and register with myrepos (to ease later update):
+
+ mkdir --parents /usr/local/share/redpill
+ cd /usr/local/share/redpill
+ git clone https://source.redpill.dk/source-hosting.git
+ mr reg
+
+Edit the file `/etc/gitolite3/gitolite.rc`
+to have `LOCAL_CODE` point into the project cloned above,
+i.e. the line should look like this:
+
+ LOCAL_CODE => "/usr/local/share/redpill/source-hosting/lib/gitolite3",
+
+Refresh gitolite setup
+by running this command:
+
+ sudo -u git gitolite setup
+
+
+## Web export
+
+FIXME: move to separate feature
+
+**On the server**,
+grant access for gitolite to write below /var/www
+with this command:
+
+ FIXME
+
+**On your local host**,
+edit the file gitolite.conf
+to add FIXME to repos that should be exported for web publishing,
+e.g. add these likes to add repository "foobar":
+
+ FIXME
## Configure web access
-Adapt the file `/etc/default/git-daemon`:
+**On the server**,
+adapt the file `/etc/default/git-daemon`:
GIT_DAEMON_ENABLE=true
GIT_DAEMON_USER=gitdaemon
diff --git a/lib/gitolite3/hooks/common/post-receive b/lib/gitolite3/hooks/common/post-receive
index ab100d9..9c9aed7 100755
--- a/lib/gitolite3/hooks/common/post-receive
+++ b/lib/gitolite3/hooks/common/post-receive
@@ -2,12 +2,16 @@
# This gitolite3 hook exports content for web publishing.
# The following gitolite3 environment variables affect its use:
-# WEB_BRANCH tree-ish (hook silently skipped if unset)
-# WEB_BASEDIR path writable by gitolite3 (default: /var/www/gitolite3)
+# WEB_BRANCH tree-ish (hook silently skipped if unset)
+# WEB_BASEDIR path writable by gitolite3 (default: /var/www/gitolite3)
+# WEB_EXEC_INIT command executed in exported dir after initial checkout
+# WEB_EXEC command executed in exported dir after every checkout
set -eu
WEB_BRANCH=${GL_OPTION_WEB_BRANCH:-}
+WEB_EXEC=${GL_OPTION_WEB_EXEC:-}
+WEB_EXEC_INIT=${GL_OPTION_WEB_EXEC_INIT:-}
[ -n "$WEB_BRANCH" ] || exit 0
@@ -20,8 +24,19 @@ export GIT_WORK_TREE
pwd
echo "Checking out content to $GIT_WORK_TREE ..."
+init=1
+[ -e "$GIT_WORK_TREE" ] || init=
+
git checkout -f "$WEB_BRANCH"
chmod -R u=rw,go=r,a+X "$GIT_WORK_TREE"
+if [ -n "$WEB_EXEC_INIT" ] && [ -n "$init" ]; then
+ ( cd "$WEB_BASEDIR" && echo "$WEB_EXEC_INIT" | sh - )
+fi
+
+if [ -n "$WEB_EXEC" ]; then
+ ( cd "$WEB_BASEDIR" && echo "$WEB_EXEC" | sh - )
+fi
+
echo "Checkout completed succesfully!"