pmeerw's blog

Tweets

Sun, 13 Apr 2008

Serving Mercurial repositories with lighttpd on OpenWrt

Sadly, Mercurial is not in OpenWrt yet; here is my lighttpd config (/etc/lighttpd.conf):

server.modules = (
        "mod_rewrite",
        "mod_alias",
        "mod_auth",
        "mod_cgi"
)

# OpenWrt has troubles with more advanced backends (#2401)
server.network-backend = "write"
# needed to store data of POST requests (#2224)
server.upload-dirs = ( "/tmp" )

static-file.exclude-extensions = ( ".cgi" )
cgi.assign = ( ".cgi" => "/usr/bin/python" )

# where hgwegdir.cgi resides
alias.url = ( "/cgi-bin/" => "/data/www-cgi/" )

# I have public and a private repositories
url.rewrite += ( "^/hg-priv([/?].*)?$" => "/cgi-bin/hgwebdir_priv.cgi$1" )
url.rewrite += ( "^/hg([/?].*)?$" => "/cgi-bin/hgwebdir.cgi$1" )

# require user/password for private repositories under /data/hg-priv
auth.debug = 0
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/data/hg-priv/.htdigest"
auth.require = ( "/cgi-bin/hgwebdir_priv.cgi" => (
    "method" => "digest",
    "realm" => "Private Mercurial repositories",
    "require" => "valid-user"))

# only require require user/password for push requests to public
# repositories under /data/hg
$HTTP["url"] =~ "^/cgi-bin/hgwebdir.py" {
    $HTTP["querystring"] =~ "cmd=unbundle" {
        auth.debug = 0
        auth.backend = "htdigest"
        auth.backend.htdigest.userfile = "/data/hg/.htdigest"
        auth.require = ( "/cgi-bin/hgwebdir.cgi" => (
            "method" => "digest",
            "realm" => "Mercurial repositories",
            "require" => "valid-user"))
    }
}

$SERVER["socket"] == "nslu2:80" {
}

$SERVER["socket"] == "nslu2:443" {
  ssl.engine = "enable"
  ssl.pemfile = "/etc/ssl/server.pem"
}

And the hgweb.config configuration file (in /data/www-cgi/):

[collections]
/data/hg/repos/ = /data/hg/repos/

[web]
motd = 

Repositories maintained by me

baseurl = /hg push_ssl = true

posted at: 21:49 | path: /projects/OpenWrt | permanent link | 0 comments


Name
(req.)
Comment


Made with PyBlosxom