mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
ejabberdctl.bc: Improve caching of commands list
Improvements: - Keep command cache for one hour - Fix parsing command list with ECMA-48 SGR escape sequence for font attributes
This commit is contained in:
parent
c6878f9c9d
commit
a33be2d67a
@ -1,18 +1,27 @@
|
|||||||
#
|
#
|
||||||
# bash completion for ejabberdctl
|
# bash completion for ejabberdctl
|
||||||
#
|
#
|
||||||
|
# For installation and details see:
|
||||||
|
# https://docs.ejabberd.im/admin/guide/managing/#bash-completion
|
||||||
|
#
|
||||||
|
|
||||||
get_help()
|
get_help()
|
||||||
{
|
{
|
||||||
local COMMANDCACHE=/tmp/ejabberd_bash_completion_$RANDOM
|
local CACHE_BASE=/tmp/ejabberd_bash_completion
|
||||||
ejabberdctl $CTLARGS help tags >$COMMANDCACHE.tags
|
local DATESTRING=`date +%F-%H`
|
||||||
ejabberdctl $CTLARGS >$COMMANDCACHE
|
local CACHE=$CACHE_BASE.$DATESTRING
|
||||||
if [[ $? == 2 ]] ; then
|
local CACHE_COMS=$CACHE.coms
|
||||||
ISRUNNING=1
|
local CACHE_TAGS=$CACHE.tags
|
||||||
runningcommands=`cat $COMMANDCACHE | grep "^ [a-z]" | awk '{print $1}' | xargs`
|
if [[ ! -f $CACHE_COMS ]] ; then
|
||||||
runningtags=`cat $COMMANDCACHE.tags | grep "^ [a-z]" | awk '{print $1}' | xargs`
|
rm -f $CACHE_BASE.*
|
||||||
|
[ -f $CACHE_COMS ] || ejabberdctl $CTLARGS | sed "s|\x1B\[[0-9]*m||g" | grep "^ [a-z]" | awk '{print $1}' | xargs >$CACHE_COMS
|
||||||
|
[ -f $CACHE_TAGS ] || ejabberdctl $CTLARGS help tags | sed "s|\x1B\[[0-9]*m||g" | grep "^ [a-z]" | awk '{print $1}' | xargs >$CACHE_TAGS
|
||||||
|
fi
|
||||||
|
if [[ $? == 2 ]] || [[ -f $CACHE_COMS ]] ; then
|
||||||
|
ISRUNNING=1
|
||||||
|
runningcommands=`cat $CACHE_COMS`
|
||||||
|
runningtags=`cat $CACHE_TAGS`
|
||||||
fi
|
fi
|
||||||
rm $COMMANDCACHE
|
|
||||||
rm $COMMANDCACHE.tags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ejabberdctl()
|
_ejabberdctl()
|
||||||
|
Loading…
Reference in New Issue
Block a user