Skip to content
Permalink
Browse files
Bind epmd and distribution port to loopback interface only for standa…
…lone
  • Loading branch information
rnewson authored and nickva committed Apr 27, 2022
1 parent 7df4777 commit a622ebf4395a23c65482085e68560b0d0e26e727
Showing 4 changed files with 36 additions and 0 deletions.
@@ -0,0 +1,14 @@
#!/bin/sh
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

ERL_EPMD_ADDRESS=127.0.0.1
@@ -39,6 +39,10 @@ DAEMON=/opt/couchdb/bin/couchdb
START_ARGS="--chuid couchdb:couchdb --chdir /opt/couchdb --background"
STOP_ARGS="--pid $PID"

if [ -r /etc/default/${NAME} ]; then
. /etc/default/${NAME}
fi

do_usage() {
echo "Usage: couchdb {start|stop|status|restart|try-restart|force-reload}" >&2
}
@@ -157,6 +157,11 @@ case $1 in
false
fi

# set inet_dist_use_interface default if not present
if ! grep -q '^-kernel inet_dist_use_interface' /opt/couchdb/etc/vm.args; then
echo "-kernel inet_dist_use_interface '{127,0,0,1}'" >> /opt/couchdb/etc/vm.args
fi

case $mode in
none)
;;
@@ -166,6 +171,12 @@ case $1 in
if ! setadminpass; then
password_error="yes"
fi

# Bind distribution port to loopback interface only
sed -i "s/^-kernel inet_dist_use_interface '{0,0,0,0}'$/-kernel inet_dist_use_interface '{127,0,0,1}'/" /opt/couchdb/etc/vm.args

# Bind EPMD to loopback interface
sed -i "s/^ERL_EPMD_ADDRESS=$/ERL_EPMD_ADDRESS=127.0.0.1/" /etc/default/couchdb
;;
clustered)
db_get couchdb/nodename && nodename="$RET"
@@ -179,6 +190,12 @@ case $1 in
if ! setadminpass; then
password_error="yes"
fi

# Unbind distribution port from lookback interface only
sed -i "s/^-kernel inet_dist_use_interface '{127,0,0,1}'$/-kernel inet_dist_use_interface '{0,0,0,0}'/" /opt/couchdb/etc/vm.args

# Unbind EPMD from loopback interface
sed -i "s/^ERL_EPMD_ADDRESS=127.0.0.1$/ERL_EPMD_ADDRESS=/" /etc/default/couchdb
;;
*)
echo "incomprehensible couchdb mode '$mode'!" 1>&2
@@ -4,6 +4,7 @@ Wants=network-online.target
After=network-online.target

[Service]
EnvironmentFile=-/etc/default/couchdb
RuntimeDirectory=couchdb
User=couchdb
Group=couchdb

0 comments on commit a622ebf

Please sign in to comment.