put port number in config/log filenames
[mkws-moved-to-github.git] / test / bin / apache-template-update
1 #!/bin/sh
2 # Copyright (c) 2014-2014 Index Data 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 : ${APACHE_PORT=4040}; export APACHE_PORT
13
14 export APACHE_LOG_DIR=$APACHE_SERVER_ROOT/logs
15 export APACHE_PID_FILE=$APACHE_LOG_DIR/mkws-jasmine-${APACHE_PORT}.pid
16 export APACHE_LOCK_FILE=$APACHE_LOG_DIR/accept-${APACHE_PORT}.lock
17
18 export MKWS_ROOT=$(pwd)/..
19
20 MKWS_OS=debian
21 APACHE_VERSION=2.2
22 apache2=$(env PATH=/bin:/usr/bin:/usr/sbin which apache2 httpd false 2>/dev/null | head -1)
23
24 case $(uname) in
25   Darwin ) MKWS_OS=macos
26            test -e libexec || ln -fs /usr/libexec .
27            ;;
28   Linux )  MKWS_OS=debian
29            if [ -e /etc/debian_version ]; then
30                 MKWS_OS=debian
31                 if $apache2 -v | egrep -q 'Server version: Apache/2\.4\.'; then
32                     APACHE_VERSION=2.4
33                 fi
34            fi
35            if [ -e /etc/redhat-release ]; then
36                 MKWS_OS=centos
37            fi
38            ;;
39   * ) MKWS_OS=debian ;;
40 esac
41
42
43 if [ "$APACHE_VERSION" = "2.4" ]; then
44     : ${MKWS_APACHE_TEMPLATE="$MKWS_ROOT/tools/apache2/jasmine-dev.template-$APACHE_VERSION"}
45     APACHE_MODULES="$MKWS_ROOT/tools/apache2/jasmine-dev.apache-modules-$APACHE_VERSION.$MKWS_OS.conf"
46 else
47     : ${MKWS_APACHE_TEMPLATE="$MKWS_ROOT/tools/apache2/jasmine-dev.template"}
48     APACHE_MODULES="$MKWS_ROOT/tools/apache2/jasmine-dev.apache-modules.$MKWS_OS.conf"
49 fi
50
51 : ${MKWS_APACHE_FILE="$APACHE_LOG_DIR/jasmine-dev-${APACHE_PORT}.conf"}
52 export APACHE_MODULES
53
54 perl -npe 's,\${(.*?)},$ENV{$1},g; ' $MKWS_APACHE_TEMPLATE > $MKWS_APACHE_FILE.tmp
55 mv -f $MKWS_APACHE_FILE.tmp $MKWS_APACHE_FILE