mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Minor ejabberdctl improvements
This commit is contained in:
parent
818d9c8c42
commit
92003fa4dc
@ -59,6 +59,7 @@ shift $((OPTIND-1))
|
|||||||
: ${EJABBERDCTL_CONFIG_PATH:="$ETC_DIR"/ejabberdctl.cfg}
|
: ${EJABBERDCTL_CONFIG_PATH:="$ETC_DIR"/ejabberdctl.cfg}
|
||||||
[ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
|
[ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
|
||||||
[ "$ERLANG_NODE_ARG" != "" ] && ERLANG_NODE=$ERLANG_NODE_ARG
|
[ "$ERLANG_NODE_ARG" != "" ] && ERLANG_NODE=$ERLANG_NODE_ARG
|
||||||
|
[ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && S="-s"
|
||||||
: ${EJABBERD_DOC_PATH:={{docdir}}}
|
: ${EJABBERD_DOC_PATH:={{docdir}}}
|
||||||
: ${EJABBERD_LOG_PATH:="$LOGS_DIR"/ejabberd.log}
|
: ${EJABBERD_LOG_PATH:="$LOGS_DIR"/ejabberd.log}
|
||||||
|
|
||||||
@ -75,25 +76,17 @@ if [ "$INET_DIST_INTERFACE" != "" ] ; then
|
|||||||
ERLANG_OPTS="$ERLANG_OPTS -kernel inet_dist_use_interface \"$INET_DIST_INTERFACE2\""
|
ERLANG_OPTS="$ERLANG_OPTS -kernel inet_dist_use_interface \"$INET_DIST_INTERFACE2\""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] ; then
|
|
||||||
NAME="-sname"
|
|
||||||
else
|
|
||||||
NAME="-name"
|
|
||||||
fi
|
|
||||||
ERL_LIBS={{libdir}}
|
ERL_LIBS={{libdir}}
|
||||||
ERL_CRASH_DUMP="$LOGS_DIR"/erl_crash_$(date "+%Y%m%d-%H%M%S").dump
|
ERL_CRASH_DUMP="$LOGS_DIR"/erl_crash_$(date "+%Y%m%d-%H%M%S").dump
|
||||||
ERL_INETRC="$ETC_DIR"/inetrc
|
ERL_INETRC="$ETC_DIR"/inetrc
|
||||||
|
|
||||||
# define ejabberd parameters
|
# define ejabberd parameters
|
||||||
rate=$(sed '/^[ ]*log_rate_limit/!d;s/.*://;s/ *//' "$EJABBERD_CONFIG_PATH")
|
EJABBERD_OPTS="$EJABBERD_OPTS\
|
||||||
rotate=$(sed '/^[ ]*log_rotate_size/!d;s/.*://;s/ *//' "$EJABBERD_CONFIG_PATH")
|
$(sed '/^log_rate_limit/!d;s/:[ \t]*\([0-9]*\).*/ \1/' "$EJABBERD_CONFIG_PATH")\
|
||||||
count=$(sed '/^[ ]*log_rotate_count/!d;s/.*://;s/ *//' "$EJABBERD_CONFIG_PATH")
|
$(sed '/^log_rotate_size/!d;s/:[ \t]*\([0-9]*\).*/ \1/' "$EJABBERD_CONFIG_PATH")\
|
||||||
date=$(sed '/^[ ]*log_rotate_date/!d;s/.*://;s/ *//' "$EJABBERD_CONFIG_PATH")
|
$(sed '/^log_rotate_count/!d;s/:[ \t]*\([0-9]*\).*/ \1/' "$EJABBERD_CONFIG_PATH")\
|
||||||
[ -z "$rate" ] || EJABBERD_OPTS="log_rate_limit $rate"
|
$(sed '/^log_rotate_date/!d;s/:[ \t]*\(.[^ ]*\).*/ \1/' "$EJABBERD_CONFIG_PATH")"
|
||||||
[ -z "$rotate" ] || EJABBERD_OPTS="$EJABBERD_OPTS log_rotate_size $rotate"
|
[ -n "$EJABBERD_OPTS" ] && EJABBERD_OPTS="-ejabberd $EJABBERD_OPTS"
|
||||||
[ -z "$count" ] || EJABBERD_OPTS="$EJABBERD_OPTS log_rotate_count $count"
|
|
||||||
[ -z "$date" ] || EJABBERD_OPTS="$EJABBERD_OPTS log_rotate_date '$date'"
|
|
||||||
[ -z "$EJABBERD_OPTS" ] || EJABBERD_OPTS="-ejabberd $EJABBERD_OPTS"
|
|
||||||
EJABBERD_OPTS="-mnesia dir \"$SPOOL_DIR\" $MNESIA_OPTIONS $EJABBERD_OPTS -s ejabberd"
|
EJABBERD_OPTS="-mnesia dir \"$SPOOL_DIR\" $MNESIA_OPTIONS $EJABBERD_OPTS -s ejabberd"
|
||||||
|
|
||||||
# export global variables
|
# export global variables
|
||||||
@ -121,12 +114,12 @@ exec_cmd()
|
|||||||
exec_erl()
|
exec_erl()
|
||||||
{
|
{
|
||||||
NODE=$1; shift
|
NODE=$1; shift
|
||||||
exec_cmd $ERL $NAME $NODE $ERLANG_OPTS "$@"
|
exec_cmd $ERL ${S:--}name $NODE $ERLANG_OPTS "$@"
|
||||||
}
|
}
|
||||||
exec_iex()
|
exec_iex()
|
||||||
{
|
{
|
||||||
NODE=$1; shift
|
NODE=$1; shift
|
||||||
exec_cmd $IEX -$NAME $NODE --erl "$ERLANG_OPTS" "$@"
|
exec_cmd $IEX ${S:--}name $NODE --erl "$ERLANG_OPTS" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# usage
|
# usage
|
||||||
@ -198,22 +191,6 @@ help()
|
|||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# generic erlang node ping feature
|
|
||||||
ping()
|
|
||||||
{
|
|
||||||
PEER=${1:-$ERLANG_NODE}
|
|
||||||
if [ "$PEER" = "${PEER%.*}" ] ; then
|
|
||||||
PING_NAME="-sname"
|
|
||||||
PING_NODE=$(hostname -s)
|
|
||||||
else
|
|
||||||
PING_NAME="-name"
|
|
||||||
PING_NODE=$(hostname)
|
|
||||||
fi
|
|
||||||
exec_cmd $ERL $PING_NAME $(uid ping $PING_NODE) $ERLANG_OPTS \
|
|
||||||
-noinput -hidden -eval 'io:format("~p~n",[net_adm:ping('"$PEER"')])' \
|
|
||||||
-s erlang halt -output text
|
|
||||||
}
|
|
||||||
|
|
||||||
# dynamic node name helper
|
# dynamic node name helper
|
||||||
uid()
|
uid()
|
||||||
{
|
{
|
||||||
@ -310,7 +287,11 @@ case $1 in
|
|||||||
exec_iex $ERLANG_NODE --erl "$EJABBERD_OPTS" --app ejabberd
|
exec_iex $ERLANG_NODE --erl "$EJABBERD_OPTS" --app ejabberd
|
||||||
;;
|
;;
|
||||||
ping)
|
ping)
|
||||||
ping $2
|
PEER=${2:-$ERLANG_NODE}
|
||||||
|
[ "$PEER" = "${PEER%.*}" ] && PS="-s"
|
||||||
|
exec_cmd $ERL ${PS:--}name $(uid ping $(hostname $PS)) $ERLANG_OPTS \
|
||||||
|
-noinput -hidden -eval 'io:format("~p~n",[net_adm:ping('"$PEER"')])' \
|
||||||
|
-s erlang halt -output text
|
||||||
;;
|
;;
|
||||||
started)
|
started)
|
||||||
wait_status 0 30 2 # wait 30x2s before timeout
|
wait_status 0 30 2 # wait 30x2s before timeout
|
||||||
|
Loading…
Reference in New Issue
Block a user