check_logfiles: 3.7.5.1
[omd.git] / packages / shinken / MONGODB_TCP_PORT.hook
blob86eeb50ffd0e678797b3feb67ff6a4f75c5b2d30
1 #!/bin/bash
3 # Alias: TCP port number and listening address for MongoDB
4 # Menu: Addons
5 # Description:
6 # Configure the TCP port used for the MongoDB
7 # process of this site. This option is only useful if
8 # the CORE is set to "shinken" and MONGODB is set to "on".
11 case "$1" in
12 default)
13 # Scan for a free port number by looking at the
14 # configuration of the other sites...
15 PORT=$($OMD_ROOT/lib/omd/port_is_used MONGODB_TCP_PORT 27017)
16 echo "$PORT"
18 choices)
19 echo "([1-9][0-9]{0,5})|([a-zA-Z0-9\.\-]*:[1-9][0-9]{0,5})"
21 set)
22 SELECTED_PORT=${2:=localhost:27017}
23 if [ "${SELECTED_PORT##*:}" = "${SELECTED_PORT%%:*}" ]; then
24 BIND_IP=0.0.0.0
25 elif [ "${SELECTED_PORT%%:*}" = "localhost" ]; then
26 SELECTED_PORT=${SELECTED_PORT##*:}
27 BIND_IP=127.0.0.1
28 else
29 BIND_IP=${SELECTED_PORT%%:*}
30 SELECTED_PORT=${SELECTED_PORT##*:}
32 PORT=$($OMD_ROOT/lib/omd/port_is_used MONGODB_TCP_PORT $SELECTED_PORT)
33 CHECK_PORT=${PORT##*:}
34 if [ "$CHECK_PORT" != "$SELECTED_PORT" ] ; then
35 echo "MongoDB port $SELECTED_PORT is in use. I've choosen $PORT instead." >&2
36 echo "$PORT"
38 cat <<EOF > $OMD_ROOT/etc/mongodb/mongod.d/port.conf
39 port = $PORT
40 bind_ip = $BIND_IP
41 EOF
43 depends)
44 [ "$CONFIG_MONGODB" = on ]
46 esac