Debian Codegraph @

contrib/docker/apache-server/entrypoint.sh

raw
1 #!/bin/bash
2
3 # This script gets executed on container start. Its job is to set up
4 # the Mercurial environment and invoke the server.
5
6 # Currently it can install any Mercurial release that has binary packages
7 # (wheels) available on PyPI.
8
9 set -e
10
11 # Provide a default config if the user hasn't supplied one.
12 if [ ! -f ${HTDOCS_DIR}/config ]; then
13 install -m 0644 /var/hg/defaulthgwebconfig ${HTDOCS_DIR}/config
14 fi
15
16 if [ ! -f ${HTDOCS_DIR}/hgweb.wsgi ]; then
17 cat >> ${HTDOCS_DIR}/hgweb.wsgi << EOF
18 config = b'${HTDOCS_DIR}/config'
19
20 import sys
21 sys.path.insert(0, '${INSTALL_DIR}/lib/python3.13/site-packages')
22
23 from mercurial import demandimport
24 demandimport.enable()
25
26 from mercurial.hgweb import hgweb
27 application = hgweb(config)
28 EOF
29 fi
30
31 if [ ! -f /etc/anubis/hgweb.env ]; then
32 cat >> /etc/anubis/hgweb.env << EOF
33 BIND=[::1]:8923
34 TARGET=http://[::1]:3001
35 EOF
36 fi
37
38 if [ ! -d ${REPOS_DIR}/repo ]; then
39 ${INSTALL_DIR}/bin/hg init ${REPOS_DIR}/repo
40 chown -R www-data:www-data ${REPOS_DIR}/repo
41 fi
42
43 # This is necessary to make debuginstall happy.
44 if [ ! -f ~/.hgrc ]; then
45 cat >> ~/.hgrc << EOF
46 [ui]
47 username = Dummy User <[email protected]>
48 EOF
49 fi
50
51 echo "Verifying Mercurial installation looks happy"
52 ${INSTALL_DIR}/bin/hg debuginstall
53
54 exec "$@"