contrib/docker/apache-server/entrypoint.sh
author Gregory Szorc <gregory.szorc@gmail.com>
Mon, 24 Sep 2018 11:16:33 -0700
changeset 39878 2ac4f3e97813
parent 23399 fd5247a88e63
permissions -rwxr-xr-x
filelog: stop proxying flags() (API) Per-revision storage flags are kinda a revlog-centric API. (Except for the fact that changegroup uses the same integer flags as revlog does and there's minimal verification that the server's flags map to the client's storage flags - but that's another problem.) The last user of flags() was in verify.py and that code was just moved into revlog.py and is accessed behind the verifyintegrity() file storage API. Since there are no more consumers, let's drop the proxy and remove the method from the file storage interface. This commit only drops the dedicated API for reading a single revision's storage flags: we still support reading and writing flags through the bulk data retrieval and add revision APIs. And since changegroups encode revlog integer flags over the wire, we'll always need to support flags at some level. The removal of individual storage flags may be too premature. But since flags() is now unused, I'd like to see how far we can get without that dedicated API - especially since it uses revision numbers instead of nodes. Differential Revision: https://phab.mercurial-scm.org/D4746
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 "$@"