annotate contrib/docker/apache-server/entrypoint.sh @ 35350:82ee401135dd

py3: handle keyword arguments correctly in cmdutil.py Differential Revision: https://phab.mercurial-scm.org/D1626
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 10 Dec 2017 04:45:10 +0530
parents fd5247a88e63
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23399
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 #!/bin/bash
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 # This script gets executed on container start. Its job is to set up
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 # the Mercurial environment and invoke the server.
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 # Mercurial can be started in two modes.
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7 # If the MERCURIAL_SOURCE environment variable is set and it points to a
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 # Mercurial source directory, we will install Mercurial from that directory.
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9 # Otherwise, we download the Mercurial source and install it manually.
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 set -e
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13 SOURCE_DIR=/var/hg/source
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14 INSTALL_DIR=/var/hg/install
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
15 REPOS_DIR=/var/hg/repos
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 HTDOCS_DIR=/var/hg/htdocs
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 if [ ! -d ${SOURCE_DIR} ]; then
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 echo "Mercurial source not available at ${SOURCE_DIR}"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 echo "You need to mount a volume containing the Mercurial source code"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 echo "when running the container. For example:"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 echo ""
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23 echo " $ docker run -v ~/src/hg:/${SOURCE_DIR} hg-apache"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 echo ""
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 echo "This container will now stop running."
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 exit 1
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 fi
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
28
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29 echo "Installing Mercurial from ${SOURCE_DIR} into ${INSTALL_DIR}"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
30 pushd ${SOURCE_DIR}
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31 /usr/bin/python2.7 setup.py install --root=/ --prefix=${INSTALL_DIR} --force
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 popd
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 mkdir -p ${HTDOCS_DIR}
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 # Provide a default config if the user hasn't supplied one.
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37 if [ ! -f ${HTDOCS_DIR}/config ]; then
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
38 cp /defaulthgwebconfig ${HTDOCS_DIR}/config
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 fi
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
40
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41 if [ ! -f ${HTDOCS_DIR}/hgweb.wsgi ]; then
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42 cat >> ${HTDOCS_DIR}/hgweb.wsgi << EOF
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
43 config = '${HTDOCS_DIR}/config'
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
44
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45 import sys
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
46 sys.path.insert(0, '${INSTALL_DIR}/lib/python2.7/site-packages')
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
47
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
48 from mercurial import demandimport
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
49 demandimport.enable()
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
50
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51 from mercurial.hgweb import hgweb
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 application = hgweb(config)
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
53 EOF
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
54 fi
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56 mkdir -p ${REPOS_DIR}
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 if [ ! -d ${REPOS_DIR}/repo ]; then
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 ${INSTALL_DIR}/bin/hg init ${REPOS_DIR}/repo
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60 chown -R www-data:www-data ${REPOS_DIR}/repo
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 fi
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
62
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63 # This is necessary to make debuginstall happy.
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64 if [ ! -f ~/.hgrc ]; then
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
65 cat >> ~/.hgrc << EOF
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
66 [ui]
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
67 username = Dummy User <nobody@example.com>
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
68 EOF
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
69 fi
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71 echo "Verifying Mercurial installation looks happy"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
72 ${INSTALL_DIR}/bin/hg debuginstall
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
73
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74 . /etc/apache2/envvars
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76 echo "Starting Apache HTTP Server on port 80"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
77 echo "We hope you remembered to publish this port when running the container!"
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
78 echo "If this is an interactive container, simply CTRL^C to stop."
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79
fd5247a88e63 docker: add Docker files for running an Apache mod_wsgi server
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
80 exec "$@"