From 75756f0fc973fd79499c753d0d355571259f2b2b Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 8 Jun 2012 17:33:21 +0200 Subject: [PATCH] Check node name is available before starting ejabberd (EJAB-1572) --- src/ejabberdctl.template | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ejabberdctl.template b/src/ejabberdctl.template index 0960f9aff..461ec1a6f 100644 --- a/src/ejabberdctl.template +++ b/src/ejabberdctl.template @@ -143,6 +143,9 @@ export EXEC_CMD # start server start () { + checknodenameusage + [ "$?" -eq 0 ] && echo "\nERROR: The node '$ERLANG_NODE' is already running." && return 1 + $EXEC_CMD "$ERL \ $NAME $ERLANG_NODE \ -noinput -detached \ @@ -189,6 +192,9 @@ debug () # start interactive server live () { + checknodenameusage + [ "$?" -eq 0 ] && echo "\nERROR: The node '$ERLANG_NODE' is already running." && return 1 + echo "--------------------------------------------------------------------" echo "" echo "IMPORTANT: ejabberd is going to start in LIVE (interactive) mode." @@ -362,6 +368,15 @@ wait_for_status() return $status } +# check node name is used or not +# $? --> 0=alreadyused 1=available +checknodenameusage () +{ + $EXEC_CMD "$ERL \ + $NAME $ERLANG_NODE \ + -s erlang halt | grep -c duplicate_name > /dev/null " +} + case $ARGS in ' start') start;; ' debug') debug;;