2007-05-21 05:41:13 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
NODE=ejabberd
|
|
|
|
HOST=localhost
|
2007-10-17 04:33:19 +02:00
|
|
|
ERLANG_NODE=$NODE@$HOST
|
2007-05-21 05:41:13 +02:00
|
|
|
|
|
|
|
# Define ejabberd environment
|
2007-09-27 14:32:05 +02:00
|
|
|
ROOTDIR=@rootdir@
|
2007-11-26 08:59:35 +01:00
|
|
|
EJABBERD_CONFIG_PATH=$ROOTDIR/etc/ejabberd/ejabberd.cfg
|
|
|
|
export EJABBERD_CONFIG_PATH
|
2007-10-17 04:33:19 +02:00
|
|
|
EJABBERDCTL_CFG=$ROOTDIR/etc/ejabberd/ejabberdctl.cfg
|
|
|
|
EJABBERD_INETRC=$ROOTDIR/etc/ejabberd/ejabberd.inetrc
|
2007-09-27 14:32:05 +02:00
|
|
|
EJABBERD_EBIN=$ROOTDIR/var/lib/ejabberd/ebin
|
2007-10-17 04:33:19 +02:00
|
|
|
EJABBERD_DB=$ROOTDIR/var/lib/ejabberd/db/$NODE
|
|
|
|
EJABBERD_MSGS_PATH=$ROOTDIR/var/lib/ejabberd/priv/msgs
|
|
|
|
EJABBERD_SO_PATH=$ROOTDIR/var/lib/ejabberd/priv/lib
|
|
|
|
EJABBERD_LOG_PATH=$ROOTDIR/var/log/ejabberd/ejabberd.log
|
2007-11-26 08:59:35 +01:00
|
|
|
export EJABBERD_LOG_PATH
|
2007-10-17 04:33:19 +02:00
|
|
|
SASL_LOG_PATH=$ROOTDIR/var/log/ejabberd/sasl.log
|
2007-11-26 09:57:21 +01:00
|
|
|
DATETIME=`date "+%Y%m%d-%H%M%S"`
|
|
|
|
ERL_CRASH_DUMP=$ROOTDIR/var/log/ejabberd/erl_crash.dump.$DATETIME
|
|
|
|
export ERL_CRASH_DUMP
|
2007-05-21 05:41:13 +02:00
|
|
|
|
|
|
|
[ -d $EJABBERD_DB ] || mkdir -p $EJABBERD_DB
|
|
|
|
|
2007-10-17 04:33:19 +02:00
|
|
|
[ -f $EJABBERDCTL_CFG ] && . $EJABBERDCTL_CFG
|
|
|
|
|
|
|
|
HOME=$ROOTDIR/var/lib/ejabberd
|
|
|
|
export HOME
|
|
|
|
|
|
|
|
if [ $# -ne 0 ] ; then
|
|
|
|
case $1 in
|
|
|
|
--node) shift ; ERLANG_NODE=$1 ; shift ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] ; then
|
|
|
|
SNAME="-kernel inetrc \""$EJABBERD_INETRC"\" -sname"
|
|
|
|
else
|
|
|
|
SNAME=-name
|
|
|
|
fi
|
|
|
|
|
2007-11-26 08:59:35 +01:00
|
|
|
# Compatibility in ZSH
|
|
|
|
#setopt shwordsplit 2>/dev/null
|
|
|
|
|
2007-12-02 22:13:25 +01:00
|
|
|
ERLANG_OPTS="$POLL $SMP $PROCESSES $ERL_MAX_ETS_TABLES"
|
2007-10-17 04:33:19 +02:00
|
|
|
|
2007-11-26 08:59:35 +01:00
|
|
|
start ()
|
2007-05-21 05:41:13 +02:00
|
|
|
{
|
|
|
|
erl \
|
2007-10-17 04:33:19 +02:00
|
|
|
$SNAME $ERLANG_NODE \
|
|
|
|
$ERLANG_OPTS \
|
2007-05-21 05:41:13 +02:00
|
|
|
-noinput -detached \
|
2007-09-27 14:32:05 +02:00
|
|
|
-pa $EJABBERD_EBIN \
|
2007-05-21 05:41:13 +02:00
|
|
|
-mnesia dir "\"$EJABBERD_DB\"" \
|
|
|
|
-s ejabberd \
|
|
|
|
-sasl sasl_error_logger \{file,\"$SASL_LOG_PATH\"\}
|
|
|
|
}
|
|
|
|
|
2007-11-26 08:59:35 +01:00
|
|
|
debug ()
|
2007-05-21 05:41:13 +02:00
|
|
|
{
|
2007-10-17 04:33:19 +02:00
|
|
|
echo "--------------------------------------------------------------------"
|
|
|
|
echo ""
|
|
|
|
echo "IMPORTANT: we will attempt to attach an INTERACTIVE shell"
|
|
|
|
echo "to an already running ejabberd node."
|
|
|
|
echo "If an ERROR is printed, it means the connection was not succesfull."
|
|
|
|
echo "You can interact with the ejabberd node if you know how to use it."
|
|
|
|
echo "Please be extremely cautious with your actions,"
|
|
|
|
echo "and exit immediately if you are not completely sure."
|
|
|
|
echo ""
|
|
|
|
echo "To detach this shell from ejabberd, press:"
|
|
|
|
echo " control+c, control+c"
|
|
|
|
echo ""
|
|
|
|
echo "--------------------------------------------------------------------"
|
2007-11-26 08:59:35 +01:00
|
|
|
echo "Press any key to continue"
|
|
|
|
read foo
|
2007-10-17 04:33:19 +02:00
|
|
|
echo ""
|
|
|
|
erl \
|
|
|
|
$SNAME debug \
|
|
|
|
-remsh $ERLANG_NODE
|
|
|
|
}
|
|
|
|
|
2007-11-26 08:59:35 +01:00
|
|
|
live ()
|
2007-10-17 04:33:19 +02:00
|
|
|
{
|
|
|
|
echo "--------------------------------------------------------------------"
|
|
|
|
echo ""
|
|
|
|
echo "IMPORTANT: ejabberd is going to start in LIVE (interactive) mode."
|
|
|
|
echo "All log messages will be shown in the command shell."
|
|
|
|
echo "You can interact with the ejabberd node if you know how to use it."
|
|
|
|
echo "Please be extremely cautious with your actions,"
|
|
|
|
echo "and exit immediately if you are not completely sure."
|
|
|
|
echo ""
|
|
|
|
echo "To exit this LIVE mode and stop ejabberd, press:"
|
|
|
|
echo " q(). and press the Enter key"
|
|
|
|
echo ""
|
|
|
|
echo "--------------------------------------------------------------------"
|
2007-11-26 08:59:35 +01:00
|
|
|
echo "Press any key to continue"
|
|
|
|
read foo
|
2007-10-17 04:33:19 +02:00
|
|
|
echo ""
|
2007-05-21 05:41:13 +02:00
|
|
|
erl \
|
2007-10-17 04:33:19 +02:00
|
|
|
$SNAME $ERLANG_NODE \
|
|
|
|
$ERLANG_OPTS \
|
2007-09-27 14:32:05 +02:00
|
|
|
-pa $EJABBERD_EBIN \
|
2007-05-21 05:41:13 +02:00
|
|
|
-mnesia dir "\"$EJABBERD_DB\"" \
|
2007-10-17 04:33:19 +02:00
|
|
|
-s ejabberd
|
2007-05-21 05:41:13 +02:00
|
|
|
}
|
|
|
|
|
2007-11-26 08:59:35 +01:00
|
|
|
ctl ()
|
2007-05-21 05:41:13 +02:00
|
|
|
{
|
|
|
|
erl \
|
2007-10-17 10:51:35 +02:00
|
|
|
$SNAME ejabberdctl \
|
2007-05-21 05:41:13 +02:00
|
|
|
-noinput \
|
2007-09-27 14:32:05 +02:00
|
|
|
-pa $EJABBERD_EBIN \
|
2007-10-17 04:33:19 +02:00
|
|
|
-s ejabberd_ctl -extra $ERLANG_NODE $@
|
|
|
|
case $? in
|
|
|
|
2) help_start;;
|
|
|
|
3) help_start;;
|
|
|
|
esac
|
2007-05-21 05:41:13 +02:00
|
|
|
}
|
|
|
|
|
2007-11-26 08:59:35 +01:00
|
|
|
usage ()
|
2007-05-21 05:41:13 +02:00
|
|
|
{
|
|
|
|
ctl
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2007-11-26 08:59:35 +01:00
|
|
|
help_start ()
|
2007-10-17 04:33:19 +02:00
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
echo "Commands to start an ejabberd node:"
|
|
|
|
echo " start Start an ejabberd node in server mode"
|
|
|
|
echo " debug Attach an interactive Erlang shell to a running ejabberd node"
|
|
|
|
echo " live Start an ejabberd node in live (interactive) mode"
|
|
|
|
echo ""
|
|
|
|
}
|
2007-05-21 05:41:13 +02:00
|
|
|
|
|
|
|
case $1 in
|
|
|
|
start) start;;
|
|
|
|
debug) debug;;
|
2007-10-17 04:33:19 +02:00
|
|
|
live) live;;
|
2007-05-21 05:41:13 +02:00
|
|
|
*) ctl $@;;
|
|
|
|
esac
|