deb/apache-register-hg.bash
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 07 May 2023 12:48:30 +0300
changeset 20 f1b38aa4fa52
parent 17 141de5177ee8
child 21 52f40bd9e114
permissions -rw-r--r--
Removed tab.

#!/bin/bash

set -x

a2enmod cgi
service apache2 restart

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
        Require all granted
        AllowOverride None
        AddHandler cgi-script .cgi
    </Directory>
</VirtualHost>
EOF

a2ensite hg
systemctl reload apache2