Skip to content

Instantly share code, notes, and snippets.

@yuki-takei
Last active August 29, 2015 14:24
Show Gist options
  • Save yuki-takei/58401ffa70c7812a9dbb to your computer and use it in GitHub Desktop.
Save yuki-takei/58401ffa70c7812a9dbb to your computer and use it in GitHub Desktop.
Dynamic dav-svn configuration
$ mkdir ~/apache2
$ cd ~/apache2
$ git clone https://github.com/weseek/apache2conf-generator-davsvn.git
$ cp -r apache2conf-generator-davsvn/templates ./mytemplates
;
; supervisord configuration file
;
[program:generate-davsvn-conf]
user=user
command=/bin/bash -c "while true; do /home/user/apache2/generate-davsvn-conf.sh; sleep 300; done"
[program:diff-and-reload-apache2]
command=/bin/bash -c "sleep 10; while true; do /home/user/apache2/diff-and-reload-apache2.sh; sleep 60; done"
#!/bin/sh
PYTHON=/usr/bin/python3.4
REPOS=/home/user/repos
OUT=davsvn.conf
cd /home/user/apache2
$PYTHON ./apache2conf-generator-davsvn/scan-and-gen.py --tplmap tplmap.json $REPOS > $OUT
{
"*/rm__*": "mytemplates/empty.tpl",
"*": "mytemplates/with-htpasswd.tpl"
}
#!/bin/sh
ORGCONF=/etc/apache2/conf-available/davsvn.conf
NEWCONF=/home/user/apache2/davsvn.conf
is_different=0
if [ -ne ORGCONF ]; then
is_different=1
else
diff $ORGCONF $NEWCONF > /dev/null 2>&1
is_different=$ # set diff status
fi
# copy config file and restart apache2
if [ $is_different -eq 1 ]; then
echo `date` "- detected changes"
# copy
cp $NEWCONF $ORGCONF
chown root:root $ORGCONF
# graceful restart
/usr/sbin/apachectl graceful
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment