Skip to content

Instantly share code, notes, and snippets.

@vstakhov
Created April 18, 2015 18:49
Show Gist options
  • Save vstakhov/a43edf96ca0290dfc41d to your computer and use it in GitHub Desktop.
Save vstakhov/a43edf96ca0290dfc41d to your computer and use it in GitHub Desktop.
git post-receive hook
#!/bin/sh
HOME=/home/cebka
GIT_REPO=$HOME/rspamd.com.git
TMP_GIT_CLONE=/tmp/rspamd.com
PUBLIC_WWW=$HOME/rspamd.com
RSPAMD_REPO=$HOME/rspamd.git
TMP_RSPAMD=/tmp/rspamd
SED_SCRIPT="sed -e 's|^~~~\([a-zA-Z].*\)$|{% highlight \1 %}|' -e 's|^~~~$|{% endhighlight %}|' -e 's/.md)/.html)/g'"
(cd $RSPAMD_REPO && git remote update)
git clone $GIT_REPO $TMP_GIT_CLONE
git clone $RSPAMD_REPO --recurse-submodules $TMP_RSPAMD
(cd $TMP_RSPAMD && cd $TMP_RSPAMD/doc && make lua-doc)
for i in $TMP_RSPAMD/doc/markdown/* ; do
_file=`basename $i`
if [ -d $i ] ; then
mkdir $TMP_GIT_CLONE/doc/$_file
if [ "$_file" = "lua" ] ; then
_layout="doc_lua"
_title="Rspamd Lua Documentation"
elif [ "$_file" = "configuration" ] ; then
_layout="doc_conf"
_title="Rspamd Configuration"
elif [ "$_file" = "architecture" ] ; then
_layout="doc_arch"
_title="Rspamd Architecture"
elif [ "$_file" = "modules" ] ; then
_layout="doc_modules"
_title="Rspamd Modules"
else
_layout="doc"
_title="Rspamd Documentation"
fi
for j in $i/* ; do
_target=`basename $j`
echo $_target | grep '.md' > /dev/null
if [ $? -eq 0 ] ; then
cat > $TMP_GIT_CLONE/doc/$_file/$_target <<EOD
---
layout: $_layout
title: $_title
---
EOD
eval $SED_SCRIPT < $j >> $TMP_GIT_CLONE/doc/$_file/$_target
else
cp $j $TMP_GIT_CLONE/doc/$_file/$_target
fi
done
else
echo $_file | grep '.md' > /dev/null
if [ $? -eq 0 ] ; then
cat > $TMP_GIT_CLONE/doc/$_file <<EOD
---
layout: doc
title: Rspamd Documentation
---
EOD
eval $SED_SCRIPT < $i >> $TMP_GIT_CLONE/doc/$_file
else
cp $i $TMP_GIT_CLONE/doc/$_file
fi
fi
done
jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
rm -Rf $TMP_RSPAMD
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment