Support Apache 2.4 for phantomjs test
[mkws-moved-to-github.git] / test / bin / apache-template-update
1 #!/bin/sh
2 # Copyright (c) 2014-2014 IndexData ApS. http://indexdata.com
3 # Wolfram Schneider
4 #
5 # generate temp config file for testing
6 #
7
8 export APACHE_SERVER_ROOT=$(pwd)
9 export APACHE_RUN_USER=$(whoami)
10 export APACHE_RUN_GROUP=$(groups | awk '{ print $1 }')
11
12 export APACHE_LOG_DIR=$APACHE_SERVER_ROOT/logs
13 export APACHE_PID_FILE=$APACHE_LOG_DIR/mkws-jasmine.pid
14 export APACHE_LOCK_FILE=$APACHE_LOG_DIR/accept.lock
15 : ${APACHE_PORT=4040}; export APACHE_PORT
16
17 export MKWS_ROOT=$(pwd)/..
18
19 MKWS_OS=debian 
20 APACHE_VERSION=2.2
21 case $(uname) in
22   Darwin ) MKWS_OS=macos 
23            test -e libexec || ln -fs /usr/libexec .
24            ;;
25   Linux )  MKWS_OS=debian 
26            if [ -e /etc/debian_version ]; then
27                 MKWS_OS=debian
28                 # Ubuntu with Apache 2.2 can continue using debian
29                 if /usr/bin/dpkg -s apache2 | grep -q "Version: 2\.4\..*ubuntu"; then
30                         MKWS_OS=ubuntu
31                         APACHE_VERSION=2.4
32                 fi
33            fi
34            if [ -e /etc/redhat-release ]; then
35                 MKWS_OS=centos  
36            fi
37            ;;
38   * ) MKWS_OS=debian ;;
39 esac
40
41 export APACHE_MODULES="$MKWS_ROOT/tools/apache2/jasmine-dev.apache-modules.$MKWS_OS.conf"
42
43 if [ "$APACHE_VERSION" = "2.4" ]; then
44         : ${MKWS_APACHE_TEMPLATE="$MKWS_ROOT/tools/apache2/jasmine-dev.template-2.4"}
45 else
46         : ${MKWS_APACHE_TEMPLATE="$MKWS_ROOT/tools/apache2/jasmine-dev.template"}
47 fi
48 : ${MKWS_APACHE_FILE="$APACHE_LOG_DIR/jasmine-dev"}
49
50
51 perl -npe 's,\${(.*?)},$ENV{$1},g; ' $MKWS_APACHE_TEMPLATE > $MKWS_APACHE_FILE.tmp
52 mv -f $MKWS_APACHE_FILE.tmp $MKWS_APACHE_FILE