fix timezones in darcs-fast-export, take 2
[girocco-darcs-fast-export.git] / t / lib-httpd.sh
blobfad953eb9ac6e225ee2ed90d7665237e28471b8e
1 #!/bin/sh
3 # This is based on git's t/lib-httpd.sh, which is
4 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
7 if test -n "$DFE_TEST_SKIP_HTTPD"
8 then
9 echo "skipping test (undef DFE_TEST_SKIP_HTTPD to enable)"
10 exit
13 LIB_HTTPD_PATH=${LIB_HTTPD_PATH-'/usr/sbin/httpd'}
14 LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'8111'}
16 HTTPD_ROOT_PATH="$PWD"/httpd
17 HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www
19 if ! test -x "$LIB_HTTPD_PATH"
20 then
21 echo "skipping test, no web server found at '$LIB_HTTPD_PATH'"
22 exit
25 HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \
26 sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q'`
28 if test -n "$HTTPD_VERSION"
29 then
30 if test -z "$LIB_HTTPD_MODULE_PATH"
31 then
32 if ! test $HTTPD_VERSION -ge 2
33 then
34 echo "skipping test, at least Apache version 2 is required"
35 exit
38 LIB_HTTPD_MODULE_PATH='/usr/lib/apache'
40 else
41 error "Could not identify web server at '$LIB_HTTPD_PATH'"
44 HTTPD_PARA="-d $HTTPD_ROOT_PATH -f $HTTPD_ROOT_PATH/apache.conf"
46 prepare_httpd() {
47 mkdir -p $HTTPD_DOCUMENT_ROOT_PATH
49 ln -s $LIB_HTTPD_MODULE_PATH $HTTPD_ROOT_PATH/modules
51 echo "PidFile httpd.pid" > $HTTPD_ROOT_PATH/apache.conf
52 echo "DocumentRoot www" >> $HTTPD_ROOT_PATH/apache.conf
53 echo "ErrorLog error.log" >> $HTTPD_ROOT_PATH/apache.conf
55 HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
58 start_httpd() {
59 prepare_httpd
61 "$LIB_HTTPD_PATH" $HTTPD_PARA \
62 -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start
65 stop_httpd() {
66 "$LIB_HTTPD_PATH" $HTTPD_PARA -k stop