mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Improve join/leave cluster scripts
This commit is contained in:
parent
28090a3958
commit
63926efd20
@ -1,18 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Add the current ejabberd node in a cluster
|
# Add the current ejabberd node in a cluster
|
||||||
|
|
||||||
# copyright (c) 2010-2015 ProcessOne
|
# copyright (c) 2010-2015 ProcessOne
|
||||||
#
|
|
||||||
# This script is proprietary software and cannot be published or redistribute.
|
|
||||||
|
|
||||||
# Return Code:
|
# Return Code:
|
||||||
# 0 : groovy baby
|
# 0 : groovy baby
|
||||||
|
# 10 : ejabberdctl not found
|
||||||
# 11 : erl not found
|
# 11 : erl not found
|
||||||
# 12 : erlc not found
|
# 12 : erlc not found
|
||||||
# 20 : database dir doesn't exist
|
# 20 : database dir can not be created
|
||||||
# 21 : database dir not writable
|
# 21 : database dir not writable
|
||||||
# 21 : database dir variable not set
|
# 22 : temporary dir can not be created
|
||||||
# 30 : network issue
|
# 30 : network issue
|
||||||
# 31 : node names incompatibility
|
# 31 : node names incompatibility
|
||||||
|
|
||||||
@ -53,23 +52,28 @@ echo ""
|
|||||||
REMOTE=$1
|
REMOTE=$1
|
||||||
}
|
}
|
||||||
|
|
||||||
cont=Y
|
PA=/tmp/clustersetup_$$
|
||||||
ping -q -c 1 ${REMOTE#*@} 2>/dev/null >/dev/null
|
CTL=$(which ejabberdctl)
|
||||||
[ $? -eq 0 ] || {
|
[ "$CTL" == "" ] && {
|
||||||
echo "Cannot ping ${REMOTE#*@}. Are you sure network setup is correct ?"
|
HERE=`which "$0"`
|
||||||
echo -n "Should we continue anyway ? (Y/n) "
|
BASE=`dirname $HERE`/..
|
||||||
read cont
|
ROOTDIR=`cd $BASE; pwd`
|
||||||
|
PATH=$ROOTDIR/bin:$PATH
|
||||||
|
PA=$ROOTDIR/clustersetup_$$
|
||||||
|
CTL=$(which ejabberdctl)
|
||||||
}
|
}
|
||||||
cont=`echo $cont | tr a-z A-Z`
|
echo "Using commands:"
|
||||||
[ "$cont" == "Y" ] || error "Check your network configuration (dns, firewall, etc...)" 30
|
[ -x $CTL ] && echo $CTL || error "can't find ejabberdctl" 10
|
||||||
|
|
||||||
|
. $CTL stop 2>/dev/null >/dev/null
|
||||||
|
ERLC=${ERL}c
|
||||||
|
|
||||||
|
[ -x $ERL ] && echo $ERL || error "can't find erl" 11
|
||||||
|
[ -x $ERLC ] && echo $ERLC || error "can't find erlc" 12
|
||||||
|
echo ""
|
||||||
|
|
||||||
HERE=`which "$0"`
|
|
||||||
BASE=`dirname $HERE`/..
|
|
||||||
ROOTDIR=`cd $BASE; pwd`
|
|
||||||
. $ROOTDIR/bin/ejabberdctl stop 2>/dev/null >/dev/null
|
|
||||||
NAME=-name
|
NAME=-name
|
||||||
[ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && NAME=-sname
|
[ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && NAME=-sname
|
||||||
PA=/tmp/clustersetup_$$
|
|
||||||
CLUSTERSETUP=clustersetup
|
CLUSTERSETUP=clustersetup
|
||||||
CLUSTERSETUP_ERL=$PA/$CLUSTERSETUP.erl
|
CLUSTERSETUP_ERL=$PA/$CLUSTERSETUP.erl
|
||||||
|
|
||||||
@ -89,17 +93,11 @@ REMOTENAME=-name
|
|||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
|
||||||
echo "Using commands:"
|
|
||||||
which erl || error "can't find erl" 11
|
|
||||||
which erlc || error "can't find erlc" 12
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
[ -d $SPOOL_DIR ] && rm -Rf $SPOOL_DIR
|
[ -d $SPOOL_DIR ] && rm -Rf $SPOOL_DIR
|
||||||
mkdir $SPOOL_DIR || error "$SPOOL_DIR cannot be created" 20
|
mkdir $SPOOL_DIR || error "$SPOOL_DIR cannot be created" 20
|
||||||
[ -w $SPOOL_DIR ] || error "$SPOOL_DIR directory is not writable" 21
|
[ -w $SPOOL_DIR ] || error "$SPOOL_DIR directory is not writable" 21
|
||||||
|
mkdir -p $PA || error "$PA cannot be created" 22
|
||||||
cd $ROOTDIR
|
cd $PA
|
||||||
mkdir -p $PA
|
|
||||||
cat <<EOF > $CLUSTERSETUP_ERL
|
cat <<EOF > $CLUSTERSETUP_ERL
|
||||||
-module($CLUSTERSETUP).
|
-module($CLUSTERSETUP).
|
||||||
|
|
||||||
@ -144,8 +142,10 @@ start() ->
|
|||||||
end,
|
end,
|
||||||
halt(R).
|
halt(R).
|
||||||
EOF
|
EOF
|
||||||
erlc -o $PA $CLUSTERSETUP_ERL
|
|
||||||
sh -c "erl $NAME $ERLANG_NODE -pa $PA $KERNEL_OPTS -mnesia extra_db_nodes \"['$REMOTE']\" dir \"\\\"$SPOOL_DIR\\\"\" -s mnesia -s $CLUSTERSETUP start"
|
$ERLC -o $PA $CLUSTERSETUP_ERL
|
||||||
|
sh -c "$ERL $NAME $ERLANG_NODE -pa $PA $KERNEL_OPTS -mnesia extra_db_nodes \"['$REMOTE']\" dir \"\\\"$SPOOL_DIR\\\"\" -s mnesia -s $CLUSTERSETUP start"
|
||||||
|
cd -
|
||||||
rm -Rf $PA
|
rm -Rf $PA
|
||||||
|
|
||||||
echo "End."
|
echo "End."
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Remove the current ejabberd node in a cluster
|
# Remove the current ejabberd node in a cluster
|
||||||
|
|
||||||
# copyright (c) 2010-2015 ProcessOne
|
# copyright (c) 2010-2015 ProcessOne
|
||||||
#
|
|
||||||
# This script is proprietary software and cannot be published or redistribute.
|
|
||||||
|
|
||||||
# Return Code:
|
# Return Code:
|
||||||
# 0 : groovy baby
|
# 0 : groovy baby
|
||||||
|
# 10 : ejabberdctl not found
|
||||||
# 11 : erl not found
|
# 11 : erl not found
|
||||||
# 12 : erlc not found
|
# 12 : erlc not found
|
||||||
# 20 : database dir doesn't exist
|
# 22 : temporary dir can not be created
|
||||||
# 21 : database dir not writable
|
|
||||||
# 21 : database dir variable not set
|
|
||||||
|
|
||||||
function error
|
function error
|
||||||
{
|
{
|
||||||
@ -33,25 +30,36 @@ echo "Press any key to continue, or Ctrl+C to stop now"
|
|||||||
read foo
|
read foo
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
HERE=`which "$0"`
|
|
||||||
BASE=`dirname $HERE`/..
|
|
||||||
ROOTDIR=`cd $BASE; pwd`
|
|
||||||
. $ROOTDIR/bin/ejabberdctl stop 2>/dev/null >/dev/null
|
|
||||||
$ROOTDIR/bin/ejabberdctl stopped
|
|
||||||
PA=/tmp/clustersetup_$$
|
PA=/tmp/clustersetup_$$
|
||||||
|
CTL=$(which ejabberdctl)
|
||||||
|
[ "$CTL" == "" ] && {
|
||||||
|
HERE=`which "$0"`
|
||||||
|
BASE=`dirname $HERE`/..
|
||||||
|
ROOTDIR=`cd $BASE; pwd`
|
||||||
|
PATH=$ROOTDIR/bin:$PATH
|
||||||
|
PA=$ROOTDIR/clustersetup_$$
|
||||||
|
CTL=$(which ejabberdctl)
|
||||||
|
}
|
||||||
|
echo "Using commands:"
|
||||||
|
[ -x $CTL ] && echo $CTL || error "can't find ejabberdctl" 10
|
||||||
|
|
||||||
|
. $CTL stop 2>/dev/null >/dev/null
|
||||||
|
ERLC=${ERL}c
|
||||||
|
|
||||||
|
[ -x $ERL ] && echo $ERL || error "can't find erl" 11
|
||||||
|
[ -x $ERLC ] && echo $ERLC || error "can't find erlc" 12
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
$CTL stopped
|
||||||
|
|
||||||
CLUSTERSETUP=clustersetup
|
CLUSTERSETUP=clustersetup
|
||||||
CLUSTERSETUP_ERL=$PA/$CLUSTERSETUP.erl
|
CLUSTERSETUP_ERL=$PA/$CLUSTERSETUP.erl
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
|
||||||
echo "Using commands:"
|
mkdir -p $PA || error "$PA cannot be created" 22
|
||||||
which erl || error "can't find erl" 11
|
cd $PA
|
||||||
which erlc || error "can't find erlc" 12
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
cd $ROOTDIR
|
|
||||||
mkdir -p $PA
|
|
||||||
cat <<EOF > $CLUSTERSETUP_ERL
|
cat <<EOF > $CLUSTERSETUP_ERL
|
||||||
-module($CLUSTERSETUP).
|
-module($CLUSTERSETUP).
|
||||||
|
|
||||||
@ -89,8 +97,10 @@ start() ->
|
|||||||
end,
|
end,
|
||||||
halt(0).
|
halt(0).
|
||||||
EOF
|
EOF
|
||||||
erlc -o $PA $CLUSTERSETUP_ERL
|
|
||||||
sh -c "erl $NAME $ERLANG_NODE -pa $PA $KERNEL_OPTS -mnesia dir "\"$SPOOL_DIR\"" -s mnesia -s $CLUSTERSETUP start"
|
$ERLC -o $PA $CLUSTERSETUP_ERL
|
||||||
|
sh -c "$ERL $NAME $ERLANG_NODE -pa $PA $KERNEL_OPTS -mnesia dir \"\\\"$SPOOL_DIR\\\"\" -s mnesia -s $CLUSTERSETUP start"
|
||||||
|
cd -
|
||||||
rm -Rf $PA
|
rm -Rf $PA
|
||||||
|
|
||||||
echo "End."
|
echo "End."
|
||||||
|
Loading…
Reference in New Issue
Block a user