check_oracle_health: update to 1.9.3.5
[omd.git] / packages / shinken / SHINKEN_WEBUI_TCP_PORT.hook
blobf65d7f53de5dbdc3197d39937b4cd6188ddbde36
1 #!/bin/bash
3 # Alias: TCP port number for Apache
4 # Menu: Web GUI
5 # Description:
6 # Configure the TCP port used for the Shinken WebUI
7 # process of this site. This option is only useful if
8 # the CORE is set to "shinken" and WEBSERVER is set to "own".
9 #
10 # After changing this variable, the site-wide Apache webserver
11 # must be restarted.
14 port_is_used ()
16 local PORT=$1
17 ls /omd/sites/*/etc/omd/site.conf >/dev/null 2>&1 || return 1
18 for conf in /omd/sites/*/etc/omd/site.conf
20 [ $conf != /omd/sites/$OMD_SITE/etc/omd/site.conf ] || continue
21 if grep -qx "CONFIG_SHINKEN_WEBUI_TCP_PORT='$PORT'" < $conf > /dev/null 2>&1 ; then
22 return 0
24 done
25 return 1
29 next_free_hook ()
31 local PORT=$1
32 while port_is_used $PORT
34 PORT=$((PORT + 1))
35 done
36 echo "$PORT"
40 case "$1" in
41 default)
42 # Scan for a free port number by looking at the
43 # configuration of the other sites...
44 PORT=$(next_free_hook 57767)
45 echo "$PORT"
47 choices)
48 echo "(none)|([1-9][0-9]{0,5})|([a-zA-Z0-9\.\-]*:[1-9][0-9]{0,5})"
50 set)
51 if [ "$2" = "none" ]; then
52 echo 0
53 else
54 PORT=$(next_free_hook $2)
55 if [ "$PORT" != "$2" ] ; then
56 echo "WebUI port $2 is in use. I've choosen $PORT instead." >&2
57 echo "$PORT"
59 cat <<EOF > $OMD_ROOT/etc/shinken/apache.conf
60 # This file is managed by 'omd config set SHINKEN_WEBUI_TCP_PORT'.
61 # Better do not edit manually
62 <IfModule mod_alias.c>
63 <Location /$OMD_SITE/shinken>
64 RewriteEngine On
65 RewriteCond %{ENV:REDIRECT_STATUS} !=501
66 RewriteCond $OMD_ROOT/lib/shinken/shinken/modules/webui_broker/__init__.py -f
67 RewriteRule ^/(.*) http://%{HTTP_HOST}:$PORT [last,redirect=301]
68 RewriteRule .* http://127.0.0.1/mi/gibts/ned [last,redirect=501]
69 ErrorDocument 501 "<h1>OMD: Shinken WebUI not available</h1>You are using a distribution where the Shinken WebUI feature has been deactivated because the built-in Python interpreter is too old.<br>In order to be correctly displayed with Internet Explorer, this message must be longer than 512 bytes. <br><br>Mir san vom Woid dahoam, des kennt a jeda glei,<br>wenns von de Berge hallt, dann samma mir dabei.<br>Und wenn as Stutzerl knallt, dann samma mir um d'Weg,<br> Mir san vom Woid dahoam, da Woid is sche.<br>Mir san af Straubing zua als lust'ge Bauernknecht,<br>Weil mir uns eib&uuml;lt ham, des war fir uns des recht.<br>Uns hods ned g'folln do draussd, ham miassn glei hoamgeh,<br>Mir san vom Woid dahoam, da Woid is sche."
70 </Location>
71 </IfModule>
72 EOF
75 depends)
76 [ "$CONFIG_CORE" = shinken ]
78 esac