3 # Alias: TCP port number and listening address for MongoDB
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".
15 ls /omd
/sites
/*/etc
/omd
/site.conf
>/dev
/null
2>&1 ||
return 1
16 for conf
in /omd
/sites
/*/etc
/omd
/site.conf
18 [ $conf != /omd
/sites
/$OMD_SITE/etc
/omd
/site.conf
] ||
continue
19 if grep -qx "CONFIG_MONGODB_TCP_PORT='$PORT'" < $conf > /dev
/null
2>&1 ; then
30 while port_is_used
$PORT
40 # Scan for a free port number by looking at the
41 # configuration of the other sites...
42 PORT
=$
(next_free_hook
27017)
46 echo "([1-9][0-9]{0,5})|([a-zA-Z0-9\.\-]*:[1-9][0-9]{0,5})"
49 SELECTED_PORT
=${2:=localhost:27017}
50 if [ "${SELECTED_PORT##*:}" = "${SELECTED_PORT%%:*}" ]; then
52 elif [ "${SELECTED_PORT%%:*}" = "localhost" ]; then
53 SELECTED_PORT
=${SELECTED_PORT##*:}
56 BIND_IP
=${SELECTED_PORT%%:*}
57 SELECTED_PORT
=${SELECTED_PORT##*:}
59 PORT
=$
(next_free_hook
$SELECTED_PORT)
60 CHECK_PORT
=${PORT##*:}
61 if [ "$CHECK_PORT" != "$SELECTED_PORT" ] ; then
62 echo "MongoDB port $SELECTED_PORT is in use. I've choosen $PORT instead." >&2
65 cat <<EOF > $OMD_ROOT/etc/mongodb/mongod.d/port.conf
71 [ "$CONFIG_MONGODB" = on
]