mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +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
|
||||
#
|
||||
# For installation and details see:
|
||||
# https://docs.ejabberd.im/admin/guide/managing/#bash-completion
|
||||
#
|
||||
|
||||
get_help()
|
||||
{
|
||||
local COMMANDCACHE=/tmp/ejabberd_bash_completion_$RANDOM
|
||||
ejabberdctl $CTLARGS help tags >$COMMANDCACHE.tags
|
||||
ejabberdctl $CTLARGS >$COMMANDCACHE
|
||||
if [[ $? == 2 ]] ; then
|
||||
ISRUNNING=1
|
||||
runningcommands=`cat $COMMANDCACHE | grep "^ [a-z]" | awk '{print $1}' | xargs`
|
||||
runningtags=`cat $COMMANDCACHE.tags | grep "^ [a-z]" | awk '{print $1}' | xargs`
|
||||
local CACHE_BASE=/tmp/ejabberd_bash_completion
|
||||
local DATESTRING=`date +%F-%H`
|
||||
local CACHE=$CACHE_BASE.$DATESTRING
|
||||
local CACHE_COMS=$CACHE.coms
|
||||
local CACHE_TAGS=$CACHE.tags
|
||||
if [[ ! -f $CACHE_COMS ]] ; then
|
||||
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
|
||||
rm $COMMANDCACHE
|
||||
rm $COMMANDCACHE.tags
|
||||
}
|
||||
|
||||
_ejabberdctl()
|
||||
|
Loading…
Reference in New Issue
Block a user