Module: check_mk
Branch: master
Commit: f42c2786b80c3f5b59d6793f7ea031130bb5dd8e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f42c2786b80c3f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 17 07:52:55 2018 +0200
Bash completion: Fixed "omd config set *" completions
Change-Id: I39b9041c6820b412601ec74d03580dc651630348
---
omd/packages/omd/bash_completion | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/omd/packages/omd/bash_completion b/omd/packages/omd/bash_completion
index edb2bd6..e880413 100644
--- a/omd/packages/omd/bash_completion
+++ b/omd/packages/omd/bash_completion
@@ -69,6 +69,7 @@ _omd()
done
local prev="${COMP_WORDS[COMP_CWORD-1]}"
+ local OMD_ROOT="/omd/sites/$site"
# omd -V|setversion ...
if [[ $prev =~ -V|setversion ]]; then
@@ -107,7 +108,7 @@ _omd()
# omd start|stop|restart|reload|status ...
elif [[ $subcmd =~ start|stop|restart|reload|status ]]; then
- opts="$(_omd_cmd_options $subcmd) $(env ls -1 /omd/sites/$site/etc/init.d/
2>/dev/null)"
+ opts="$(_omd_cmd_options $subcmd) $(env ls -1 $OMD_ROOT/etc/init.d/
2>/dev/null)"
# omd config ...
elif [[ $subcmd =~ config ]]; then
@@ -118,14 +119,16 @@ _omd()
# omd config set|show ...
elif [ ${#subcmdargs[@]} -eq 1 ]; then
- opts=$(awk -F= '{ print $1 }' /omd/sites/$site/etc/omd/site.conf |
sed 's/^CONFIG_//')
+ opts=$(awk -F= '{ print $1 }' $OMD_ROOT/etc/omd/site.conf | sed
's/^CONFIG_//')
# omd config set <option> ...
elif [ ${subcmdargs[0]} = "set" ]; then
- if [ $EUID -eq 0 ]; then
- opts=$(su - $site ./lib/omd/hooks/$prev choices | awk -F: '{ print $1
}')
- else
- opts=$(./lib/omd/hooks/$prev choices | awk -F: '{ print $1 }')
+ if [[ -e "$OMD_ROOT/lib/omd/hooks/$prev" ]]; then
+ if [ $EUID -eq 0 ]; then
+ opts=$(su - $site $OMD_ROOT/lib/omd/hooks/$prev choices | awk -F:
'{ print $1 }')
+ else
+ opts=$($OMD_ROOT/lib/omd/hooks/$prev choices | awk -F: '{ print
$1 }')
+ fi
fi
fi