deb/apache-register-hg.bash
changeset 15 3f7b202af99e
parent 13 7ed40cd96e3a
child 16 667a0417c36a
equal deleted inserted replaced
14:719ced1ac5c3 15:3f7b202af99e
       
     1 #!/bin/bash
       
     2 
       
     3 set -x
       
     4 
       
     5 mkdir -p /srv/hg
       
     6 chown user:user /srv/hg
       
     7 
       
     8 cat <<EOF >/srv/hg/hgweb.cgi
       
     9 #!/usr/bin/env python
       
    10 # See also https://mercurial-scm.org/wiki/PublishingRepositories
       
    11 
       
    12 # Path to repo or hgweb config to serve (see 'hg help hgweb')
       
    13 config = "/srv/hg/hgweb.config"
       
    14 
       
    15 from mercurial import demandimport; demandimport.enable()
       
    16 from mercurial.hgweb import hgweb, wsgicgi
       
    17 application = hgweb(config)
       
    18 wsgicgi.launch(application)
       
    19 EOF
       
    20 chmod a+xr /srv/hg/hgweb.cgi
       
    21 
       
    22 cat <<EOF >/srv/hg/hgweb.config
       
    23 [paths]
       
    24 / = /srv/hg/*
       
    25 
       
    26 [web]
       
    27 style = gitweb
       
    28 encoding = "UTF-8"
       
    29 
       
    30 baseurl = /
       
    31 
       
    32 deny_push = *
       
    33 allow_archive = bz2, gz, zip
       
    34 EOF
       
    35 chmod a+r /srv/hg/hgweb.config
       
    36 
       
    37 cat <<EOF >/etc/apache2/sites-available/hg.conf
       
    38 <VirtualHost hg.defun.work:*>
       
    39 	DocumentRoot /srv/hg
       
    40 
       
    41     ScriptAliasMatch  ^/(.*)  /srv/hg/hgweb.cgi$1
       
    42 
       
    43     <Directory "/srv/hg/">
       
    44         Options ExecCGI FollowSymLinks
       
    45         Require all granted
       
    46         AllowOverride None
       
    47     </Directory>
       
    48 </VirtualHost>
       
    49 EOF
       
    50 
       
    51 a2ensite hg
       
    52 # service apache2 restart