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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
6a6933bfce58 Added test Apache 2 virtual host.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
#!/bin/bash
6a6933bfce58 Added test Apache 2 virtual host.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
11
a6a75053c129 Fixed names, enabled debugging.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 10
diff changeset
     3
set -x
a6a75053c129 Fixed names, enabled debugging.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 10
diff changeset
     4
16
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
     5
a2enmod cgi
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
     6
service apache2 restart
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
     7
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
     8
mkdir -p /srv/hg
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
     9
chown user:user /srv/hg
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    10
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    11
cat <<EOF >/srv/hg/hgweb.cgi
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    12
#!/usr/bin/env python
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    13
# See also https://mercurial-scm.org/wiki/PublishingRepositories
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    14
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    15
# Path to repo or hgweb config to serve (see 'hg help hgweb')
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    16
config = "/srv/hg/hgweb.config"
10
6a6933bfce58 Added test Apache 2 virtual host.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    18
from mercurial import demandimport; demandimport.enable()
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    19
from mercurial.hgweb import hgweb, wsgicgi
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    20
application = hgweb(config)
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    21
wsgicgi.launch(application)
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    22
EOF
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    23
chmod a+xr /srv/hg/hgweb.cgi
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    24
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    25
cat <<EOF >/srv/hg/hgweb.config
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    26
[paths]
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    27
/ = /srv/hg/*
10
6a6933bfce58 Added test Apache 2 virtual host.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    29
[web]
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    30
style = gitweb
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    31
encoding = "UTF-8"
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    32
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    33
baseurl = /
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    34
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    35
deny_push = *
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    36
allow_archive = bz2, gz, zip
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    37
EOF
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    38
chmod a+r /srv/hg/hgweb.config
13
7ed40cd96e3a Possible fix for: AH01630: client denied by server configuration.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 12
diff changeset
    39
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    40
cat <<EOF >/etc/apache2/sites-available/hg.conf
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    41
<VirtualHost hg.defun.work:*>
16
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
    42
    DocumentRoot /srv/hg
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    43
17
141de5177ee8 Escaped dollar sign.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 16
diff changeset
    44
    ScriptAliasMatch  ^/(.*)  /srv/hg/hgweb.cgi/\$1
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    45
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    46
    <Directory "/srv/hg/">
16
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
    47
        Options +ExecCGI
13
7ed40cd96e3a Possible fix for: AH01630: client denied by server configuration.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 12
diff changeset
    48
        Require all granted
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    49
        AllowOverride None
16
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
    50
        AddHandler cgi-script .cgi
13
7ed40cd96e3a Possible fix for: AH01630: client denied by server configuration.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 12
diff changeset
    51
    </Directory>
11
a6a75053c129 Fixed names, enabled debugging.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 10
diff changeset
    52
</VirtualHost>
10
6a6933bfce58 Added test Apache 2 virtual host.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    53
EOF
6a6933bfce58 Added test Apache 2 virtual host.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    54
15
3f7b202af99e An attempt to host HG via Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 13
diff changeset
    55
a2ensite hg
16
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
    56
systemctl reload apache2
667a0417c36a Corrections to hosting HG in Apache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 15
diff changeset
    57