deb/apache-register-hg.bash
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 07 May 2023 11:16:52 +0300
changeset 15 3f7b202af99e
parent 13 deb/apache-register-2048.bash@7ed40cd96e3a
child 16 667a0417c36a
permissions -rw-r--r--
An attempt to host HG via Apache.

#!/bin/bash

set -x

mkdir -p /srv/hg
chown user:user /srv/hg

cat <<EOF >/srv/hg/hgweb.cgi
#!/usr/bin/env python
# See also https://mercurial-scm.org/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/srv/hg/hgweb.config"

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)
EOF
chmod a+xr /srv/hg/hgweb.cgi

cat <<EOF >/srv/hg/hgweb.config
[paths]
/ = /srv/hg/*

[web]
style = gitweb
encoding = "UTF-8"

baseurl = /

deny_push = *
allow_archive = bz2, gz, zip
EOF
chmod a+r /srv/hg/hgweb.config

cat <<EOF >/etc/apache2/sites-available/hg.conf
<VirtualHost hg.defun.work:*>
	DocumentRoot /srv/hg

    ScriptAliasMatch  ^/(.*)  /srv/hg/hgweb.cgi$1

    <Directory "/srv/hg/">
        Options ExecCGI FollowSymLinks
        Require all granted
        AllowOverride None
    </Directory>
</VirtualHost>
EOF

a2ensite hg
# service apache2 restart