24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-07-02 23:06:21 +02:00

Check node name is available before starting ejabberd (EJAB-1572)

This commit is contained in:
Badlop 2012-06-08 17:33:21 +02:00 committed by Christophe Romain
parent 9787416e88
commit 9442a583bc

View File

@ -41,7 +41,9 @@ fi
if [ "$EJABBERDCTL_CONFIG_PATH" = "" ] ; then
EJABBERDCTL_CONFIG_PATH=$ETCDIR/ejabberdctl.cfg
fi
[ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
if [ -f "$EJABBERDCTL_CONFIG_PATH" ] ; then
. "$EJABBERDCTL_CONFIG_PATH"
fi
if [ "$LOGS_DIR" = "" ] ; then
LOGS_DIR=@LOCALSTATEDIR@/log/ejabberd
fi
@ -75,7 +77,9 @@ if [ "$EXEC_CMD" = "false" ] ; then
fi
NAME=-name
[ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && NAME=-sname
if [ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] ; then
NAME=-sname
fi
KERNEL_OPTS=""
if [ "$FIREWALL_WINDOW" != "" ] ; then
@ -88,22 +92,22 @@ fi
ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $ERL_OPTIONS"
# define additional environment variables
if [ "$EJABBERDDIR" = "" ]; then
if [ "$EJABBERDDIR" = "" ] ; then
EJABBERDDIR=@LIBDIR@/ejabberd
fi
if [ "$EJABBERD_EBIN_PATH" = "" ]; then
if [ "$EJABBERD_EBIN_PATH" = "" ] ; then
EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
fi
if [ "$EJABBERD_PRIV_PATH" = "" ]; then
if [ "$EJABBERD_PRIV_PATH" = "" ] ; then
EJABBERD_PRIV_PATH=$EJABBERDDIR/priv
fi
if [ "$EJABBERD_BIN_PATH" = "" ]; then
if [ "$EJABBERD_BIN_PATH" = "" ] ; then
EJABBERD_BIN_PATH=$EJABBERD_PRIV_PATH/bin
fi
if [ "$EJABBERD_SO_PATH" = "" ]; then
if [ "$EJABBERD_SO_PATH" = "" ] ; then
EJABBERD_SO_PATH=$EJABBERD_PRIV_PATH/lib
fi
if [ "$EJABBERD_MSGS_PATH" = "" ]; then
if [ "$EJABBERD_MSGS_PATH" = "" ] ; then
EJABBERD_MSGS_PATH=$EJABBERD_PRIV_PATH/msgs
fi
@ -292,7 +296,7 @@ ctl ()
fi
)
result=$?
if [ $result -eq 1 ]; then
if [ $result -eq 1 ] ; then
# means we errored out in flock
# rather than in the exec - stay in the loop
# trying other conn names...
@ -305,7 +309,7 @@ ctl ()
result=$(expr $result / 10)
fi
if [ "$badlock" ];then
if [ "$badlock" ] ;then
echo "Ran out of connections to try. Your ejabberd processes" >&2
echo "may be stuck or this is a very busy server. For very" >&2
echo "busy servers, consider raising MAXCONNID in ejabberdctl">&2
@ -352,13 +356,13 @@ check_start()
{
epmd -names | grep -q $NODE && {
ps ux | grep -v grep | grep -q $ERLANG_NODE && {
echo "ejabberd is already running."
echo "ERROR: The ejabberd node '$ERLANG_NODE' is already running."
exit 4
} || {
ps ux | grep beam | grep -v "grep beam" && {
echo "ejabberd node is registered, but no ejabberd process has been found."
echo "can not kill epmd as other erlang nodes are running."
echo "please stop all erlang nodes, and call 'epmd -kill'."
echo "ERROR: The ejabberd node '$ERLANG_NODE' is registered,"
echo " but no ejabberd process has been found."
echo "Shutdown other erlang nodes, and call 'epmd -kill'."
exit 5
} || {
epmd -kill
@ -374,7 +378,7 @@ wait_for_status()
# return: 0 OK, 1 KO
timeout=$2
status=4
while [ $status -ne $1 ]; do
while [ $status -ne $1 ] ; do
sleep $3
timeout=$(($timeout - 1))
[ $timeout -eq 0 ] && {