check_logfiles: 3.7.5.1
[omd.git] / packages / apache-omd / APACHE_TCP_PORT.hook
blob0b024202efc86f58f3cce2d034d45dee299a0187
1 #!/bin/bash
3 # Alias: TCP port number for Apache
4 # Menu: Web GUI
5 # Description:
6 # Configure the TCP port used for the Apache webserver
7 # process of this site. This option is only useful if
8 # APACHE is set to "on" and WEBSERVER is set to "own".
10 # After changing this variable, the man Apache webserver
11 # must be restarted.
13 # Load other config options. This hook needs
14 # APACHE_TCP_PORT.
15 if [ -f $OMD_ROOT/etc/omd/site.conf ]; then
16 . $OMD_ROOT/etc/omd/site.conf
17 else
18 CONFIG_APACHE_TCP_ADDR=${CONFIG_APACHE_TCP_ADDR:-127.0.0.1}
21 case "$1" in
22 default)
23 # Scan for a free port number by looking at the
24 # configuration of the other sites...
25 PORT=$($OMD_ROOT/lib/omd/port_is_used APACHE_TCP_PORT 5000)
26 echo "$PORT"
28 choices)
29 echo "[1-9][0-9]{0,4}"
31 set)
32 PORT=$($OMD_ROOT/lib/omd/port_is_used APACHE_TCP_PORT $2)
33 cat <<EOF > $OMD_ROOT/etc/apache/listen-port.conf
34 # This file is created by 'omd config set APACHE_TCP_PORT'.
35 # Better do not edit manually
36 Listen $CONFIG_APACHE_TCP_ADDR:$PORT
37 EOF
38 cat <<EOF > $OMD_ROOT/etc/apache/proxy-port.conf
39 # This file is created by 'omd config set APACHE_TCP_PORT'.
40 # Better do not edit manually
41 <IfModule mod_proxy_http.c>
42 <Proxy http://$CONFIG_APACHE_TCP_ADDR:$PORT/$OMD_SITE>
43 Order allow,deny
44 allow from all
45 </Proxy>
47 <Location /$OMD_SITE>
48 # Setting "retry=0" to prevent 60 second caching of problem states e.g. when
49 # the site apache is down and someone tries to access the page.
50 # "disablereuse=On" prevents the apache from keeping the connection which leads to
51 # wrong devlivered pages sometimes
52 ProxyPass http://$CONFIG_APACHE_TCP_ADDR:$PORT/$OMD_SITE retry=0 disablereuse=On
53 ProxyPassReverse http://$CONFIG_APACHE_TCP_ADDR:$PORT/$OMD_SITE
54 </Location>
55 </IfModule>
56 EOF
57 if [ "$PORT" != "$2" ] ; then
58 echo "Apache port $2 is in use. I've choosen $PORT instead." >&2
59 echo "$PORT"
62 depends)
63 [ "$CONFIG_APACHE_MODE" = own ]
65 esac