# Remote circumlunar.space (C.S) gopherlog // 18-10-4 As git on SDF still is partly broken, I have decided to invest a bit of time in my C.S setup instead of fixing/adapting my phlog installation on SDF. I already had my C.S gopherlog ("clog") in git, of course, but I needed a way to update the working repo on C.S whenever I add a clog post. There are several possibilities to implement this: - git hooks: elegant, but requires additional git setup - cronjob: proven to work (on SDF), but has trade-off between system load and update frequency - gopher cgi-script pulling into the working (publication) repo on C.S: requires additional step, but simple and with manual control I'd prefer the latter solution, but there is the problem of cgi-scripts running as the gophernicus user, which is basically 'nobody' and therefore does not have access to my git repo. This leaves githooks or cronjobs. Not wanting to put burden on C.S, I'm left with the githooks approach, e.g with a dumb post-update hook that simply does `cd $CLOGDIR && git pull` . After some trials, I got it working! My most stupid error was that I put the hook into the working directory instead of the repo... and apparently the git-receive-pack does not run in the working directory: I had to put the absolute path into the remote used in the working directory (manually, it always worked with a relative path). Then I ran into the issue that a newly created file somewhere else ended up in the remote repo, but not in the working directory even after the `git pull` : a checkout is required, but this should only be done for the clog directory, in case the repo covers other files (as in my case) which may still have unsaved changes. So I added a `git checkout $clogdir` but then I got strange "fatal errors" about '.' not being a git repo. Searching the web found me a thread on stackexchange which indicated the problem might be with the `GIT_DIR` environment variable, and indeed unsetting this variable results in `cd` (and so $PWD) being honoured by git. The final `post-update` hook script is below. Additionally it has a `chmod` which forces read permissions on all files in the clog directory. Anyway, now I can also remotely clog, not just phlog, and I have learned some more details of git. ^-^ .:. #!/bin/sh cdir=/home/yargo/gopher/clog echo :post-update: unset GIT_DIR cd "$cdir" && git pull && git checkout . && chmod a+r *